Skip to content

da-phil/SDC-Controls-PID

Repository files navigation

Implementation of simple PID control

Dependencies

There's an experimental patch for windows in this PR

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./pid.

Tips for setting up your environment can be found here

Implementation

The implementation of the PID controller was straight forward, the function void PID::UpdateError(double cte) takes the current control error for calcuating the internal error gains and the function double PID::TotalError() returns the resulting control error value.

One instance of the PID class controls the steering, where the cross-tack-error (CTE) is being used as error value and the other PID instance controls the speed of the car by using the a target speed range between 10 and 40 mph, depending on the steering output, increasing speed at lower steering angles and decreasing for high steering angles, just like this: target_speed = 30. * (1. - abs(steer_value)) + 10.

For tuning the PID gains I started out with 0.1, 0.0005, 1.0 (P,I,D) and refined the parameters manually to 0.07, 0.002, 1.7. Good guidelines on how to tune PID parameters are:

After manually tuning the PID parameters I implemented twiddle (used in class) in order to optimize the PID parameters in respect to the RMSE over a lap on the racing course.

Even after tuning the PID parameters carefully the car drives safe but very shacky, presumably a real passenger would throw up after only one lap already! I'm already curious on how model predictive control improves this situation ;)

Releases

No releases published

Packages

No packages published

Languages