mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-21 15:23:57 -04:00
RC_Channel: prevent floating exception on bad MIN/MAX/TRIM values
This commit is contained in:
parent
ffe1561f31
commit
1b1bc9f3b1
@ -428,10 +428,16 @@ RC_Channel::norm_output()
|
||||
{
|
||||
int16_t mid = (radio_max + radio_min) / 2;
|
||||
float ret;
|
||||
if(radio_out < mid)
|
||||
if (mid <= radio_min) {
|
||||
return 0;
|
||||
}
|
||||
if (radio_out < mid) {
|
||||
ret = (float)(radio_out - mid) / (float)(mid - radio_min);
|
||||
else
|
||||
} else if (radio_out > mid) {
|
||||
ret = (float)(radio_out - mid) / (float)(radio_max - mid);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
if (_reverse == -1) {
|
||||
ret = -ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user