This ROS package, assignment1_rt, implements a solution that involves controlling two turtles (turtle1 and turtle2) within the Turtlesim environment. The package includes two nodes:
- UI (node1): Manages user interaction and controls turtle spawning and movement.
- Distance (node2): Monitors the relative distance between the turtles and enforces boundary constraints.
- Spawn New Turtle (
turtle2)- Automatically spawns a second turtle in the Turtlesim environment.
- Interactive Command Interface
- Provides a text-based interface for the user to:
- Choose which turtle to control (
turtle1orturtle2). - Input velocity commands (linear and angular) for the selected turtle.
- Choose which turtle to control (
- Provides a text-based interface for the user to:
- Timed Command Execution
- Velocity commands are executed for 1 second, after which the turtle stops. The user can then input new commands.
- Distance Monitoring
- Computes and publishes the distance between
turtle1andturtle2on a dedicated topic.
- Computes and publishes the distance between
- Proximity Control
- Stops a turtle if it gets too close to the other turtle (user-defined threshold).
- Threshold = 2.0 (by default)
- Stops a turtle if it gets too close to the other turtle (user-defined threshold).
- Boundary Enforcement
- Stops a turtle if it moves out of the defined area:
xory> 10.0xory< 1.0
- Stops a turtle if it moves out of the defined area:
- ROS Noetic (recommended)
- Turtlesim package
sudo apt install ros-noetic-turtlesim
- Clone the repository into your ROS workspace
cd ~/ros1/src
git clone https://github.com/yuimomi/assignment1_rt.git
cd ~/ros1
catkin_make
- Source your workspace
source devel/setup.bash
- Launch Turtlesim
rosrun turtlesim turtlesim_node
- Start the Nodes
- Launch the UI Node (node1)
rosrun assignment1_rt UI
- Launch the Distance Node (node2)
rosrun assignment1_rt Distance
- Interact with the Interface
- Use the terminal interface to select a turtle and input velocity commands.
/turtle1/pose: Provides the position and orientation ofturtle1./turtle2/pose: Provides the position and orientation ofturtle2./cmd_vel: Accepts velocity commands for the turtles./distance_topic: Publishes the relative distance betweenturtle1andturtle2.
/spawn: Spawns a new turtle./kill: Removes a turtle.
assignment1_rt/
├── CMakeLists.txt
├── package.xml
├── src/
│ ├── UI.cpp # Implements the UI node
│ ├── Distance.cpp # Implements the distance monitoring node
└── README.md
- Code must be pushed to a GitHub repository with a clear commit history.
- README must clearly explain the code, its functionality, and how to run it.
- Bonus points for using both C++ and Python in your implementation.