check_obstacle()¶
Check the presence of an obstacle into a specified range of angles and distances.
Reference¶
Arguments¶
Argument |
Type |
Default value |
|
|---|---|---|---|
|
|
Lower bound of the angles range. |
|
|
|
Upper bound of the angles range. |
|
|
|
|
Lower bound of the distance range. |
|
|
|
Upper bound of the distance range. |
|
|
|
ENUM
to select the unit of the angle:
( |
Both
lower_angleandupper_anglemust be into the range[angle_min, angle_max]from laser info (see LidarController.get_laser_info())upper_anglemust be higher thanlower_angle.At least one of both
lower_distanceorupper_distancemust be speficied.upper_distancemust be higher thanlower_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¶
RayaLidarInvalidAngleUnitRayaInvalidNumericRange
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):
...