mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
rc_update: throttle trim centering fix for reverse channel
The entire logic did not work for the case when the throttle channel is reversed because then QGC sets trim = max for that channel and the result is only half the throttle range.
This commit is contained in:
@@ -215,8 +215,12 @@ void RCUpdate::parameters_updated()
|
||||
const uint16_t throttle_min = _parameters.min[throttle_channel];
|
||||
const uint16_t throttle_trim = _parameters.trim[throttle_channel];
|
||||
const uint16_t throttle_max = _parameters.max[throttle_channel];
|
||||
const bool throttle_rev = _parameters.rev[throttle_channel];
|
||||
|
||||
if (throttle_min == throttle_trim) {
|
||||
const bool normal_case = !throttle_rev && (throttle_trim == throttle_min);
|
||||
const bool reversed_case = throttle_rev && (throttle_trim == throttle_max);
|
||||
|
||||
if (normal_case || reversed_case) {
|
||||
const uint16_t new_throttle_trim = (throttle_min + throttle_max) / 2;
|
||||
_parameters.trim[throttle_channel] = new_throttle_trim;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user