Self-Driving Car Engineer Nanodegree Program
The objective of this project is to implement a PID controller that can safely navigate around the driving track
We are provided the following a program inputs:
- The Cross-track error of the car
- The vehicle must drive safely around the track
The PID controller provides for a combination of 3 driving parameters and how they affect how hard (steering angle) a car steers relative to the Cross Track Error (CTE).
This component steers the car directly proportional to the cross track error. It tries to orient the car to the center of the car's trajectory. Higher values gets the car swiftly to the center of the track, while lower values slows down the orientation to the center.
cte * -tau
This component helps to offset systematic bias in the car's model that may prevent the car from directly reaching the center of the track. This bias may appear in the form of wheel alignment errors. A human driver intuitively corrects for this error by steering harder in the opposite direction of the error. For an autonomous vehicle, we offset this error with the I component that is proportional to the cumulative CTE.
sum_cte = SUMMATION(cte)
sum_cte * -tau_i
This component helps to intercept the driving trajectory by opposing the P component as the car approaches the driving trajectory. It is in the form of a differential that makes the car approach the track's center line while reducing the tendency to overshoot it.
I used a combination of manual tuning and Twiddle to achieve drivable parameters.
I trialled various P values to achieve a value capable of nudging the car towards the center. I discovered that there
is very negligible wheel alignment in the simulator there by no need for a I component. I selected a random D value.
I used this value as a starting point in my Twiddle algorithm. This can be found in the twiddle.cpp
file.
The video below shows how my parameters drive the car around the car.
- 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.
- Clone this repo.
- Make a build directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./pid
.