An autonomous navigation implementation for the ROS2 turtlesim environment. This project demonstrates a decoupled control strategy where a robot first rotates toward a waypoint and then translates toward it using tuned PID (Proportional-Integral-Derivative) controllers.
This repository contains a ROS2 package that enables a robot to follow a series of waypoints defined in a configuration file. The project is split into two phases:
- Part 1: Basic Goal Seeker – Implements the core logic to parse waypoints and navigate using a simple proportional controller and state-based movement (rotate-then-translate).
- Part 2: Full PID Controller – Enhances the movement profile by implementing full PID logic for both linear and angular velocities, ensuring smooth acceleration and deceleration while minimizing overshoot.
- ROS2 Humble (or compatible version)
- tf_transformations:
sudo apt install ros-humble-tf-transformations
- Clone this repository into your
colconworkspacesrcfolder. - Navigate to the workspace root and build:
colcon build --packages-select goal_seek
source install/setup.bash
To launch the full PID-controlled navigation along with the simulator:
ros2 launch goal_seek goal_seek_part_2.launch.py
Waypoints are managed via a text file located at goal_seek/config/goals.txt. The format is simple space-separated x y coordinates:
4.5 6.4
7.6 2.4
8.7 2.3
The robot follows a state-machine approach within the Odometry callback:
- Heading Correction: If the angular error exceeds the threshold, the robot stops linear movement and rotates.
- Translation: Once facing the goal, the robot moves forward, using the PID controller to ramp down velocity as it approaches the coordinate.
- Wait State: Upon reaching a goal (within a defined distance threshold), the robot pauses for 5 seconds before fetching the next waypoint.
The control output is calculated as:
Where:
- Proportional (): Corrects based on current error.
- Integral (): Eliminates steady-state error.
- Derivative (): Dampens oscillations and prevents overshoot.
goal_seek_part_2.py: The primary node featuring the PID controller.publish_odom.py: A utility node that convertsturtlesim/Posedata into standardnav_msgs/Odometry.launch/: Contains Python launch files to bring up the simulation and controllers simultaneously.