Skip to content

Fix PID derivative-kick issues and add integral-windup mitigation - #20

Open
SerrialError wants to merge 2 commits into
vexide:mainfrom
SerrialError:feat/pid-improvements
Open

SerrialError wants to merge 2 commits into
vexide:mainfrom
SerrialError:feat/pid-improvements

Conversation

@SerrialError

Copy link
Copy Markdown

Derivative fixes

  • Differentiate the measurement instead of the error, removing derivative kick on setpoint changes (technically doesn't really matter as motions currently only use a fixed setpoint).
  • Gets rid of the first-tick derivative spike by setting the prev_measurement to the starting measurement when the controller is initialized to set the derivative to be 0 on start

New anti-windup mitigations

  • Conditional integration freezes the integral term while the output is at max (always on).
  • Windup clamping clamps integral term to a settable max (defaulted as off)

New PidMode (Position/Velocity)

  • Changes Integral Reset to only happen in Position PID controllers as Velocity PID Controllers flip signs constantly (set to Position mode by default).

Also adds a reset() to help prevent first-tick derivative kick if a controller isn't cloned as well as assorted formatting fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant