Self-Driving Car Engineer Nanodegree Program
- 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.
git clone https://github.com/uWebSockets/uWebSockets
cd uWebSockets
git checkout e94b6e1
Some function signatures have changed in v0.14.x. See this PR for more details.
- Simulator. You can download these from the project intro page in the classroom.
There's 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
.
Rubric points
The code compiles without errors with cmake and make as described in Basic Build Instructions.
The base PID algorithm follows what's presented in the lessons. The only difference is adding a limiter to the integral part to prevent the controller windup.
P
part effectively is sufficient to have the system reacting on the error and compensating for it. But the maximum result you can achieve is either understeering or oscillation.
D
part helps to compensate for oversteering or for a sudden change of the error. Especially it is helpful on high speed when the error is growing quickly and suddenly, e.g., on sharp turns.
I
part is normally required to compensate for the static state error. But in the case of long sharp turns it also helps to stay on track because the rate of the error change is close to zero, so D
part is becoming inefficient.
There are two controllers that work together - the velocity and steering controllers. Tuning the velocity controller was the easiest task. I started with proportional part only reaching a satisfactory speed control with a static offset. Then I moved on to the differential part to reach a satisfactory behaviour in particular for braking. The last step was adding the integral part to compensate for the static offset.
The steering controller was tricky to tune especially for high speed. The submitted code works well for velocities in range 60 - 70 MPH and is sharply tuned. For lower velocities a different set of parameters is prefered to achieve a smooth motion. The steering controller hyperparameters were selected by hand following a simple approach:
- Tune the
P
part to have a satisfactory steering with a slight oscillation. Reduce theP
part slightly after finding theP
paramter around the oscillation point. - Increase the
D
part till the car is capable of dealing with sharp turns without leaving the road. - Add integral part to smoothen the steering and to be able to handle long curves. Integral part was in this case the most challenging part which required finding not only the
I
coefficient but also a proper integral limit. Having a large integral limit with a lowI
coefficient would introduce oscillations. Reducing the limit but increasing theI
coefficient helped to achive the desirable result.
Unfortunately simulator recording didn't work for me, so I had to perform a screen recording which introduced some lags into the performance. The video can be found here.