A ROS2 action server that moves a turtlesim turtle in a perfect square pattern using precise proportional control.
This project implements a ROS2 action server that controls a turtlesim turtle to draw precise squares.
-
Clone/Navigate to workspace:
cd ~/projet
-
Build the packages:
colcon build
-
Source the workspace:
source install/setup.bash
ros2 run turtlesim turtlesim_nodesource ~/projet/install/setup.bash
ros2 run turtle_square_controller draw_square_action_serverBasic usage:
ros2 action send_goal /draw_square turtle_square_interfaces/action/DrawSquare "{side_length: 2.0, speed: 1.0}"With feedback:
ros2 action send_goal --feedback /draw_square turtle_square_interfaces/action/DrawSquare "{side_length: 2.0, speed: 1.0}"Different sizes and speeds:
# Small fast square
ros2 action send_goal /draw_square turtle_square_interfaces/action/DrawSquare "{side_length: 1.0, speed: 2.0}"
# Large slow square
ros2 action send_goal /draw_square turtle_square_interfaces/action/DrawSquare "{side_length: 3.0, speed: 0.5}"
# Medium square
ros2 action send_goal /draw_square turtle_square_interfaces/action/DrawSquare "{side_length: 2.5, speed: 1.5}"The controller:
- Subscribes to
/turtle1/poseto monitor the turtle's position - Publishes to
/turtle1/cmd_velto control velocity - Uses MultiThreadedExecutor to process pose updates while executing movements
- Applies proportional control for both:
- Forward movement:
linear.x = min(Kp × distance_error, max_speed) - Rotation:
angular.z = min(Kp × angle_error, max_speed)
- Forward movement:
This implementation is inspired by:
"Overshoot Avoiding Control for Rigid Robots" by Figen Özen
The paper introduces OACA (Overshoot Avoiding Control Algorithm), which combines:
- Proportional-Derivative (PD) control
- Constant Error Acceleration
- Overshoot prevention through proportional speed reduction
Our implementation simplifies this to pure proportional control (P-control) which is sufficient for turtlesim's 2D environment and eliminates overshoot entirely.
- OUBRAHAM Maya
- SADI Mohamed Mouaad
- SAMIR Yassine
- SEKOUANE Amel
Apache-2.0