Fix PIDController::in_deadband() to give correct result when error is zero (#5078)

This commit is contained in:
Lewis Baker 2023-07-13 06:27:45 +09:30 committed by GitHub
parent a539197bc4
commit 9344d85414
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ float PIDController::update(float setpoint, float process_value) {
bool PIDController::in_deadband() { bool PIDController::in_deadband() {
// return (fabs(error) < deadband_threshold); // return (fabs(error) < deadband_threshold);
float err = -error_; float err = -error_;
return ((err > 0 && err < threshold_high_) || (err < 0 && err > threshold_low_)); return (threshold_low_ < err && err < threshold_high_);
} }
void PIDController::calculate_proportional_term_() { void PIDController::calculate_proportional_term_() {