mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Fix PIDController with Continous and no Input Range set. (#883)
This commit is contained in:
committed by
Peter Johnson
parent
02b6615042
commit
5513888457
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user