Skip to content

ChitraChaudhari/PID-controller

Repository files navigation

CarND-Controls-PID

Self-Driving Car Engineer Nanodegree Program


Project Basics

In this project, I am using a Proportional-Integral-Derivative Controller, PID in order to drive a simulated car around a virtual track. The project involves implementing the controller primarily for the steering angle of the car as well as tuning coefficients for each PID value in order to calculate a steering angle that keeps the car on the track.

Dependencies

##Simulator. You can download these from the project intro page in the classroom.

Basic Build Instructions

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

Tips for setting up your environment can be found here

Rubric points

Compile

Your code should compile.

The code compiles without any errors.No modification done in given setup

Implementation

The PID procedure follows what was taught in the lessons.

Yes,PID implementation is done in the PID.cpp file. The UpdateError() method calculates proportional(p_error), integral(i_error) and derivative(d_error) errors and the TotalError() calculates the total error using the appropriate coefficients(Kp, Ki, Kd).

Reflection

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

The actual implementation of code for a basic PID controller is fairly straightforward. My implementation closely follows what was taught in the lessons.

The 'P' proportional portion of the controller tries to steer the car toward the center line against the cross-track error, cte. If used along, the car overshoots the central line very easily and go out of the road very quickly. However, if the coefficient is set too high for P, the car will oscillate a ton, as the car will constantly overcorrect and overshoot the middle. If the coefficient is too low, the car may react too slowly to curves when the car gets off-center with a higher CTE.

The "I" for integral sums up all previous cte's up to that point to eliminate a possible bias on the controlled system.If used along, it makes the car to go in circles.

The "D" for derivate is the change in CTE from one value to the next. IT helps to counteract the proportional trend to overshoot the center line by smoothing the approach to it.Too high of a coefficient leads to almost constant steering angle changes of large degrees, where although the car will be well-centered it can hardly move. Too low of a D coefficient will lead to the oscillations being too high with more overshooting.

Describe how the final hyperparameters were chosen.

The parameters were chosen manually by try and error. I started by using zero as parameters to see if car can drive straight. Then added the Kp and the car start going on following the road but it starts overshooting go out of it. Then added the Kd to try to overcome the overshooting. Once those values were found i tried adjusting them in conjuction with each other. After the car drove the track without going out of it, the parameters increased to minimize the average cross-track error on a single track lap. The final parameters where [P: 0.1, I: 0.005, D: 1.6]. I also tried implementing Twiddle algorithm, which helps finding the optimal parameters. I ended up not using it as the resulting parameters tended to vary every time I ran it, and didn't find improvement in driving behavior compared to using the manually tuned parameters.

Simulation

The vehicle must successfully drive a lap around the track.

Here is a link to short video with the final parameters https://youtu.be/DSCRHmfZaao

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages