No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
results
src
.gitignore
CMakeLists.txt
README.md
cmakepatch.txt
final_result.gif
install-mac.sh
install-ubuntu.sh
visualize.py

README.md

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.

Basic Plot Visualization Instructions

  1. Edit the column name in visualize.py
  2. run python visualize.py <csvfilename>

Summary

First, I implemented the PID error calculation and its update mechanism in PID.cpp. By printing out the CTE and the error value or the steering value, I can see and follow the impact of parameter changes.

In order to get the optimum parameter, I've decided to tune the hyperparameters manually.

For the first experiment, I tuned the P parameter. After several experiments, I found out that with 0.05 as the P parameter, the vehicle can pass the first left curve. The bellow figures shows the comparison between 0.1, 0.05, and 0.2. The left graph plots the CTE values and the right graph plots the steering values in respect to the time.

image1

The figure above shows how the P-parameter itself isn't enough to reach the stability. We see that the vehicle is getting unstable (see the increasing oscillation of the CTE and the total error values).

Afterwards, I started to vary the D parameter with values 1, 2, and 0.5. 0.5 as the D value causes that the current control will react half of the current error difference. It means that the vehicle cannot response a high error difference that can be caused by curves. On the other hand, if KD is equal to 2, then the vehicle is over-responsive to a small error change. Thus, I chose KP=0.05 and KD=1 as the reference to tune the I parameter.

image2

The below figures shows several experiments using difference I parameters. KI=0.001 (see green and blue lines) generates a good results compared to 0.0001 (orange line).

image3

With the above results, the vehicle still drives out side the road and yellow line at the curves (CTE is larger than 3.0). Thus, I try to assign a zero value for the throttle in order to slow down the vehicle if the current CTE exceeds a threshold value. Next, I need to re-tune the parameters. I found out that KP = 0.12, KD=2.1 and KI[0.002:0.005] keep the vehicle on the road.

image4

These two figures show some refinement of the parameter tuning and limit the steering value between range -1 and 1. We can observe the steering values of these figures, that by increasing the I-parameter , we can control the vehicle to be more stable.

image5 image6

As the final result, I choose KP=0.12, KI=0.009, and KD=1.8. From all my experiments, these hyperparameters give the lowest total CTE in one lap. The last figures shows that even with the constant throttle value of 0.3 (no break), the vehicle can deal with the circuit curves without leaving the road (CTE < 3.0).

image7

Please see the video of my final result below. Notice, that no rear break light can be observed in the video, since I assign throttle = 0 to reduce the speed.

gif1