This project is to use PID controllers to control the steering angle and the throttle for driving a car in a game simulator. The simulator provides cross-track error (CTE) via websocket. The PID (proportional-integral-differential) controllers give steering and throttle commands to drive the car reliably around the simulator track.
Description of PID values in PID control
P (proportional) accounts for present values of the error. For example, if the error is large and positive, the control output will also be large and positive.
I (integral) accounts for all past values of the error. For example, if the current output is not sufficiently strong, the integral of the error will accumulate over time, and the controller will respond by applying a stronger action.
D (differential) accounts for possible future trends of the error, based on its current rate of change.
PID parameters used for steering angles:
PID parameters used for throttle:
How to tune the parameters
The parameters are tuned manually with the order of: p, d, i. The d and i are first setted to be zeros, and 0.2 is used for the p value. I adjust the p value up and down till it could drive around the first corner and hard to imporve more. Then I keep the p value as it is, and increase the d value. Use the same approach for d value and i value.
In order to automatically fine tune the parameters, an optimization algorithm twiddle can be used, which is exampled as follows:
Demo 2: speedy drive, which is targeting for dirivng the car as fast as possible, but as a side effect, the car starts to swing. In order to make the car drive fast as well as steady, further joint parameter tuning for both PID controllers need to be carried out.