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 and CVX interface.
For more details see our paper Optimization‐based autonomous racing of 1:43 scale RC cars or the Arxiv version.
- Install hpipm including the python interface
- alternativly install Yalmip or CVX
- in simulation.m change to the optimization framework you use (hpipm, Yalmip, CVX)
- run simulation.m
- play with the tunning in getMPC_vars.m
- change the car model between FullSize and ORCA
- change the track layout between the ORCA and the RCP track
- 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.