mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] PIDController: Reset position and velocity error when reset() is called. (#4064)
In addition to m_prevError and m_totalError, m_positionError and m_velocityError need to be reset to 0 when reset() is called. Otherwise, the next time calculate() is called, the old values will be used as the previous error, but this is inaccurate since the caller wanted to reset the state of the PID controller.
This commit is contained in:
@@ -338,8 +338,10 @@ public class PIDController implements Sendable, AutoCloseable {
|
||||
|
||||
/** Resets the previous error and the integral term. */
|
||||
public void reset() {
|
||||
m_positionError = 0;
|
||||
m_prevError = 0;
|
||||
m_totalError = 0;
|
||||
m_velocityError = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user