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.
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.
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
- 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
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.bashros2 launch my_robot_bringup turtlesim_catch_them_all.launch.xml| 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 |
-
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.
This project is licensed under the MIT License.
-
Inspired by the ROS2 for Beginners course by Edouard Renard.
-
Built with ROS2 and Turtlesim.
Mohammad Alghazawi — Mechatronics engineer (MSc) passionate about robotics, simulation, and ROS2 development.
