Welcome to the Turtle Carnage game repository! 🐢🚀
In this game, turtles engage in relentless pursuit, chasing, and outwitting each other. The main components include:
- turtlesim_node: The environment where our turtle characters reside.
- turtle_spawner: Responsible for spawning new turtles with random positions and orientations.
- turtle_controller: Manages the movement and behavior of the turtles.
Here's how the game unfolds:
-
Spawn New Turtles:
- The
turtle_spawner
node generates random positions (x, y) and orientations (θ) for new turtles. - It sends a spawn request to the
/Spawn
service, creating a fresh turtle.
- The
-
Target Setting:
- The
turtle_spawner
node also communicates with the/target_pose
server. - It sets the target turtle's name and position.
- The
-
Control Loop:
- The
turtle_controller
node runs a control loop at 0.1Hz. - It calculates linear and angular velocities based on the target position.
- These velocities are published to the
/cmd_vel
topic.
- The
-
Chase and Capture:
- The turtle moves toward the target.
- Once it reaches within a clearance of 0.25 units, it stops moving.
-
Target Elimination:
- The
turtle_controller
node sends a kill request to the/kill_turtle
server. - The target turtle is eliminated.
- The
-
Repeat:
- The
turtle_spawner
node receives the client registration. - It sends a client request to the
/kill
service of theturtlesim_node
. - A new target turtle is spawned, and the cycle continues.
- The
TurtleCarnage.mp4
- Ubuntu 22.04
- ROS2 Humble
- Python 3.10
- Create a ROS2 workspace:
mkdir ros2_ws cd ros2_ws mkdir src colcon build
- If colcon is not installed, run:
sudo apt update sudo apt install python3-colcon-common-extensions
- Add the ROS2 workspace to your ~/.bashrc:
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc source ~/.bashrc
Place the following folders inside the src
folder:
turtle_carnage
my_robot_interfaces
my_robot_bringup
cd ros2_ws
colcon build
source ~/.bashrc
cd
ros2 launch my_robot_bringup turtle_carnage_app.launch.py
Feel free to explore the code and have fun with the turtles! 🐢🎮