yashar_turtle_chase package from yashar_turtle_chase repo

yashar_turtle_chase

Package Summary

Tags No category tags.
Version 0.0.0
License Apache License 2.0
Build type AMENT_PYTHON
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/yaswhar/yashar_turtle_chase.git
VCS Type git
VCS Version main
Last Updated 2025-04-20
Dev Status DEVELOPED
CI status No Continuous Integration
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Dynamic leader-follower turtlesim demo with leader switching service

Additional Links

No additional links.

Maintainers

  • Yashar Zafari

Authors

No additional authors.

This package and README file is written for the Robotics-Lab HW2. Yashar Zafari - Student Number: 99106209, Sharif University of Technology. email

๐Ÿข yashar_turtle_chase

A dynamic leader-follower demo using ROS2โ€™s turtlesim, where multiple turtles can follow a designated leader with real-time leader switching capability.

๐Ÿ“ฆ Overview

This package demonstrates a multi-turtle simulation where:

  • Multiple turtles are spawned in the turtlesim environment.
  • One turtle acts as the leader, controllable via keyboard.
  • Other turtles follow the leader using proportional control.
  • The leader can be switched dynamically at runtime.

๐Ÿงฐ Features

  • Dynamic Turtle Spawning: Automatically spawns a specified number of turtles at random, non-overlapping positions.
  • Leader-Follower Mechanism: Implements a simple proportional controller for followers to track the leaderโ€™s position.
  • Real-Time Leader Switching: Change the leader turtle during runtime using a ROS 2 topic.
  • Launch File: Convenient launch file to start the entire setup, including turtlesim, turtle spawner, follower logic, and teleoperation.

๐Ÿš€ Installation

  1. Clone the Repository:
   cd ~/ros2_ws/src
   git clone https://github.com/your_username/yashar_turtle_chase.git

2. **Install Dependencies**:

   
```bash
   cd ~/ros2_ws
   rosdep install --from-paths src --ignore-src -r -y
   
  1. Build the Package:
   colcon build --packages-select yashar_turtle_chase
   source install/setup.bash
   

๐Ÿงช Usage

Launch the Simulation

ros2 launch yashar_turtle_chase dynamic_chase.launch.py

This will:

  • Start the turtlesim_node.
  • Spawn the specified number of turtles (default is 2).
  • Initiate the dynamic follower node.
  • Teleoperate the leader in the command window opened.
  • Switch the leader in another terminal.

Control the Leader Turtle

Use the keyboard in the teleoperation terminal to move the leader turtle.

Switch the Leader Turtle

Publish a new leader name to the /switch_leader topic:

ros2 topic pub /switch_leader std_msgs/String "{data: 'turtle2'}"

Replace 'turtle2' with the desired turtle name (e.g., 'turtle1', 'turtle3', etc.).

๐Ÿง  Implementation Details

Follower Logic

The dynamic_follower.py node:

  • Subscribes to the /turtleX/pose topics to get the positions of all turtles.
  • Publishes velocity commands to /turtleY/cmd_vel for follower turtles.
  • Calculates the distance and angle to the leader and applies proportional control to follow.

Leader Detection

The current leader is stored as a variable within the node. It can be updated at runtime by publishing to the /switch_leader topic.

Challenges Faced

  • Dynamic Spawning: Ensuring turtles spawn at non-overlapping positions required implementing a check against existing positions.
  • Real-Time Leader Switching: Maintaining smooth transitions when changing leaders without disrupting follower behavior.

๐Ÿ“น Demonstration

https://github.com/user-attachments/assets/0013b428-5731-40c6-85f9-7b0369217965

In the demo, observe how the follower turtle tracks the leader and how switching the leader affects the behavior.

๐Ÿ“ License

This project is licensed under the Apache License 2.0.


For more information on ROS 2 and turtlesim, refer to the official ROS 2 tutorials.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange

No version for distro jazzy. Known supported distros are highlighted in the buttons above.
No version for distro kilted. Known supported distros are highlighted in the buttons above.
No version for distro rolling. Known supported distros are highlighted in the buttons above.
No version for distro noetic. Known supported distros are highlighted in the buttons above.
No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro eloquent. Known supported distros are highlighted in the buttons above.
No version for distro dashing. Known supported distros are highlighted in the buttons above.
No version for distro galactic. Known supported distros are highlighted in the buttons above.
No version for distro foxy. Known supported distros are highlighted in the buttons above.
No version for distro iron. Known supported distros are highlighted in the buttons above.
No version for distro lunar. Known supported distros are highlighted in the buttons above.
No version for distro jade. Known supported distros are highlighted in the buttons above.
No version for distro indigo. Known supported distros are highlighted in the buttons above.
No version for distro hydro. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.