Skip to content

Anil-CAI/Ros-_Turtlesim_Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🐢 ROS 2 Humble - Turtlesim Guide 🐢

✨ Complete Step-by-Step Tutorial to Install, Use & Control Turtlesim in ROS 2 Humble ✨


🚀 Step 1: Install Turtlesim Package


sudo apt update
sudo apt install ros-humble-turtlesim

✅ Check Installation:


ros2 pkg executables turtlesim

You should see:


turtlesim draw_square
turtlesim mimic
turtlesim turtle_teleop_key
turtlesim turtlesim_node

🕹️ Step 2: Launch Turtlesim Simulator


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]

🎮 Step 3: Control the Turtle

🖥️ Open a new terminal, source ROS 2 again, and run:


ros2 run turtlesim turtle_teleop_key

✅ Controls:

  • ⬆️⬇️⬅️➡️ Use your arrow keys to move the turtle.
  • 🐢 Each key press moves the turtle a small distance, just like a real robot.

🔍 Step 4: Explore Nodes, Topics & Services


ros2 node list
ros2 topic list
ros2 service list
ros2 action list

🛠️ Step 5: Install and Use rqt


sudo apt update
sudo apt install '~nros-humble-rqt*'

🖥️ Launch rqt:


rqt

✅ First Time Setup:

  • Navigate to Plugins > Services > Service Caller.
  • 💡 If plugins don’t appear, run:

rqt --force-discover

✨ Step 6: Spawn a Second Turtle

🔄 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.

⚠️ Note:

If you try to spawn turtle1 again, you’ll see:


[ERROR] [turtlesim]: A turtle named [turtle1] already exists

🎨 Step 7: Change Pen Color

🎨 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.


🐢 Step 8: Control Turtle 2 (Remapping)

🕹️ To control turtle2, run this in a new terminal:


ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel

✅ Now:

  • Terminal 1 controls turtle1.
  • Terminal 2 controls turtle2.

❌ Step 9: Close Turtlesim

  • Press Ctrl + C in the turtlesim_node terminal.
  • Press q in the turtle_teleop_key terminal.

📚 Summary

✅ Installed turtlesim
✅ Moved the turtle using teleop
✅ Explored nodes, topics & services
✅ Used rqt to spawn and customize turtles
✅ Controlled multiple turtles with remapping


💬 Final Note

Thanks for following this guide! 🐢 Dive deeper into ROS 2 for building awesome robotic projects!


🌐 Connect With Me

anil ai

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors