LiDAR-based reactive wall-following robot for ROS2 Jazzy. The robot follows the left wall by monitoring laser scan regions and adjusting velocity — no Nav2 or SLAM required.
The node divides the LiDAR scan into three regions:
Front (-15° to 15°)
┌───┐
│ │
Front-Left ──────▶│ R │
(30° to 60°) │ │
│ │
Left ───────────▶│ │
(80° to 100°) └───┘
Decision logic:
- Wall ahead (front < threshold) → slow down, turn right
- Too far from wall (left > target × 1.5) → turn left to approach
- Too close to wall (left < target × 0.7) → turn right to move away
- Tracking → proportional control using front-left distance error
- ROS2 Jazzy
- TurtleBot3 Gazebo (
ros-jazzy-turtlebot3-gazebo)
cd ~/ros2_ws/src
git clone https://github.com/manavsikkas/ros2_wall_follower.git
cd ..
colcon build --packages-select ros2_wall_follower
source install/setup.bashexport TURTLEBOT3_MODEL=waffle
ros2 launch ros2_wall_follower wall_follower.launch.pyWith Gazebo GUI:
ros2 launch ros2_wall_follower wall_follower.launch.py gui:=true| Parameter | Default | Description |
|---|---|---|
target_distance |
0.5 |
Desired distance from the wall (meters) |
max_linear_speed |
0.2 |
Maximum forward speed (m/s) |
max_angular_speed |
1.5 |
Maximum turn rate (rad/s) |
front_threshold |
0.6 |
Distance to trigger front-wall avoidance (meters) |
use_stamped_cmd_vel |
true |
Publish TwistStamped (Gazebo Harmonic) vs Twist |
| Topic | Type | Direction | Description |
|---|---|---|---|
/scan |
LaserScan |
Subscribe | LiDAR scan data |
/cmd_vel |
TwistStamped |
Publish | Velocity commands |
MIT