Model Predictive Controller (Udacity’s Autonomous Car Engineer Nanodegree, term 2, project 5)

In this project the task is to program a Model Predictive Controller which is able to drive the car around the track, with the difficulty of having a latency of about 100ms to simulate delays in the network and the time until the actuators engage.

The inputs to the MPC are:

  • Waypoints, approximated by a third degree polynomial.
  • Car status: position, orientation, speed, and current state of the actuators

MPC uses a model to predict future states based on actuators input and tries to find a series of actuators inputs which minimizes a cost function. The model can be kinematic or dynamic, but I used a simple kinematic model for this project. The selection of MPC parameters and cost function are key to having a capable and stable controller. The cost function I defined is based on factors such as:

  • Reduce position and orientation error w.r.t. the waypoints trajectory
  • Keep a reference speed
  • Reduce actuator use
  • Reduce actuator derivatives, i.e. no sudden changes

The optimizer (a C++ library) is fed the discretized kinematic equations, constraints and the cost function. It is important to balance the number of steps and the time step for good and timely performance.

I tuned the cost function for the MPC to be able to drive up to 80mph. Video performance below. Yellow line in the video are waypoints, green line is the solution from the MPC.

It is nice to explore another “simple” controller which can safely drive the car (in the simulator at least!) but it also showcases the need of self-driving cars to integrate several systems into one coordinated unit. This method is dependant on dynamic information (Waypoints) and it disregards most of its environment. I hope part 3 of the self-driving car nanodegree will feature some kind of “integration” scenario where different systems have to be combined to give the car some autonomy, rather than mere automation.

The controller driving ~65mph:

The controller driving ~80mph:

The report I submitted:

The code for my project is hosted in github:

Leave a Reply

Your email address will not be published. Required fields are marked *