mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add PIDController Wrapping (#601)
This commit is contained in:
committed by
Peter Johnson
parent
c9d440f338
commit
a338ee8be0
@@ -640,11 +640,14 @@ void PIDController::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
|
||||
* @return Error for continuous inputs.
|
||||
*/
|
||||
double PIDController::GetContinuousError(double error) const {
|
||||
if (m_continuous && std::fabs(error) > m_inputRange / 2) {
|
||||
if (error > 0) {
|
||||
return error - m_inputRange;
|
||||
} else {
|
||||
return error + m_inputRange;
|
||||
if (m_continuous) {
|
||||
error = std::fmod(error, m_inputRange);
|
||||
if (std::fabs(error) > m_inputRange / 2) {
|
||||
if (error > 0) {
|
||||
return error - m_inputRange;
|
||||
} else {
|
||||
return error + m_inputRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user