Skip to content
forked from PoPGRI/Race

Race a Tesla Model 3 with model predictive control.

Notifications You must be signed in to change notification settings

AlexGisi/mpc-racing

 
 

Repository files navigation

mpc-racing

This repository contains an implementation of MPC-based racing in a Carla simulation. Features include

  • Smooth parameterization of racing tracks
  • Model predictive control formulation which maximizes the vehicle's progress along path
  • Custom combined PID and pure pursuit racing-tuned controllers for comparison
  • Optimization of MPC parameters using genetic algorithm
  • Kinematic, dynamic, and blended bicycle models with custom extensions to accurately model the simulation vehicle
  • Collect, visualize, and create filtered datasets from vehicle data
  • Train and evaluate tire models using pytorch

The simulation is built on the GRAIC platform for the CARLA simulator.

Install

First, follow the instructions to install GRAIC here. I found the following modifications are necessary:

  1. Get the carla install by following instructions at carla-simulator/carla#7017 (comment)

  2. Update networkx to 2.8: pip install networkx==2.8

  3. Add scenario_runner-0.9.13/srunner/tests/carla_mocks to pythonpath: export PYTHONPATH=$PYTHONPATH:/opt/scenario_runner-0.9.13/srunner/tests/carla_mocks

  4. install tkinter: sudo apt-get install python3-tk

If you did not install CARLA to /opt/carla-simulator, then change the parameters in auxillary/carla.py to match your install location. Then when you run python3 auxillary/carla.py, it should load the CARLA simulator on the Shanghai map.

Use

How to run (without scenarios):

  1. Start carla with python3 auxillary/carla.py.
  2. Run the GRAIC wrapper using the script python3 automatic_control_GRAIC.py.

Note the main branch implements the model predictive controller, while the pp branch implements the pure pursuit controller with the best parameters found via GA.

Project structure

The control directory holds mpc-related files. the models directory holds files related to the development of the vehicle models (these are re-implemented in casadi symbolics in control/mpc.py). The splines directory holds files related to the parameterization of the centerline and the lane boundaries. The script directory contains testing and visualization scripts for various parts of the project.

Contributors

About

Race a Tesla Model 3 with model predictive control.

Topics

Resources

Stars

Watchers

Forks

Languages

  • Python 100.0%