/CarND-PID-Control-Project

Determining the steering angle of an autonomous vehicle using the concepts of PID controllers.

Primary LanguageC++

PID controller


In this project I have tried to use my knowledge of Control Systems to implement a PID controller in C++ to maneuver the vehicle around the track!

The simulator will provide you the cross track error (CTE) and the velocity (mph) in order to compute the appropriate steering angle.

Output

Final results with the implementation

Parameter Selection

The error values for the P, I and D were chosen as follows:

p_error - chosen to be a very large value assuming the car starts far from the intended path

i_error - assume that the total sum of errors initially is extremely small as the car is yet to start

d_error - assume that the initial difference is small as the car is yet to start

Initial P (Kp) - 0.150 - This parameter make the car move toward the CTE, by multiplying the CTE by P value. The true value is never really achieved. It merely oscillates around it. I started with a value of 0.2 as given in the quiz. I then tweaked the value by increasing it a bit and then decreasing it. Finally I stopped in 0.15 as there was not much difference in the driving behavior.

Initial I (Ki) - 0.001 - This parameter compensates for the systematic bias, like a faulty alignment of the steering wheel. It will accumulate the values of the errors and over time correct the car. I started with a value of 0.004 as given in the quiz. I then increased it to 0.01 and found that the car's oscillations increased. Therefor, I started decreasing it gradually and found that 0.001 worked just fine.

Initial D (Kd) - 2.5 - This parameter is for steering the car back to the course. It becomes smaller as the car drives towards the CTE. This avoids the over-shooting caused by the P controller alone. I started with a value of 3.0 as given in the quiz. I increased it to 3.5 and found that the result was not improving. I therefore experimented with decreasing it a bit and finally settled on 2.5.

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.

Code Style

Google's C++ style guide.