Skip to content
Model Predictive Contouring Controller (MPCC) for Autonomous Racing
Branch: master
Clone or download
alexliniger Merge pull request #5 from ValerioMa/master
updated to new set interface
Latest commit 6a5529b Feb 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Images doc added to readme Oct 3, 2018
Matlab updated to new set interface Feb 10, 2019
LICENSE Initial commit Oct 1, 2018


Simulation environment of the Model Predictive Contouring Controller (MPCC) for Autonomous Racing developed by the Automatic Control Lab (IfA) at ETH Zurich


The MPCC is a model predictive path following controller which does follow a predefined reference path X^ref and Y^ref. This is achieved by augmenting the system with an integrator stated theta which approximates the progress along the reference path. The theta state is coupled to the real dynamics using the lag error e^l which is penalized in the cost. Additionally, the contouring error (lateral error to the reference path) is also penalized in the cost function. Finally, the progress along the reference path is maximized to achieve that the car does follow the path as fast as possible and the rate of the inputs is penalized. To guarantee that the car stays within the track, track constraints are imposed as well as bounds on all states, inputs and the rate of inputs. The resulting optimization problem is shown in the following equation:

The vehicle dynamics considered is a bicycle model with nonlinear magic formula tire models:

with the tire model and drive train model given as follows:

Finally, the state and inputs of the problem are given as follows:

Where (X,Y) is the global position phi the heading of the car, v_x and v_y the longitudinal respectively the lateral velocity and omega the yaw rate. Theta is the augmented state which approximates the progress. The inputs are the duty cycle d to the drive train, the steering angle delta and the velocity along the reference path v_theta (which is an approximation of the velocities projected onto the path)

To achieve obstacle avoidance of other cars, before solving the MPCC problem grid search 1-D dynamic programming approach finds the best way to avoid the obstacles. This path is then converted into a corridor which modifies the track constraint.

Finally, to solve the MPCC problem, we approximate the nonlinear problem as a time-varying quadratic program, by linearizing and discretizing the dynamics, approximating the lag and contouring errors using a first order tyler approximation and approximating the track constraints with two linear half space aligned with the boundaries. The resulting quadratic program is then solved using hpipm, however we also offer a Yalmip, CVX, and direct QuadProg interface.

For more details see our paper Optimization‐based autonomous racing of 1:43 scale RC cars or the Arxiv version.

How to run

Before running code

  1. Install hpipm including the python interface
  2. alternatively install Yalmip or CVX, or use the quadprog interface

Run code

  1. in simulation.m change to the optimization framework you use (hpipm, Yalmip, CVX, quadprog)
  2. run simulation.m
  3. play with the tunning in getMPC_vars.m
  4. change the car model between FullSize and ORCA
  5. change the track layout between the ORCA and the RCP track


  1. If you use the RCP track the obstacle postions need to be changed by hand


Beside the 1:43 RC cars, we also implemented a full sized car model as well as two possible tracks.


You can’t perform that action at this time.