check_obstacle()
  • 1 Minute to read

check_obstacle()


Article summary

Check the presence of an obstacle into a specified range of angles and distances.

Reference

Arguments

ArgumentTypeDefault value
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

bool
Returns True if the lidar detects an obstacle between the angles lower_angle and upper_angle, at a distance between lower_distance and upper_distance from the robot.

Exceptions

  • RayaLidarInvalidAngleUnit
  • RayaInvalidNumericRange

See the complete list of lidar exceptions.

Usage Example

Check if obstacle in front of the robot (angle range: [-15.0°, 15.0°]), at less than a meter and a half.

Code:

...
class RayaApplication(RayaApplicationBase):

    async def setup(self):
        self.lidar = self.enable_controller('lidar')
        ...

    async def loop(self):
      ...
      detection = self.lidar.check_obstacle(
                lower_angle=-15.0, 
                upper_angle=15.0, 
                lower_distance=1.5, 
                and_unit=ANG_UNIT.DEG
            )
      ...
            
    async def finish(self):
       ...


See the Lidar_listener example to check some valid uses.


Was this article helpful?