RC_Channel: constrain norm_input() to -1 to 1

if RC is not properly calibrated we could get a value beyond 1, which
could cause some flight modes to exceed the roll/pitch limits of the
aircraft
This commit is contained in:
Andrew Tridgell 2014-03-15 20:43:13 +11:00
parent eb7db82210
commit 68462025ba

View File

@ -333,10 +333,12 @@ RC_Channel::range_to_pwm()
float
RC_Channel::norm_input()
{
float ret;
if(radio_in < radio_trim)
return _reverse * (float)(radio_in - radio_trim) / (float)(radio_trim - radio_min);
ret = _reverse * (float)(radio_in - radio_trim) / (float)(radio_trim - radio_min);
else
return _reverse * (float)(radio_in - radio_trim) / (float)(radio_max - radio_trim);
ret = _reverse * (float)(radio_in - radio_trim) / (float)(radio_max - radio_trim);
return constrain_float(ret, -1.0f, 1.0f);
}
/*