sudo apt update
sudo apt install ros-humble-turtlesim
ros2 pkg executables turtlesim
You should see:
turtlesim draw_square
turtlesim mimic
turtlesim turtle_teleop_key
turtlesim turtlesim_node
ros2 run turtlesim turtlesim_node
🐢 A window will pop up showing a turtle in the center.
📜 Terminal output will show:
[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim
[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
🖥️ Open a new terminal, source ROS 2 again, and run:
ros2 run turtlesim turtle_teleop_key
- ⬆️⬇️⬅️➡️ Use your arrow keys to move the turtle.
- 🐢 Each key press moves the turtle a small distance, just like a real robot.
ros2 node list
ros2 topic list
ros2 service list
ros2 action list
sudo apt update
sudo apt install '~nros-humble-rqt*'
rqt
- Navigate to Plugins > Services > Service Caller.
- 💡 If plugins don’t appear, run:
rqt --force-discover
🔄 In rqt, refresh the service list.
🛠️ Select the /spawn service and set:
- name: turtle2
- x: 1.0
- y: 1.0
✅ Click Call to spawn turtle2.
If you try to spawn turtle1 again, you’ll see:
[ERROR] [turtlesim]: A turtle named [turtle1] already exists
🎨 In rqt, select the /turtle1/set_pen service and set:
- r: 255 (Red)
- g: 0
- b: 0
- width: 5
✅ Click Call — turtle1 will now draw in red with thicker lines.
🕹️ To control turtle2, run this in a new terminal:
ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel
- Terminal 1 controls turtle1.
- Terminal 2 controls turtle2.
- Press Ctrl + C in the turtlesim_node terminal.
- Press q in the turtle_teleop_key terminal.
✅ Installed turtlesim
✅ Moved the turtle using teleop
✅ Explored nodes, topics & services
✅ Used rqt to spawn and customize turtles
✅ Controlled multiple turtles with remapping
Thanks for following this guide! 🐢 Dive deeper into ROS 2 for building awesome robotic projects!