[ROS2 Q&A] 226 – Work with ROS2 turtlesim

Written by Marco Arruda

05/01/2022

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.

Related courses & material:

Topics:
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This