fixed elevator wobbling at low airspeed.

Removed not applicable if conditions.
This commit is contained in:
fludwig
2015-03-02 18:15:11 +01:00
committed by Friedemann Ludwig
parent 9574c6dd2a
commit 32012e8aac
4 changed files with 20 additions and 25 deletions
@@ -49,6 +49,7 @@
#include "ecl_controller.h"
#include <stdio.h>
#include <mathlib/mathlib.h>
ECL_Controller::ECL_Controller(const char *name) :
_last_run(0),
@@ -126,3 +127,14 @@ float ECL_Controller::get_desired_bodyrate()
{
return _bodyrate_setpoint;
}
float ECL_Controller::constrain_airspeed(float airspeed, float minspeed, float maxspeed) {
float airspeed_result = airspeed;
if (!isfinite(airspeed)) {
/* airspeed is NaN, +- INF or not available, pick center of band */
airspeed = 0.5f * (minspeed + maxspeed);
} else if (airspeed < minspeed) {
airspeed = minspeed;
}
return airspeed_result;
}