Skip to content

Model Predictive Controller implemented to drive a car on a simulator.

Notifications You must be signed in to change notification settings

baumanab/CarND-MPC-Project-1

 
 

Repository files navigation

CarND-Controls-MPC

Self-Driving Car Engineer Nanodegree Program


The Model

  1. General assertion
    The coordinates of the car provided by the simulator are in global coordinates. For more simplicity, I transformed theses coordinates with respect to the car (and not to the map).
    The state vector of the vehicle is given as follow:
  • x - Vehicle position in forward direction
  • y - Vehicle position in lateral direction
  • psi - Angle of the vehicle (yaw angle)
  • v - Vehicle's speed

And the actuators are:

  • delta - Steering angle (radians)
  • a - acceleration
  1. Update step
    The update step can be found here in my code. This update step is used to compute the next state of the car, regarding the current state. Lf is the distance between the front of vehicle and its center of gravity. This constant was kindly given by Udacity.

Polynomial Fitting and MPC Preprocessing

I used a third degree Polynomial to compute the trajectory od the car. A second degree polynomial would have led to underfitting, whereas more than a third degree polynomial would not have allow me to generalize the data enough (overfitting).

Timestep Length and Elapsed Duration (N & dt)

Timestep Length and Frequency were chosen by trial and error method. After some trials, I found that 10 timesteps (N) at a frequency of 15 (dt) provided the best results, for a speed of 30 mph. However, the more speed we would like to achieve, the more we want to "see further", hence it becomes necessary to increase N.

Model Predictive Control with Latency

The Model Predictive Control handles a 100 millisecond latency which simulate latency between sensors and processing.

Dependencies

  • cmake >= 3.5
  • All OSes: click here for installation instructions
  • make >= 4.1
  • gcc/g++ >= 5.4
  • uWebSockets == 0.14, but the master branch will probably work just fine
    • Follow the instructions in the uWebSockets README to get setup for your platform. You can download the zip of the appropriate version from the releases page. Here's a link to the v0.14 zip.
    • If you have MacOS and have Homebrew installed you can just run the ./install-mac.sh script to install this.
  • Ipopt
    • Mac: brew install ipopt --with-openblas
    • Linux
      • You will need a version of Ipopt 3.12.1 or higher. The version available through apt-get is 3.11.x. If you can get that version to work great but if not there's a script install_ipopt.sh that will install Ipopt. You just need to download the source from here.
      • Then call install_ipopt.sh with the source directory as the first argument, ex: bash install_ipopt.sh Ipopt-3.12.1.
    • Windows: TODO. If you can use the Linux subsystem and follow the Linux instructions.
  • CppAD
    • Mac: brew install cppad
    • Linux sudo apt-get install cppad or equivalent.
    • Windows: TODO. If you can use the Linux subsystem and follow the Linux instructions.
  • Eigen. This is already part of the repo so you shouldn't have to worry about it.
  • Simulator. You can download these from the releases tab.

Basic Build Instructions

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

About

Model Predictive Controller implemented to drive a car on a simulator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 83.2%
  • Fortran 11.5%
  • C 2.0%
  • CMake 1.8%
  • Cuda 1.1%
  • Shell 0.2%
  • Other 0.2%