This project involves developing a Python script to control the motion of the Turtlesim robot in ROS (Robot Operating System). Users can select from various predefined motion trajectories and provide specific parameters to guide the robot’s movements accordingly.
The system provides the following motion trajectory options:
- Square: The turtle moves in a square path.
- Triangle: The turtle draws an equilateral triangle.
- Circular: The turtle moves in a circular path.
- Spiral: The turtle moves in a spiral pattern.
- Point to Point: The turtle navigates to a specific (x, y) destination from its current position.
- Zigzag Motion: The turtle moves back and forth in a zigzag pattern using triangular paths.
- Exit: Exit the program.
The script prompts the user to select one of the motion trajectories and provides specific instructions based on the chosen trajectory:
- Prompt: Enter the edge dimension of the square.
- Action: The turtle will move in a square path with the specified edge length.

- Prompt: Enter the length of the triangle’s side.
- Action: The turtle will draw an equilateral triangle.

- Prompt: Enter the radius of the circle.
- Action: The turtle will move in a circular path with the given radius.

- Prompt: Enter the change in radius for the spiral shape.
- Action: The turtle will move in an expanding or contracting spiral based on the input.

- Prompt: Enter the destination coordinates (x, y).
- Action: The turtle will navigate from its current position to the specified destination.

- Prompt: The system will prompt for required parameters to execute zigzag motio
- Action: The turtle will navigate back and forth using triangular paths to create a zigzag pattern.

- Action: Terminates the program.
- ROS: Installed and configured on your system.
- Turtlesim Package: Available in the ROS environment.
- Python 3.x: Required to execute the script.
-
Clone the repository:
cd turtlesim_motion_trajectory -
Navigate to the project directory:
cd turtlesim_motion_trajectory -
Ensure the ROS environment is sourced:
source /opt/ros/<ros_distro>/setup.bash
-
Run the Python script:
python3 motion_trajectory.py
-
Launch the Turtlesim node in ROS:
rosrun turtlesim turtlesim_node
-
Execute the Python script to interact with the trajectory system.
-
Follow the prompts to select a motion trajectory and provide the required parameters.
Select one of the following motion trajectories for turtle robot:
1. Square
2. Triangle
3. Circular
4. Spiral
5. Point to Point
6. Zigzag motion
7. Exit
Enter your choice (1-7): 3
Enter the radius of the circle: 5
The turtle will then move in a circular trajectory with a radius of 5 units.