lidar_scan


Overview

The lidar_scan example demonstrates how to use LiDAR sensors for obstacle detection while moving the robot forward and backward.

Execution

The application can be executed using:

python3 lidar_scan/ --auto-run

Inputs

  • No mandatory command-line arguments.

  • The application automatically enables the front LiDAR sensor.

Outputs

  • Log messages indicating motion status and obstacle detection.

  • The robot moves forward and backward for 5 seconds unless an obstacle is detected.

Behavior

  • The application enables the front LiDAR sensor and starts moving forward.

  • If an obstacle is detected within 40 cm, it stops, disables the front LiDAR, and enables the rear LiDAR.

  • The robot then moves backward until another obstacle is detected within 40 cm.

  • Upon detecting the second obstacle, the robot stops and the application finishes.

Example Output

During execution, the output logs follow this pattern:

[INFO] [timestamp] [pyraya.lidar_scan]: Auto running the app
[INFO] [timestamp] [pyraya.lidar_scan]: Moving 5 seconds forward...
[WARNING] [timestamp] [pyraya.lidar_scan]: Obstacle!
[WARNING] [timestamp] [pyraya.lidar_scan]: Stopping robot movement...
[INFO] [timestamp] [pyraya.lidar_scan]: Moving 5 seconds backward...
[WARNING] [timestamp] [pyraya.lidar_scan]: Obstacle!
[INFO] [timestamp] [pyraya.lidar_scan]: Unsubscribing to topics...

Key Note

  • The enable_obstacles setting is disabled to test the LiDAR sensors.

  • The motion automatically adjusts based on detected obstacles, ensuring safety during navigation.

  • The application disables the obstacle avoidance system to test LiDAR functionality.