Add PIDController Wrapping (#601)

This commit is contained in:
Caleb Smith
2017-11-26 00:15:33 -05:00
committed by Peter Johnson
parent c9d440f338
commit a338ee8be0
2 changed files with 16 additions and 10 deletions

View File

@@ -773,11 +773,14 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
* @return Error for continuous inputs.
*/
protected double getContinuousError(double error) {
if (m_continuous && Math.abs(error) > m_inputRange / 2) {
if (error > 0) {
return error - m_inputRange;
} else {
return error + m_inputRange;
if (m_continuous) {
error %= m_inputRange;
if (Math.abs(error) > m_inputRange / 2) {
if (error > 0) {
return error - m_inputRange;
} else {
return error + m_inputRange;
}
}
}