https://github.com/lin775533/ros_car_simulte
https://github.com/lin775533/ros_car_simulte
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lin775533/ros_car_simulte
- Owner: Lin775533
- Created: 2025-04-30T05:05:39.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-30T05:25:19.000Z (about 1 year ago)
- Last Synced: 2025-06-17T18:49:46.531Z (about 1 year ago)
- Language: Makefile
- Size: 98.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🤖 ROS Motion Planning & Control




## 📋 Overview
This repository contains implementation of motion planning and control algorithms for a TurtleBot3 robot using ROS and Gazebo simulation environment. The project focuses on:
- PID controller implementation for precise robot navigation
- Multiple control modes for robot movement
- Trajectory planning and execution
- Real-time pose monitoring and feedback
## 🗂️ Repository Structure
```
Lab3_YuChun_Lin_ws/
├── build/ # Build directory
├── devel/ # Development space
├── src/ # Source code
│ ├── pid_controller/ # Main ROS package
│ │ ├── src/
│ │ │ ├── pid_controller.py # PID implementation
│ │ │ └── motion_planner.py # Reference pose generator
│ │ ├── CMakeLists.txt
│ │ └── package.xml
└── catkin_workspace # Workspace configuration
```
## ⚙️ Implementation Details
### PID Controller (`pid_controller.py`)
The PID controller implements two separate control loops:
1. **Angular Velocity Controller**:
- Controls the robot's orientation
- Tunes robot turning to face target direction
- Parameters: Kp_angular, Ki_angular, Kd_angular
2. **Linear Velocity Controller**:
- Controls the robot's forward movement
- Manages acceleration and deceleration
- Parameters: Kp_linear, Ki_linear, Kd_linear
### Motion Planner (`motion_planner.py`)
The motion planner:
- Takes user input for desired position (x, y, θ)
- Publishes reference poses
- Monitors robot progress
- Supports two operation modes:
- **Mode 0**: Sequential control (rotate → move → rotate)
- **Mode 1**: Simultaneous position and orientation control
## 🚀 Control Modes
### Mode 0: Sequential Control
Control sequence:
1. First rotation to face target
2. Linear movement to target position
3. Final rotation to achieve target orientation
### Mode 1: Simultaneous Control
- Simultaneously controls both linear and angular velocities
- Robot moves in curved trajectories
- More efficient but potentially more complex control
## 💻 How to Run
1. **Start ROS master**:
```bash
roscore
```
2. **Launch Gazebo simulation environment**:
```bash
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
```
3. **Run PID controller node**:
```bash
rosrun pid_controller pid_controller.py
```
4. **Run motion planner node**:
```bash
rosrun pid_controller motion_planner.py
```
5. **Enter target coordinates when prompted**:
```
Enter x goal: 2.0
Enter y goal: 3.0
Enter theta goal (radians): 1.57
Enter mode (0 or 1): 1
```
## 📊 Performance Metrics
The system achieves high precision in target acquisition:
| Metric | Requirement | Achieved |
|--------|-------------|----------|
| Position Error | ≤ 0.1 meters | ✅ 0.05 meters |
| Orientation Error | ≤ 0.1 radians | ✅ 0.07 radians |
## 🔍 PID Tuning
For optimal performance, the PID parameters were tuned using the following approach:
1. Set Ki and Kd to zero
2. Increase Kp until system oscillates
3. Add Kd for dampening
4. Fine-tune Ki to eliminate steady-state error
Final parameters:
```python
# Angular Controller
Kp_angular = 1.5
Ki_angular = 0.01
Kd_angular = 0.5
# Linear Controller
Kp_linear = 0.8
Ki_linear = 0.01
Kd_linear = 0.2
```
## 📌 Author
**Yu-Chun Lin**
University of California, Irvine
Master of Embedded & Cyber-Physical Systems