Autonomous driving simulation using the CARLA Simulator🚗. It implements a complete pipeline including:
- Environment Setup: Loading a CARLA world (e.g., Town03), configuring synchronous mode, and spawning vehicles (ego and obstacles).
- Path Planning: Generating collision-free paths using sampling-based algorithms (RRT, RRT*, and Informed RRT*) implemented in
RRT.py
. - Trajectory Generation: Smoothing the planned path using motion primitives via cubic polynomial interpolation in
motion_primitive.py
. - Vehicle Control: Controlling the ego vehicle using a combination of PID controllers for longitudinal (throttle/brake) and lateral (steering) actions, implemented in
controller.py
. - Real-Time Visualization: Displaying a camera view using PyGame and a live-updating trajectory plot using Matplotlib.
-
main.py:
Main source code that sets up the simulation, spawns vehicles, attaches sensors, executes path planning, generates trajectories, runs the control loop, and displays real-time visualizations. -
RRT.py:
Contains the implementation of RRT, RRT*, and Informed RRT* algorithms for path planning. -
motion_primitive.py:
Implements motion primitive generation using cubic polynomial interpolation for smooth trajectory creation. -
controller.py:
Implements PID controllers for both longitudinal (speed) and lateral (steering) vehicle control.
- CARLA Simulator:
Download and install CARLA from here. Ensure the CARLA server is running before executing the project.
-
Clone the Repository:
git clone https://github.com/taherfattahi/carla-motion-planning-rrt-based cd carla-motion-planning-rrt-based
-
Install the Required Python Packages:
pip install numpy matplotlib pygame scipy
- Start the CARLA Server:
Run the CARLA simulator (e.g., execute ./CarlaUE4.sh
on Linux or run the executable on Windows).
- Run the Main Script:
python main.py
Contributions are welcome. If you find a bug or have a feature request, please open an issue or submit a pull request.
- CARLA Open-source simulator for autonomous driving research.
- Robotic Path Planning: RRT and RRT*
- The PID Controller & Theory Explained