Self-Driving Car Engineer Nanodegree Program
- Rewrite python code from classroom to C++.:)
Init()
initialize P, I, D parameters (PID.cpp line 14-25)UpdateError()
, based on PID error calculation formula, get error for each parameters(PID.cpp line 27-35)GetSteerValue()
, output steer values (PID.cpp line 46-58)
- Manual PID parameters turning
- Adjust values by modify P, all others to 0; then P,I; then PID.
- it looks like P= .2, I = 1e-4, D = 3.0 let the car finish the full lap
- Using Twiddle Algorithm to Tune PID Paramters
- I imitated the python code algorithm and rewrite it in C++
- Added a few conditions to make it better works in the simulation enviroment
- if cte > 5 , which means the car is out of lane, should rerun simulation
- if time steps (no of h messages) > 8000 ( about one lap), restart simulation for another iteration
- However, it seems my implementation doesn't work well. first of all, it takes much longer time to run more iterations in simulator.
- Besides, PID values are not moving in the right directions and stay at a range then do not change anymore.
- Due to limited time, I am not be able to figure out the reason and will revisit this after finishing the final project.
Below is a short GIF shows the animation after using manual tuned PID parameters.
Below is a short GIF shows the animation after using twiddle for 14 iterations(Failed).
Describe the effect each of the P, I, D components had in my implementation.
- P (proportional) tries to stter car to the center to minimize cte. However, it easily make the car overshot center of lane and could run out of lane.
- I(Intergral) treis to reduce the bias of car control system (like steering drift) accumulated over time. In the simulator, it seems there is no bias.
- D(Differential) helps reduce the effect of overshoot created by P, so the car's steering will not oscillate much when only P is added.
- 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
.
Tips for setting up your environment can be found here