/ModelPredictiveController

Udacity Self Driving Car Engineer Model Predictive Controls Project

Primary LanguageC++MIT LicenseMIT

CarND-Controls-MPC

Self-Driving Car Engineer Nanodegree Program


Dependencies

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./mpc.

Build with Docker-Compose

The docker-compose can run the project into a container and exposes the port required by the simulator to run.

  1. Clone this repo.
  2. Build image: docker-compose build
  3. Run Container: docker-compose up
  4. On code changes repeat steps 2 and 3.

Tips

  1. The MPC is recommended to be tested on examples to see if implementation behaves as desired. One possible example is the vehicle offset of a straight line (reference). If the MPC implementation is correct, it tracks the reference line after some timesteps(not too many).
  2. The lake_track_waypoints.csv file has waypoints of the lake track. This could fit polynomials and points and see of how well your model tracks curve. NOTE: This file might be not completely in sync with the simulator so your solution should NOT depend on it.
  3. For visualization this C++ matplotlib wrapper could be helpful.)
  4. Tips for setting up your environment are available here
  5. VM Latency: Some students have reported differences in behavior using VM's ostensibly a result of latency. Please let us know if issues arise as a result of a VM environment.

Hints!

  • You don't have to follow this directory structure, but if you do, your work will span all of the .cpp files here. Keep an eye out for TODOs.

Description of Model

THe model was taken from the Udacity Course material and is shown in the image below:

alt text

Timestep Length and Elapsed Duration

I choose to use a timestep length of 8 and an elapsed duration of 100 ms. I was able to get better performance with a timestep length of 18 and an elapsed duration of 50 ms, but I wanted to get the model working at an elapsed duration of 100 ms I got a timestep length of 8 by trying longer lengths and finding issues at higher speeds and around curves where the model would predict too far ahead and have a crazy prediction causing an unstable controller. So through iterations of smaller timestep lengths I ended up with a value of 8.

Additional Comments

I was able to tune the controller to handle the 100 ms latency. I copied the cost function from the MPC quiz, but added in a penalty for steering at low cross track error this was intended to be able to have a higher cross track error penalty without hunting around the line.