Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

167 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mpc_python

A (hopefully) easy-to-follow Iterative MPC tracking controller built with CVXPY and paired with MuJoCo. Designed to help anyone looking to transition from basic control to real-time convex optimization.

MuJoCo simulation with the mushr car model

This mainly uses CVXPY to maintain a strict quadratic programming framework rather than relying on a non-linear solver like CasADi (which I love btw!). But, implementing an iMPC, we can still bridge the gap between convex optimization and real-world vehicle physics, allowing you to handle non-linear kinematics through iterative linearization.

MuJoCo simulation with the mushr car model

Headless toy demo with dummy car

Note: I've also preserved my original notebooks on Model Predictive Control for path-following problems here for historical context, a bit outdated.

This repo builds upon code and ideas from other open-source projects; please check them out in the Special Thanks section!

Getting started

Nix Flake ❄️

A Nix flake is provided for a reproducible development shell.

Just run the 2 examples below:

nix run --impure .#mujoco-demo
nix run .#nosim-demo

Otherwise, enter the development shell: this is heavier but also includes jupyter lab to experiment with the notebooks.

nix develop --impure

GUI demos require nixGL (auto-detects Intel/AMD/NVIDIA GPU):

nixGL python mpc_python/mpc_demo_mujoco.py

Headless demos run without it:

python mpc_python/mpc_demo_nosim.py

Conda

conda env create -f env.yml
conda activate simulation

Then run the scripts:

python3 mpc_demo_mujoco.py
python3 mpc_demo_nosim.py

Notebooks

  1. Model derivation — analytical and numerical derivation (1.0, parametrized curves, differential, motion model)

  2. MPC — implementation and testing of various tweaks (2.0, 2.1, 2.2, 2.3)

  3. Obstacle Avoidance — halfplane constraints to avoid track collisions (3.0, 3.1) — Still work in progress!

References & Special Thanks ⭐ :

About

A simple MPC controller for path tracking implemented in python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages