DEV Community

ros turtlesim for beginners

ros2 turtlesim
the humble turtlesim is a beginer level simulation tool

Hey everyone ๐Ÿ‘‹ Iโ€™m Nagu, and this is my first blog post on the DEV Community!
In this post, weโ€™ll explore Turtlesim, a fun and simple simulator in ROS 2 (Robot Operating System 2) โ€” perfect for beginners who want to start learning robotics and ROS commands.

๐Ÿš€ What is ROS 2 Humble?

ROS 2 Humble Hawksbill is a popular Long-Term Support (LTS) version of ROS 2.
Itโ€™s widely used for building and simulating robots โ€” from simple mobile bots to advanced AI-driven systems.

๐Ÿข What is Turtlesim?

Turtlesim is a lightweight simulator that shows a small turtle in a 2D world.
Itโ€™s often the first step to understanding ROS concepts such as:

Nodes ๐Ÿงฉ (independent programs)

Topics ๐Ÿ—ฃ๏ธ (communication channels)

Services โš™๏ธ (request/response system)

Parameters โšก (settings and configurations)

โš™๏ธ Step 1: Install ROS 2 Humble

If you havenโ€™t installed ROS 2 yet, open your terminal and run:

sudo apt update && sudo apt upgrade -y
sudo apt install ros-humble-desktop
Then source it:
source

/opt/ros/humble/setup.bash
(Tip: Add this line to your .bashrc so it auto-loads every time you open a terminal)

๐Ÿงฉ Step 2: Install Turtlesim

sudo apt install ros-humble-turtlesim
Check if itโ€™s installed:

ros2 pkg list | grep turtlesim
note :sometimes ros2 command not found in terminal
in that case it better to switch to root terminal by the below command

sudo su
๐Ÿ–ฅ๏ธ Step 3: Run Turtlesim

Launch the turtlesim window:

ros2 run turtlesim turtlesim_node
A blue window will appear with a turtle in the center ๐Ÿข๐Ÿ’™

๐ŸŽฎ Step 4: Control the Turtle

Open another terminal and run:

ros2 run turtlesim turtle_teleop_key
after clicks of some keys
โฌ†๏ธโžก๏ธโฌ‡๏ธโฌ…๏ธ

Now use your arrow keys to move the turtle around.
Congrats โ€” you just published your first commands in ROS 2!

๐Ÿง  Step 5: Explore Basic Commands

List all active topics:

ros2 topic list

See messages being published: while you are controling the turtle by arrow keys

ros2 topic echo /turtle1/cmd_vel


linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0

z: -2.0

linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0

z: 2.0

WHEN YOU TOUCH THE EDGE OF THE WINDOW it publish to the

turtlesim_node
terminal
[WARN] [1761550426.649414936] [turtlesim]: Oh no! I hit the wall! (Clamping from [x=11.120421, y=4.634281])

Clear the screen:

ros2 service call /clear std_srvs/srv/Empty
Change the background color:

ros2 param set /turtlesim background_r 200
ros2 param set /turtlesim background_g 100
ros2 param set /turtlesim background_b 150
ros2 service call /clear std_srvs/srv/Empty
๐Ÿ’ก What You Learned

โœ… How to install and run ROS 2 Humble
โœ… How to launch and control Turtlesim
โœ… How to explore topics, services, and parameters
the official website for ros

This is just the beginning of your ROS 2 journey โ€” next, weโ€™ll write a Python node to move the turtle automatically!

โœ๏ธ Final Words

Thanks for reading!
If you enjoyed this post or found it helpful, leave a โค๏ธ and follow me for more tutorials on ROS 2, Ubuntu, and Ethical Hacking.
and since it is my first ever blog please support me for more info

โ€œDonโ€™t prove, just improve.โ€ โ€” Nagu

Would you like me to write your next post script โ€” the one about controlling Turtlesim using Python code
see you soon guys

Top comments (0)