Closed ssejrog closed 4 months ago
Fixing this removes a (probably only used by me) strange behavior where you can set target
and compute the PID with a current
of 0
. I do this in some of my code that's EZ-Template based, here and here.
To keep this functionality, a new function was added to PID called .compute_error()
. You pass error
and current
into this, and it'll compute PID ignoring target
. current
is only used for derivative calculation.
Expected Behavior
PID targets can be changed and the robot will switch to following the new target.
Actual Behavior
The robot follows a new target, but 1 iteration after the target has changed there is derivative kick.
This can be solved by getting the derivative of the input sensor value instead of error.