Position controller to move the turtle simulatoin. Turtlesim is a lightweight simulator for learning ROS 2. It illustrates what ROS 2 does at the most basic level to give you an idea of what you will do with a real robot or a robot simulation later on;
Here, the turtle represents a robot that we want to control. Given a goal position
Where
Where
Note that to send the robot to a goal position, receive feedback and the final result, it is necessary to implement an interface for the action server. Check the turtlesim_interfaces package for more details.
Below, its a recording of a working demonstration. Note that we just sent the turtle some random positions to go.
Demo
Just clone this project in your ROS2 workspace:
cd ~/ros_ws/src
git clone https://github.com/luizcarloscf/autonomous-robots.git
cd ~/ros_ws
Then, build this package with:
rosdep install -i --from-path src --rosdistro humble -y
colcon build --packages-up-to=turtlesim_controller
source install/setup.bash
Finally, you can launch with:
ros2 launch turtlesim_controller turtlesim_controller_launch.py
The above launch script also starts the turtlesim controller. You can test it by opening another terminal and executing (just remenber to source the workspace in this new terminal):
source install/setup.bash
ros2 action send_goal /turtletask turtlesim_interfaces/action/TurtleTask "{x: 1.0, y: 10.0}"
The turtle controller exposes several configuration parameters, you can check them with:
ros2 param list
To modify the parameter:
ros2 param set /turtlesim_controller kp_angular 6
For more information about each configuration parameter, you can describe each one with:
ros2 param describe /turtlesim_controller kp_angular
Running with Docker
You can run the turtle simulation and its controller with Docker and a launch script:
docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw --rm luizcarloscf/autonomous-robots:main ros2 launch turtlesim_controller turtlesim_controller_launch.py
This program will run the turtle simulation and also run its controller. Using an action client, you can send the turtle wherever you want with, e.g.:
docker run -it --rm luizcarloscf/autonomous-robots:main ros2 run turtlesim_controller client -x 5 -y 8