In controls 1-22 there is a code outline for PID controller, but if you follow the outline it will not work! Look at this section:
self.error_sum_ += error * delta_time
# Update the past error
self.last_error_ = error
# Find delta_error
delta_error = error - self.last_error_
# Update the past error
self.last_error_ = error```
Firstly notice there is an instruction to set self.last_error_ twice, once before and once after delta_error. The first one _must_ be removed. In the current code `delta_error` will always be 0 and hence the derivative term has no effect.
I removed this one line from my code and now everything works perfectly
In controls 1-22 there is a code outline for PID controller, but if you follow the outline it will not work! Look at this section: