| 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest | 
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged yashar_turtle_chase at Robotics Stack Exchange
         
       | 
      
        yashar_turtle_chase package from yashar_turtle_chase repoyashar_turtle_chase | 
      
         ROS Distro
       | 
    
Package Summary
| 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-08-03 | 
| Dev Status | DEVELOPED | 
| Released | UNRELEASED | 
| Contributing | 
        
          Help Wanted (-)
        
         Good First Issues (-) Pull Requests to Review (-)  | 
    
Package Description
Maintainers
- Yashar Zafari
 
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 
turtlesimenvironment. - 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
- 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
   
- 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/posetopics to get the positions of all turtles. - Publishes velocity commands to 
/turtleY/cmd_velfor 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
File truncated at 100 lines see the full file
Package Dependencies
| Deps | Name | 
|---|---|
| rosidl_default_generators | |
| ament_cmake | |
| rclpy | |
| turtlesim | |
| geometry_msgs | |
| std_msgs | |
| ament_copyright | |
| ament_flake8 | |
| ament_pep257 | |
| ament_lint_auto | |
| ament_lint_common | |
| rosidl_default_runtime | 
System Dependencies
| Name | 
|---|
| python3-pytest |