Self-Driving Car Engineer Nanodegree Program
In this project, I decide the steering angle of simulator's car steering wheel , using PID controller and Twiddle (coordinate ascent)
- mkdir build
- cd build
- cmake ..
- make
- ./pid
I was using Windows 10 and VisualStudio17
-to build this project using Bash for window :
navigate to projet
write cmd : mkdir build
then navigate to build
write cmd : cmake .. -G "Unix Makefiles" && make
write cmd : ./pid
- in class PID we fill the initial parameters Kp, Ki, Kd.
- in every step we update p & i & d Errors.
- and then calculate Total Error, it is the sum of paramters and their errors multiplied.
- now we tune the Kp, Ki, Kd parameters using these instructions
- Kp decides how fast the car will stear to correct its course, the less the faster.
- Kd decides how much the car will swing after stearing is done, the more , the dry streaing is.
- now we build the twiddle algorithm
- I'll use the same implementation in lesson
- using boolean flags, I'll decide which part will be active during the current loop
- using p array as the [kp, ki, kd] , and pd array as a helper to tune p array
- initialize kp ki kd, to the manually tuned parameters [0.12,0,3]
- initialize pd array to [1,0,15] , I decided these values after trial and error.
- I choose to twiddle every 5 steps, to auto-tune on fly without restarting simulator.
-
while twiddle is running, the car will swing, but eventually it will stop after twiddle is done.
gif animation :
-
but after twiddle is done car can take curves successfuly :
gif animation :
these images are taken from diffrent testing sessions.
gif animation :
I got only few comment , that if I can improve the PID controller will be perfect
- start with p=[0,0,0] & pd=[1,1,1]
- drive succesfuly with throttle more than 0.4
- use more steps between twiddle steps -now using 5 steps-