CarND-Controls-PID

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: ./pid.

Rubric Points

Your code should compile.

It does! See 'Basic Build Instructions' above.

Note: Twiddle.cpp file was added to CMakeLists.txt.

The PID procedure follows what was taught in the lessons.

PID.cpp contains the PID controller implementation. PID::TotalError() is where I calculate total error using P, I, and D gains and errors. PID::AccumulatedSquaredError() accumulates the squared error during the simulation, I use it during PID parameters tuning. The tuning happens in Twiddle.cpp - the instance of this class stores info about which parameter (P, I, or D) is being currently optimized. Twiddle::Iterate() increases/decreases the value of the current parameter.

Describe the effect each of the P, I, D components had in your implementation.

The best way to describe the components is to observe the extreme points on this video:

Video

  • P gain is too big - oversteering.
  • P gain is too small - understeering.
  • I gain is too big - little effect due absence of persistent errors - slight oversteering.
  • I gain is too small - no effect in our case since we don't have persistent errors.
  • D gain is too big - jerky steering.
  • D gain is too small - cannot compensate P oversteering, oscillations last longer.

Describe how the final hyperparameters were chosen.

Final parameters (P = 0.0837465, I = 2.0899e-06, D = 1.44656) were chosen after running twiddle for many iterations (I've lost the number of iterations, it had been running for about an hour). Each iteration runs 2000 simulation steps (~ 20 secs of simulation), after that the simulation resets to initial state and next iteration of twiddle occurs. I stopped the optimization process after decided current parameters are good enough.

The vehicle must successfully drive a lap around the track.

Here's the video:

Video