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_unitANGLE_UNITDEGREESENUM to select the unit of the angle: (DEGREES) degrees or (RADIANS) 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

  • RayaLidarInvalidAngleUnit
  • RayaInvalidNumericRange

See the complete list of lidar exceptions.

Usage Example

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!



Was this article helpful?

What's Next