Fix PIDController with Continous and no Input Range set. (#883)

This commit is contained in:
sciencewhiz
2018-01-11 21:06:25 -08:00
committed by Peter Johnson
parent 02b6615042
commit 5513888457
2 changed files with 11 additions and 8 deletions

View File

@@ -367,8 +367,8 @@ double PIDController::Get() const {
/**
* Set the PID controller to consider the input to be continuous,
*
* Rather then using the max and min in as constraints, it considers them to
* be the same point and automatically calculates the shortest route to
* Rather then using the max and min input range as constraints, it considers
* them to be the same point and automatically calculates the shortest route to
* the setpoint.
*
* @param continuous true turns on continuous, false turns off continuous
@@ -652,7 +652,7 @@ void PIDController::InitSendable(SendableBuilder& builder) {
* @return Error for continuous inputs.
*/
double PIDController::GetContinuousError(double error) const {
if (m_continuous) {
if (m_continuous && m_inputRange != 0) {
error = std::fmod(error, m_inputRange);
if (std::fabs(error) > m_inputRange / 2) {
if (error > 0) {