mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-03 23:10:46 +08:00
feat(manual_control): replace stick override threshold with double-flick gesture (#27041)
* feat(manual_control): trigger RC override on stick velocity COM_RC_STICK_OV is now a velocity threshold (1/s) instead of a deflection percentage. Default 3.0, range [1.0, 10.0]. A stick held statically cannot trigger override. * docs(manual_control): update COM_RC_STICK_OV description for velocity-based override * feat(manual_control): gate RC override with sign-consistency check * fix(ManualControl): lower threshold and filter constant for RC override, add tests for MovingDiff * refactor(commander): merge RC override params into COM_RC_OVR_SPEED Replace the COM_RC_OVERRIDE bitmask + COM_RC_STICK_OV threshold with a single float COM_RC_OVR_SPEED (stick override velocity, 0 = disabled). Override now applies uniformly in auto and offboard modes. - ManualControl: rename param, treat 0 as disabled (FLT_EPSILON guard) - Commander: drop the per-mode bitmask gate and the RcOverrideBits enum - param_translation: migrate COM_RC_OVERRIDE on import (enabled -> 1.0, disabled -> 0.0) and drop the unit-incompatible COM_RC_STICK_OV value - docs: collapse the two params into one across the mode pages * fix(manual_override): Move configuration to manual_control module with MAN_OVERRIDE_SPD parameter and a negative value disabling the feature. All other logic stays in Commander. * docs(releases): add release note for RC override rework (MAN_OVERRIDE_SPD) --------- Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
1 parent
3b9a5a6ada
commit
b8c5f66af0
23 files changed
+182
-121
No files matched your search
@@ -3121,38 +3121,22 @@ void Commander::manualControlCheck()
|
||||
_last_manual_throttle = manual_control_setpoint.throttle;
|
||||
|
||||
if (isArmed()) {
|
||||
// Abort autonomous mode and switch to position mode if sticks are moved significantly
|
||||
// but only if actually in air.
|
||||
if (manual_control_setpoint.sticks_moving
|
||||
&& !_vehicle_control_mode.flag_control_manual_enabled
|
||||
&& (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING)
|
||||
) {
|
||||
bool override_enabled = false;
|
||||
// Hand control back to the pilot when they override with the sticks (see MAN_OVERRIDE_SPD).
|
||||
// Only applies to multicopters (incl. VTOLs in MC mode) in auto/offboard modes.
|
||||
const bool rotary_wing = (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
const bool overridable_mode = _vehicle_control_mode.flag_control_auto_enabled || _vehicle_control_mode.flag_control_offboard_enabled;
|
||||
|
||||
if (_vehicle_control_mode.flag_control_auto_enabled) {
|
||||
if (_param_com_rc_override.get() & static_cast<int32_t>(RcOverrideBits::AUTO_MODE_BIT)) {
|
||||
override_enabled = true;
|
||||
if (manual_control_setpoint.sticks_moving && rotary_wing && overridable_mode) {
|
||||
// If no failsafe is active, directly change the mode, otherwise pass the request to the failsafe state machine
|
||||
if (_failsafe.selectedAction() <= FailsafeBase::Action::Warn) {
|
||||
if (_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_POSCTL, ModeChangeSource::User, true)) {
|
||||
tune_positive(true);
|
||||
mavlink_log_info(&_mavlink_log_pub, "Pilot took over using sticks\t");
|
||||
events::send(events::ID("commander_rc_override"), events::Log::Info, "Pilot took over using sticks");
|
||||
}
|
||||
}
|
||||
|
||||
if (_vehicle_control_mode.flag_control_offboard_enabled) {
|
||||
if (_param_com_rc_override.get() & static_cast<int32_t>(RcOverrideBits::OFFBOARD_MODE_BIT)) {
|
||||
override_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (override_enabled) {
|
||||
// If no failsafe is active, directly change the mode, otherwise pass the request to the failsafe state machine
|
||||
if (_failsafe.selectedAction() <= FailsafeBase::Action::Warn) {
|
||||
if (_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_POSCTL, ModeChangeSource::User, true)) {
|
||||
tune_positive(true);
|
||||
mavlink_log_info(&_mavlink_log_pub, "Pilot took over using sticks\t");
|
||||
events::send(events::ID("commander_rc_override"), events::Log::Info, "Pilot took over using sticks");
|
||||
}
|
||||
|
||||
} else {
|
||||
_failsafe_user_override_request = true;
|
||||
}
|
||||
} else {
|
||||
_failsafe_user_override_request = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user