ferram4 / MouseAimFlight

Other
1 stars 8 forks source link

PID controller logic #1

Open camlost2 opened 6 years ago

camlost2 commented 6 years ago

Simply clamping the integral part is not enough to cure integral windup

suppose the variable rises up to the setpoint but still lower than it, the integral would stay negatively saturated. It only cancels when the variable stays higher than the setpoint for a while.

A FIFO queue is needed to store the integral values of each update

tetryds commented 6 years ago

Yes, that is known, but this was the easiest approach that still worked. The integral can add up to a certain threshold when the controls are not saturated. The idea in the future is to analyze the rate at which the error changes proportionally to how far it is from the target point, and apply the integral factor proportionally, so that it's active only as the error remains high and is not shrinking. If you have any suggestions for such implementation, please feel free to file a PR, I promise I won't take too long to check it out :)

camlost2 commented 6 years ago

My implementation using a FIFO queue, N being the length of queue

https://github.com/KSP-RO/AJE/blob/master/Source/PIDController.cs