Self-Driving Car Engineer Nanodegree Program
This project implements a PID controller in C++ to maneuver the vehicle around the track in the simulator! Two PID controllers are to be implemented one for steering control and another for throttle control.
PID stands for Proportional-Integral-Derivative. It is a controller with three coeffients P, I and D. The effects of these coefficients are discussed below.
- It is a distance between the vehicle´s actual trajectory and the groundtruth trajectory. It is best suited to control the vehicle by steering in proportion to CTE.
- This is a term used in Robotics that tells you how much the vehicle´s steerable wheels are aligned.
- It sets the steering angle in proportion to CTE by virtue of a gain parameter called tau_p.
steering angle = -tau_p * cte
- This controller steeers the vehicle towords the trajectory but when it reaches the trajectory it overshoots.
- The following graph demonstrates the overshooting due to P controller.
- In this controller the steering angle is not just proportional to CTE by virtue of tau_p but also the temporal derivative of the CTE with a gain parameter called tau_d.
steering angle = -tau_p * cte - tau_d * diff_cte
- This helps the vehicle to not overshoot the trajectoy as the the derivative component counter steers the vehicle.
- The following graph demonstrates the behaviour of P controller and PD controller.
- Finally this controller overcomes the problem of overshooting and systematic bias by adding one more term.
steering angle = -tau_p * cte - tau_d * diff_cte - tau_i * int_cte
- This time, addition to PD controller parameters the steering angle is prportional to integral of all CTE over time.
- The following graph summerizes the P-, PD-, and PID- controllers.
Manual tunning of PID coefficients for steering and throttle values.
The vehicle drives along the trajectory with oscillations.
The vehicle follows the trajectory with relatively low oscillations.
The vehicle follows the trajectory but due to overspeeding it shakes while taking turns.
The braking while taking turns allows the vehicle to take the turns smoothly.
- Clone this repo.
- Make a build directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./pid
.
- 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.