mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 07:28:29 -04:00
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:
parent
eb7db82210
commit
68462025ba
@ -333,10 +333,12 @@ RC_Channel::range_to_pwm()
|
|||||||
float
|
float
|
||||||
RC_Channel::norm_input()
|
RC_Channel::norm_input()
|
||||||
{
|
{
|
||||||
|
float ret;
|
||||||
if(radio_in < radio_trim)
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user