Skip to content

Python implementation of mpc controller for path tracking

License

Notifications You must be signed in to change notification settings

mcarfagno/mpc_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mpc_python

I keep here my (old) notebooks on Model Predictive Control for path-following problems. Includes a Pybullet simulation to demo the controller. This mainly uses CVXPY as a framework. This repo contains code from other projecs, check them out in the special thanks section.

Contents

Jupyter Notebooks

  1. State space model derivation -> analytical and numerical derivaion of the model

  2. MPC -> implementation and testing of various tweaks/improvements

  3. Obstacle Avoidance -> Using halfplane constrains to avaoid track collisions -> Sill work in progress!

Results

Racing car model is from: https://github.com/erwincoumans/pybullet_robots.

Results:

The settings used for tuning the MPC controller are in the mpc_config class.

Usage

The results above can be reproduced both in Docker and Conda.

Docker

From this repository root directory:

docker build -t mpc-demo -f docker/Dockerfile .
  • To run the pybullet demo:
xhost +local:docker
docker run -it --net=host --ipc=host --privileged \
    --env="DISPLAY" \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    --volume="${XAUTHORITY}:/root/.Xauthority" \
    mpc-demo:latest \
    bash -c "python3 mpc_demo_pybullet.py"
  • To run the simulation-less demo: change the last command to python3 mpc_demo_nosim.py.
    • this is a simpler demo that does not use pybullet, useful for debugging.

In both cases the script will promt the user to press enter before starting the demo, pybullet may take a few seconds.

Conda Environment

The environment used for this project can be repoduced via conda:

conda env create -f env.yml
conda activate simulation

The demos can be run with:

python3 mpc_demo_pybullet.py
python3 mpc_demo_nosim.py

This environment also includes jupyter lab to experiment with the jupyter notebooks.

References & Special Thanks ⭐ :

About

Python implementation of mpc controller for path tracking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published