Skip to content

mohammad-alghazawi/turtlesim_catch_them_all

Repository files navigation

🐢 Turtlesim Catch Them All (ROS2)

A ROS2 project where a main turtle chases and catches randomly spawned turtles in the Turtlesim simulator.
Implemented in both Python and C++ to demonstrate cross-language ROS2 development.


📖 Overview

This project is inspired by the ROS2 for Beginners course by Edouard Renard.
The goal is to:

  • Spawn turtles one by one in the Turtlesim environment.
  • Control the main turtle to catch the nearest one.
  • Remove turtles once they are caught.

The project demonstrates:

  • ROS2 topics, services, and custom messages.
  • Writing ROS2 nodes in Python and C++.
  • Organizing a multi-package ROS2 workspace.

📂 Repository Structure

turtlesim_catch_them_all/
|
│── my_robot_bringup/         # Launch & config files      # Shared bringup
│── my_robot_interfaces/      # Custom messages & services # Shared interfaces
|
|── python_version/
│   └── turtlesim_catch_them_all/ # Python nodes (controller, spawner)
│
├── cpp_version/
│  └── turtlesim_project_cpp/    # C++ nodes (controller, spawner)
│
├── README.md
└── LICENSE

🚀 Features

  • Custom ROS2 messages (Turtle.msg, TurtleArray.msg)
  • Custom ROS2 service (CatchTurtle.srv)
  • Spawner node: publishes new turtles at random positions
  • Controller node: moves the main turtle to catch the nearest one
  • Cross-language implementation: Python and C++ versions

⚙️ Installation

Clone the repo into your ROS2 workspace:

cd ~/ros2_ws/src
git clone https://github.com/mohammad-alghazawi/turtlesim_catch_them_all.git
cd ..
colcon build
source install/setup.bash

▶️ Run Instructions

Python & C++ :

ros2 launch my_robot_bringup turtlesim_catch_them_all.launch.xml

📊 Comparison: Python vs C++

Feature Python Implementation C++ Implementation
Ease of writing ✅ Faster prototyping ⚡ High performance
Code readability 🟢 Very clear 🟡 More verbose
Execution speed 🟡 Slower 🟢 Faster
ROS2 ecosystem support ✅ Widely used ✅ Widely used

📸 Demo

Turtlesim Demo

Python & C++ implementations of the turtle-catching game in ROS2


📚 Learning Outcomes

  • Practiced ROS2 node development in both Python and C++.

  • Learned to define and use custom messages and services.

  • Gained experience in multi-package workspace organization.

  • Showcased ability to translate logic across languages.

📝 License

This project is licensed under the MIT License.

🙌 Acknowledgments

  • Inspired by the ROS2 for Beginners course by Edouard Renard.

  • Built with ROS2 and Turtlesim.

🙋‍♂️ Author

Mohammad Alghazawi — Mechatronics engineer (MSc) passionate about robotics, simulation, and ROS2 development.

About

A ROS2 simulation project with Turtlesim demonstrating topics, services, and custom interfaces. Includes both Python and C++ implementations of a turtle-catching game for learning and showcasing cross-language ROS2 development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors