In this post it will be shown how to work with Turtlesim with ROS 2, one of the best ways of testing ROS2 features with a very simple simulation
Configuring environment
In order to do that in a way anyone can reproduce, let’s use the App of TheconstructSim. Start by creating a new rosject here
After creating it, just hit the Run button and wait for the desktop environment to get ready.
Launch turtlesim simulation
Start by opening a web shell and executing the following command:
ros2 run turtlesim turtlesim_node
You must have some logs in the shell and the simulation ready in the graphical tools, like the image below:
Control using the keyboard
In order to control the robot using the teleop keyboard, we must check if the topics match. In that case, turtlesim has a namespace and the teleop keyboard must be re-mapped.
Check the topics of the simulator:
ros2 topic list
In that case, we need to map the keyboard to the topic /turtle1/cmd_vel
This is quite simple by using the cli, just run the node adding an argument, like below:
ros2 run teleop_twist_keyboard teleop_twist_keyboard cmd_vel:=/turtle1/cmd_vel
This is a quick way to start working with mobile robots. You can try many different algorithms quickly without having to configure a more complex simulation.
0 Comments