create_obstacle_listener()
  • 1 Minute to read

create_obstacle_listener()


Article Summary

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

ArgumentsTypeDefault value
listener_namestringUnique listener identifier
callbackfunction or tupleCallback (see the Callback section in the Listeners Schema page)
lower_anglefloatLower bound of the angles range.
upper_anglefloatUpper bound of the angles range.
lower_distancefloat0.0Lower bound of the distance range.
upper_distancefloatfloat('inf')Upper bound of the distance range.
ang_unitenumANG_UNIT.DEGENUM to select the unit of the angle: (ANG_UNIT.DEG) degrees or (ANG_UNIT.RAD) radians
  • Both lower_angle and upper_angle must be into the range [angle_min, angle_max] from laser info (see LidarController.get_laser_info())
  • upper_angle must be higher than lower_angle.
  • At least one of both lower_distance or upper_distance must be speficied.
  • upper_distance must be higher than lower_distance.

Return

None

Exceptions

ExceptionCondition
RayaLidarInvalidAngleUnit
RayaInvalidNumericRangeupper_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?