[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:
Tommy Beadle
2022-05-06 11:44:08 -04:00
committed by GitHub
parent f20a20f3f1
commit dc6f641fd2
2 changed files with 4 additions and 0 deletions

View File

@@ -155,8 +155,10 @@ double PIDController::Calculate(double measurement, double setpoint) {
}
void PIDController::Reset() {
m_positionError = 0;
m_prevError = 0;
m_totalError = 0;
m_velocityError = 0;
}
void PIDController::InitSendable(wpi::SendableBuilder& builder) {