check_obstacle()
- 1 Minute to read
check_obstacle()
- 1 Minute to read
Article summary
Did you find this summary helpful?
Thank you for your feedback
Check the presence of an obstacle into a specified range of angles and distances.
Reference
Arguments
Argument | Type | Default value | |
---|---|---|---|
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 | ANGLE_UNIT | DEGREES | ENUM to select the unit of the angle: (DEGREES ) degrees or (RADIANS ) 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
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?