Self-Driving Car Engineer Nanodegree Program
I tried a few methods to tune this controller. My first attempt was to use the python simulator with the 'twiddle' algorithm to optimize the parameters. The parameters that were generated from the lesson created a system that overcorrected into a state of instability. Parameters like driving speed and max steering angle could be adjusted to better replicate the conditions in the simulator. I realized that, while twiddle reduces total error, the solution is likely not ideal as a passenger. It results in steep, underdamped oscillations that would be highly uncomfortable and unnecessary in most scenarios. From the previous trajectory generation project, it is likely that this path would void the curvature and jerk constraints. Ideally, we could set some constraints on the path during 'twiddle' to prefer overdamped paths that are smooth rather than underdamped paths that oscillate and are uncomfortable.
The other method I used to tune was simply by manual (not twiddle) trial and error. I followed steps described here that instruct to first build a stable PD controller before introducing the integral component. During this process, I found that a minimum proportional value is needed to properly steer around the corners on the track at a given speed. If this value is too small, the vehicle doesn't correct enough and drives off the outside edge of the turn. If its too large, it oscillates once it enters the turn and eventually crashes. I found reducing the speed was helpful to maintain stability around tight corners (I reduced the set speed to 0.13). Although this is not ideal in a scenario where speed is prioritized, considering comfortable driving conditions is necessary in an autonomous vehicle carrying humans, and therefore it is natural to reduce speed in sharp corners. Ideally the trajectory would reduce speed on high curvature areas automatically. Once the PD controller was smooth and strong enough to corner at the set speed, I introduced a relatively small integral coefficient to correct for constant error. Too strong of an integral component and the vehicle will oscillate, but reducing this value provided just enough pull to bring the car back to the lane center.
- 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
We've purposefully kept editor configuration files out of this repo in order to keep it as simple and environment agnostic as possible. However, we recommend using the following settings:
- indent using spaces
- set tab width to 2 spaces (keeps the matrices in source code aligned)
Please (do your best to) stick to Google's C++ style guide.
Note: regardless of the changes you make, your project must be buildable using cmake and make!
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.
- You don't have to follow this directory structure, but if you do, your work will span all of the .cpp files here. Keep an eye out for TODOs.