diff --git a/libraries/PID/PID.cpp b/libraries/PID/PID.cpp index 4fe529256f..330e950049 100644 --- a/libraries/PID/PID.cpp +++ b/libraries/PID/PID.cpp @@ -21,7 +21,7 @@ PID::get_pid(long error, long dt, float scaler) // discrete low pass filter, cuts out the // high frequency noise that can drive the controller crazy derivative = _last_derivative + - ((delta_time / (RC + delta_time)) * (derivative - _last_derivative)); + ((delta_time / (_RC + delta_time)) * (derivative - _last_derivative)); // update state _last_error = error; diff --git a/libraries/PID/PID.h b/libraries/PID/PID.h index 8ccf949885..82298c9d03 100644 --- a/libraries/PID/PID.h +++ b/libraries/PID/PID.h @@ -67,14 +67,15 @@ public: /// @name parameter accessors //@{ - float kP() { return _kp; } - float &kP() { return _kp; } - float kI() { return _ki; } - float &kI() { return _kd; } - float kD() { return _kd; } - float &kD() { return _kd; } - float imax() { return _imax; } - float &imax() { return _imax; } + float kP() { return _kp; } + float kI() { return _ki; } + float kD() { return _kd; } + float imax() { return _imax; } + + void kP(float v) { _kp = v; } + void kI(float v) { _ki = v; } + void kD(float v) { _kd = v; } + void imax(float v) { _imax = v; } //@} private: