willhnguyen / CarND-PID-Control-Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PID Controller

Self-Driving Car Engineer Nanodegree

This project aims to implement a PID controller to set a car to drive itself around a race track.

Dependencies

Build and Run Instructions

To build the program, run the following sequence of command line instructions.

$ cd /path/to/cloned/repo
$ mkdir build
$ cd build
$ cmake ..
$ make

To see the program in action, make sure to download the Term 2 simulator, run it, and choose the third simulation option. Then, execute the program by executing the pid program in the build folder.

$ ./pid

Project Information

PID equation

The PID controller allows a car to drive itself by identifying ways to correct the car's steering. It comes in 3 parts.

P equation

The P part of the PID controller is short for proportional. This part identifies the cross-track error (abbr. CTE, def. the perpendicular distance away from the target trajectory). This term will tell the car to adjust its steering toward the opposite direction to get closer to the trajectory. Although this update works, it poses a problem once the car gets close enough that it overshoots the trajectory. Once this happens, the car will continously undesirably oscillate around the trajectory.

D equation

The D part of the PID controller is short for differential. This part identifies the change in the CTE and helps the car adjust its steering to avoid the oscillation problem.

I equation

The I part of the PID controller is short for integral. This part looks at the entire history of the car's CTE to adjust for systematic bias. One potential systematic bias is if the car's steering isn't properly aligned, causing it to drift towards a location away from the target trajectory.

Each part of the PID controller also takes a coefficient to adjust how much each part affects the vehicle's driving behavior. This will have to be tuned manually or by using an algorithm that automatically tunes it while the car is driving.

Project Implementation Details

The src/pid.cpp and src/main.cpp files were modified for this project.

The src/pid.cpp file implements the PID controller as is specified in the course.

The src/main.cpp file adds code that sets the PID controller's coefficients. It also provides code manually test different coefficients without having to compile the program with new coefficient values each time a new set of values are decided.

About


Languages

Language:C++ 99.7%Language:Shell 0.2%Language:CMake 0.1%