create_obstacle_listener()
- 1 Minute to read
create_obstacle_listener()
- 1 Minute to read
Article summary
Did you find this summary helpful?
Thank you for your feedback
Creates a listener triggered when an obstacle is found with the selected parameters (as in check_obstacle). The callback is called only once when the condition meets.
Reference
Arguments
Arguments | Type | Default value | |
---|---|---|---|
listener_name | string | Unique listener identifier | |
callback | function or tuple | Callback (see the Callback section in the Listeners Schema page) | |
lower_angle | float | Lower bound of the angles range. | |
upper_angle | float | Upper bound of the angles range. | |
lower_distance | float | 0.0 | Lower bound of the distance range. |
upper_distance | float | float('inf') | Upper bound of the distance range. |
ang_unit | enum | ANG_UNIT.DEG | ENUM to select the unit of the angle: (ANG_UNIT.DEG ) degrees or (ANG_UNIT.RAD ) radians |
- Both
lower_angle
andupper_angle
must be into the range[angle_min, angle_max]
from laser info (see LidarController.get_laser_info()) upper_angle
must be higher thanlower_angle
.- At least one of both
lower_distance
orupper_distance
must be speficied. upper_distance
must be higher thanlower_distance
.
Return
None
Exceptions
Exception | Condition |
---|---|
RayaLidarInvalidAngleUnit | |
RayaInvalidNumericRange | upper_angle is lower than lower_angle or none of lower_distance and upper_distance are specified or upper_distance is lower than lower_distance. |
See the complete list of Raya Exceptions.
Callback Arguments
Callback does not receive any arguments.
Examples
async def setup(self):
self.lidar.create_obstacle_listener(listener_name='obstacle',
callback=self.callback_obstacle,
lower_angle=260,
upper_angle=280,
upper_distance=2.0)
async def loop(self):
await self.sleep(1.0)
self.log.info('Doing other (non blocking) stuff!')
def callback_obstacle(self):
self.log.warning('Obstacle!')
(INFO)<RayaApp.app.app> Doing other (non blocking) stuff!
(INFO)<RayaApp.app.app> Doing other (non blocking) stuff!
(WARNING)<RayaApp.app.app> Obstacle!
(INFO)<RayaApp.app.app> Doing other (non blocking) stuff!
TODO!
Go back to the Lidar Controller page.
Was this article helpful?