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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user