Skip to content

shaoanlu/sqp_nmpc_cbf_cvxpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MPC-based Unicycle Trajectory Tracking with Control Barrier Functions (CBFs)

Overview

This repository contains an example that implements a Model Predictive Control (MPC) controller for trajectory tracking of a unicycle while enforcing safety constraints using Control Barrier Functions (CBFs). The goal is to follow a predefined reference trajectory while avoiding an obstacle and staying within a safe region.

There are already many repositories with similar implementations, but most of them are using CasADi or MATLAB. This repository instead is a Python implementation that uses CVXPY for the QP subproblem and jax for autograd as well as parallelization.

Requirements

  • Python 3.10+
  • jax
  • cvxpy
  • numpy
  • matplotlib

Demo

To run the demo, simply run the sqp_mpccbf_tracking.ipynb notebook in Google Colab Open In Colab.

Key Features of the MPC-DCBF Implementation

  • Trajectory tracking with NMPC.
  • Discrete Control Barrier Functions (CBFs) to enforce h[k+1] - h[k] >= -a;pha * h[k] as a MPC constraint
  • Sequential Quadratic Programming (SQP) for handling nonlinearities and updating the linearization at each iteration.
  • QP formulation using cvxpy with cp.Parameter for warm-starting and fast updates.

Trouble Shooting

  • OSQP failed: remove time_limit argument in prob.solve(...) or increase max_sqp_iter or try different QP solvers.

About

Model predictive control with Discrete Control Barrier Function constraints using CVXPY

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published