This project implements 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.
More information is only accessible by people who are already enrolled in Term 2 of CarND. If you are enrolled, see the project page for instructions and the project rubric.
- Udacity Term 2 Simulator
- cmake >= 3.5
- All OSes: click here for installation instructions
- make >= 4.1(mac, linux), 3.81(Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - [install Xcode command line tools]((https://developer.apple.com/xcode/features/)
- Windows: recommend using MinGW
- uWebSockets
- Run either
./install-mac.sh
or./install-ubuntu.sh
. - If you install from source, checkout to commit
e94b6e1
, i.e.Some function signatures have changed in v0.14.x. See this PR for more details.git clone https://github.com/uWebSockets/uWebSockets cd uWebSockets git checkout e94b6e1
- Run either
- Simulator. You can download these from the project intro page in the classroom.
Fellow students have put together a guide to Windows set-up for the project here if the environment you have set up for the Sensor Fusion projects does not work for this project. There's also an experimental patch for windows in this PR.
- Clone this repo.
- Make a build directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./pid
.
Tips for setting up your environment can be found here
The proportional control (P) tends to steer the car towards the center line of the road, aiming to the cross-track error. If you try to use this control in isolation, the car will constantly overshoot the center line, in a zig-zag pattern.
The integral control (I) helps to control systematic bias in the controllers. If used along the car will take a circular trajectory. I couldn't observe a bias in the controllers of the simulator, thus the integral controller was not added to the hyper-parameters.
The derivative control (D) smooth the proportional controller transition to the center line, thus avoiding overshooting.
The parameters were chosen manually, the tuning strategy below:
First I decided to tune the proportional controller since this control tends to overshoot the center line, I tried to pick a value where the oscillation amplitude was small.
Secondly, I tuned the derivative control, since this smooth the proportional control tendency to overshoot.
Third, noticed was not necessary to tune the integral controller, since couldn't observe any bias in the simulator controllers.
Finally, the parameters I chose were:
Kp = 0.25
Ki = 0
Kd = 4
Here's a link to my video result