mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-16 08:20:34 +08:00
rc_update: improve manual_switches simple protections
- require back to back matching switch decode to match within 1 second - clear any previous manual switches if RC is unstable
This commit is contained in:
@@ -542,6 +542,12 @@ void RCUpdate::Run()
|
||||
}
|
||||
|
||||
_last_timestamp_signal = input_rc.timestamp_last_signal;
|
||||
|
||||
} else {
|
||||
// RC input unstable or lost, clear any previous manual_switches
|
||||
if (_manual_switches_last_publish.timestamp_sample != 0) {
|
||||
_manual_switches_last_publish = {};
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(_rc_values_previous, input_rc.values, sizeof(input_rc.values[0]) * channel_count_limited);
|
||||
@@ -643,8 +649,10 @@ void RCUpdate::UpdateManualSwitches(const hrt_abstime ×tamp_sample)
|
||||
switches.video_switch = get_rc_sw2pos_position(rc_channels_s::FUNCTION_AUX_4, 0.5f);
|
||||
#endif
|
||||
|
||||
// last 2 switch updates identical (simple protection from bad RC data)
|
||||
if (switches == _manual_switches_previous) {
|
||||
// last 2 switch updates identical within 1 second (simple protection from bad RC data)
|
||||
if ((switches == _manual_switches_previous)
|
||||
&& (switches.timestamp_sample < _manual_switches_previous.timestamp_sample + 1_s)) {
|
||||
|
||||
const bool switches_changed = (switches != _manual_switches_last_publish);
|
||||
|
||||
// publish immediately on change or at ~1 Hz
|
||||
|
||||
Reference in New Issue
Block a user