This repository contains a ROS 2 implementation of autonomous navigation behaviors for the TurtleBot3 (Burger). It features a reactive Wall Follower and a Bug2 Algorithm that enables the robot to navigate toward a global goal while avoiding obstacles by switching between goal-seeking and boundary-following states.
- Reactive Wall Following: Utilizes LiDAR data to maintain a consistent distance (0.5m - 0.7m) from walls on the right side of the robot.
- Bug2 Navigation: Implements a finite state machine to navigate to specific (x, y) coordinates.
- PID Control: Uses proportional control for smooth angular and linear velocity adjustments during goal seeking.
- M-Line Tracking: Calculates the distance to the direct path between the start and goal to determine when to exit obstacle avoidance.
- ROS 2 (Humble or Foxy)
- TurtleBot3 Simulation Packages
- Gazebo
- Clone this repo into your workspace
srcfolder:
cd ~/ros2_ws/src
git clone <your-repo-link>
- Build the package:
cd ~/ros2_ws
colcon build --packages-select turtlebot3_navigation
source install/setup.bash
To launch the robot in an environment where it will follow the right-hand wall indefinitely:
ros2 launch turtlebot3_navigation wall_follow.launch.py
To navigate to a specific goal (default defined in params.yaml):
ros2 launch turtlebot3_navigation bug2.launch.py
The robot samples LiDAR ranges at specific angles:
- Front:
0°to10°and350°to360°to detect obstacles ahead. - Right:
320°to350°to monitor the wall distance. It maintains a distance between0.5and0.7meters. If it gets too close, it steers left; if too far, it steers right.
- Goal Seek: The robot calculates the heading to the goal and moves forward.
- Wall Follow: If an obstacle is detected, the robot switches to wall following.
- Transition: It continues following the wall until it intersects the "M-line" (the original straight line from start to goal) and is closer to the goal than when it started following the wall.
You can change the navigation target by editing turtlebot3_navigation/config/params.yaml:
goal_position: [2.0, -1.2]

