AC_PID - added more paranoid checking that imax is positive in constructor, operator() and load_gains methods

This commit is contained in:
rmackay9 2012-03-20 11:51:15 +09:00
parent aeb010b6e9
commit f8ad719825
2 changed files with 3 additions and 2 deletions

View File

@ -120,6 +120,7 @@ AC_PID::load_gains()
_ki.load(); _ki.load();
_kd.load(); _kd.load();
_imax.load(); _imax.load();
_imax = abs(_imax);
} }
void void

View File

@ -33,7 +33,7 @@ public:
_kp (initial_p), _kp (initial_p),
_ki (initial_i), _ki (initial_i),
_kd (initial_d), _kd (initial_d),
_imax(initial_imax) _imax(abs(initial_imax))
{ {
// no need for explicit load, assuming that the main code uses AP_Param::load_all. // no need for explicit load, assuming that the main code uses AP_Param::load_all.
} }
@ -78,7 +78,7 @@ public:
const float i, const float i,
const float d, const float d,
const int16_t imaxval) { const int16_t imaxval) {
_kp = p; _ki = i; _kd = d; _imax = imaxval; _kp = p; _ki = i; _kd = d; _imax = abs(imaxval);
} }
float kP() const { return _kp.get(); } float kP() const { return _kp.get(); }