Skip to content

Preetbandgar/ros2-turtlesim-catch-them-all

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐒 ROS2 Multi-Node Control and Coordination

ROS2 Python Ubuntu


πŸ“Œ Overview

This project demonstrates a multi-node ROS2 application built using the Turtlesim simulator. A primary turtle (turtle1) autonomously chases dynamically spawned turtles using ROS2 nodes, topics, services, timers, and custom interfaces. The project focuses on ROS2 fundamentals and runtime introspection, not advanced robotics algorithms.


🧠 System Architecture

Nodes

  • /turtlesim (ROS2 provided) ROS2-provided simulation node. Publishes turtle pose and exposes /spawn and /kill services.

  • /turtle_spawner Spawns turtles periodically and publishes the list of active turtles.

  • /turtle_controller Subscribes to turtle pose and active turtle list, and publishes velocity commands to move turtle1.


πŸ”„ Communication

Topics

  • /turtle1/pose
  • /turtle1/cmd_vel
  • /alive_turtles

Services

  • /spawn
  • /kill

Custom Interfaces

Turtle.msg

string name
float32 x
float32 y
float32 theta

TurtleArray.msg

Turtle[] turtles

CatchTurtle.srv

string name
---
bool success

πŸ“‚ Repository Structure

ros2-turtlesim-catch-them-all/
β”œβ”€β”€ README.md
β”œβ”€β”€ screenshots/
β”‚   β”œβ”€β”€ launch_and_simulation.png
β”‚   β”œβ”€β”€ node_list.png
β”‚   β”œβ”€β”€ topic_list.png
β”‚   β”œβ”€β”€ alive_turtles_info.png
β”‚   └── rqt_graph.png
β”œβ”€β”€ videos/
β”‚   └── turtlesim_demo.gif
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ my_robot_bringup/
β”‚   β”‚   β”œβ”€β”€ launch/
β”‚   β”‚   β”‚   └── turtlesim_catch_them_all.launch.xml
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── catch_them_all_config.yaml
β”‚   β”‚   └── package.xml
β”‚   β”œβ”€β”€ my_robot_interfaces/
β”‚   β”‚   β”œβ”€β”€ msg/
β”‚   β”‚   β”‚   β”œβ”€β”€ Turtle.msg
β”‚   β”‚   β”‚   β”œβ”€β”€ TurtleArray.msg
β”‚   β”‚   β”œβ”€β”€ srv/
β”‚   β”‚   β”‚   └── CatchTurtle.srv
β”‚   β”‚   └── package.xml
β”‚   └── turtlesim_catch_them_all/
β”‚       β”œβ”€β”€ turtlesim_catch_them_all/
β”‚       β”‚   β”œβ”€β”€ turtle_controller.py
β”‚       β”‚   └── turtle_spawner.py
β”‚       └── package.xml


πŸ›  Prerequisites

  • Ubuntu 24.04 LTS
  • ROS2 Jazzy
  • Python 3.12

βš™οΈ Build Instructions

Update dependencies

  rosdep update
  rosdep install --from-paths src --ignore-src -y

Build workspace

  colcon build --symlink-install

Source environment

  source install/setup.bash

▢️ Run the Project

ros2 launch my_robot_bringup turtlesim_catch_them_all.launch.xml

πŸ” Runtime Introspection

Node List

ros2 node list

Node List

Topic List

ros2 topic list

Topic List

Topic Info

ros2 topic info /alive_turtles

Alive Turtles Topic Info

Node & Topic Graph

rqt_graph

RQT Graph


πŸŽ₯ Demo

A short demo video showing:

  • Launch execution
  • Turtle spawning
  • Autonomous chasing behavior
  • ROS2 introspection

πŸ“½ Demo Video:

Demo Video

πŸ§ͺ Expected Behavior

  • New turtles spawn periodically
  • Main turtle (turtle1) chases active turtles
  • System continues autonomously

🧠 ROS2 Concepts Demonstrated

  • ROS2 Nodes & packages
  • Publishers & subscribers
  • Services
  • Timers
  • Custom interfaces
  • Launch files
  • Runtime introspection (ros2 node, ros2 topic, rqt_graph)

πŸš€ Possible Improvements

  • Smarter target selection
  • Multi-hunter turtles
  • Event-based architecture
  • Dockerized deployment

πŸ“œ Credits

Based on the ROS2 for Beginners curriculum by Edouard Renard (Udemy), adapted and documented here as a reproducible hands-on ROS2 systems exercise.


πŸ‘€ Author

GitHub: https://github.com/Preetbandgar

About

Multi-node ROS2 fundamentals project using Turtlesim. Demonstrates nodes, topics, services, timers, custom messages, and runtime introspection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors