From d8a0ce69338333b0ff6afb989c9e72e0d83adbf6 Mon Sep 17 00:00:00 2001 From: jasonshort Date: Wed, 26 Oct 2011 16:48:50 +0000 Subject: [PATCH] Just in case the Min and Max functions are not playing nice with AP_Var --- libraries/APM_PI/APM_PI.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/APM_PI/APM_PI.cpp b/libraries/APM_PI/APM_PI.cpp index 6fd710a32a..c07b55210f 100644 --- a/libraries/APM_PI/APM_PI.cpp +++ b/libraries/APM_PI/APM_PI.cpp @@ -11,8 +11,12 @@ long APM_PI::get_pi(int32_t error, float dt) { _integrator += ((float)error * _ki) * dt; - _integrator = min(_integrator, (float)_imax); - _integrator = max(_integrator, (float)-_imax); + +if (_integrator < -_imax) { + _integrator = -_imax; + } else if (_integrator > _imax) { + _integrator = _imax; + } return (float)error * _kp + _integrator; }