diff --git a/msg/ActionRequest.msg b/msg/ActionRequest.msg index c8a79c69b9..2e0251797d 100644 --- a/msg/ActionRequest.msg +++ b/msg/ActionRequest.msg @@ -9,6 +9,7 @@ uint8 ACTION_KILL = 4 uint8 ACTION_SWITCH_MODE = 5 uint8 ACTION_VTOL_TRANSITION_TO_MULTICOPTER = 6 uint8 ACTION_VTOL_TRANSITION_TO_FIXEDWING = 7 +uint8 ACTION_TERMINATE = 8 uint8 source # how the request was triggered uint8 SOURCE_STICK_GESTURE = 0 diff --git a/msg/ManualControlSwitches.msg b/msg/ManualControlSwitches.msg index afd9fcb347..4f8b426ada 100644 --- a/msg/ManualControlSwitches.msg +++ b/msg/ManualControlSwitches.msg @@ -23,6 +23,7 @@ uint8 return_switch # return to launch 2 position switch (mandatory uint8 loiter_switch # loiter 2 position switch (optional): _MISSION_, LOITER uint8 offboard_switch # offboard 2 position switch (optional): _NORMAL_, OFFBOARD uint8 kill_switch # throttle kill: _NORMAL_, KILL +uint8 termination_switch # trigger termination which cannot be undone uint8 gear_switch # landing gear switch: _DOWN_, UP uint8 transition_switch # VTOL transition switch: _HOVER, FORWARD_FLIGHT diff --git a/msg/RcChannels.msg b/msg/RcChannels.msg index b932dfd33b..c8cc2e9354 100644 --- a/msg/RcChannels.msg +++ b/msg/RcChannels.msg @@ -29,13 +29,14 @@ uint8 FUNCTION_FLTBTN_SLOT_5 = 25 uint8 FUNCTION_FLTBTN_SLOT_6 = 26 uint8 FUNCTION_ENGAGE_MAIN_MOTOR = 27 uint8 FUNCTION_PAYLOAD_POWER = 28 +uint8 FUNCTION_TERMINATION = 29 uint8 FUNCTION_FLTBTN_SLOT_COUNT = 6 uint64 timestamp_last_valid # Timestamp of last valid RC signal float32[18] channels # Scaled to -1..1 (throttle: 0..1) uint8 channel_count # Number of valid channels -int8[29] function # Functions mapping +int8[30] function # Functions mapping uint8 rssi # Receive signal strength index bool signal_lost # Control signal lost, should be checked together with topic timeout uint32 frame_drop_count # Number of dropped frames diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 424fe77f3a..112f824f20 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -1698,6 +1698,11 @@ void Commander::executeActionRequest(const action_request_s &action_request) break; + case action_request_s::ACTION_TERMINATE: + _user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_TERMINATION); + + break; + case action_request_s::ACTION_SWITCH_MODE: if (!_user_mode_intention.change(action_request.mode, ModeChangeSource::User, false)) { diff --git a/src/modules/manual_control/ManualControl.cpp b/src/modules/manual_control/ManualControl.cpp index dc94487218..4015c2abad 100644 --- a/src/modules/manual_control/ManualControl.cpp +++ b/src/modules/manual_control/ManualControl.cpp @@ -237,6 +237,11 @@ void ManualControl::processSwitches(hrt_abstime &now) } } + if (switches.termination_switch != _previous_switches.termination_switch + && switches.termination_switch == manual_control_switches_s::SWITCH_POS_ON) { + sendActionRequest(action_request_s::ACTION_TERMINATE, action_request_s::SOURCE_RC_SWITCH); + } + if (switches.gear_switch != _previous_switches.gear_switch && _previous_switches.gear_switch != manual_control_switches_s::SWITCH_POS_NONE) { diff --git a/src/modules/rc_update/params.c b/src/modules/rc_update/params.c index eb734de1dc..040593dcce 100644 --- a/src/modules/rc_update/params.c +++ b/src/modules/rc_update/params.c @@ -1441,6 +1441,34 @@ PARAM_DEFINE_INT32(RC_MAP_OFFB_SW, 0); */ PARAM_DEFINE_INT32(RC_MAP_KILL_SW, 0); +/** + * Termination switch channel + * + * @min 0 + * @max 18 + * @group Radio Switches + * @value 0 Unassigned + * @value 1 Channel 1 + * @value 2 Channel 2 + * @value 3 Channel 3 + * @value 4 Channel 4 + * @value 5 Channel 5 + * @value 6 Channel 6 + * @value 7 Channel 7 + * @value 8 Channel 8 + * @value 9 Channel 9 + * @value 10 Channel 10 + * @value 11 Channel 11 + * @value 12 Channel 12 + * @value 13 Channel 13 + * @value 14 Channel 14 + * @value 15 Channel 15 + * @value 16 Channel 16 + * @value 17 Channel 17 + * @value 18 Channel 18 + */ +PARAM_DEFINE_INT32(RC_MAP_TERM_SW, 0); + /** * Arm switch channel. * diff --git a/src/modules/rc_update/rc_update.cpp b/src/modules/rc_update/rc_update.cpp index b793020df7..7c8960a357 100644 --- a/src/modules/rc_update/rc_update.cpp +++ b/src/modules/rc_update/rc_update.cpp @@ -207,6 +207,7 @@ void RCUpdate::update_rc_functions() _rc.function[rc_channels_s::FUNCTION_LOITER] = _param_rc_map_loiter_sw.get() - 1; _rc.function[rc_channels_s::FUNCTION_OFFBOARD] = _param_rc_map_offb_sw.get() - 1; _rc.function[rc_channels_s::FUNCTION_KILLSWITCH] = _param_rc_map_kill_sw.get() - 1; + _rc.function[rc_channels_s::FUNCTION_TERMINATION] = _param_rc_map_term_sw.get() - 1; _rc.function[rc_channels_s::FUNCTION_ARMSWITCH] = _param_rc_map_arm_sw.get() - 1; _rc.function[rc_channels_s::FUNCTION_TRANSITION] = _param_rc_map_trans_sw.get() - 1; _rc.function[rc_channels_s::FUNCTION_GEAR] = _param_rc_map_gear_sw.get() - 1; @@ -631,6 +632,7 @@ void RCUpdate::UpdateManualSwitches(const hrt_abstime ×tamp_sample) switches.loiter_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_LOITER, _param_rc_loiter_th.get()); switches.offboard_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_OFFBOARD, _param_rc_offb_th.get()); switches.kill_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_KILLSWITCH, _param_rc_killswitch_th.get()); + switches.termination_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_TERMINATION, .75f); switches.arm_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_ARMSWITCH, _param_rc_armswitch_th.get()); switches.transition_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_TRANSITION, _param_rc_trans_th.get()); switches.gear_switch = getRCSwitchOnOffPosition(rc_channels_s::FUNCTION_GEAR, _param_rc_gear_th.get()); diff --git a/src/modules/rc_update/rc_update.h b/src/modules/rc_update/rc_update.h index 518c7a31fd..812408debe 100644 --- a/src/modules/rc_update/rc_update.h +++ b/src/modules/rc_update/rc_update.h @@ -223,6 +223,7 @@ protected: (ParamInt) _param_rc_map_loiter_sw, (ParamInt) _param_rc_map_offb_sw, (ParamInt) _param_rc_map_kill_sw, + (ParamInt) _param_rc_map_term_sw, (ParamInt) _param_rc_map_arm_sw, (ParamInt) _param_rc_map_trans_sw, (ParamInt) _param_rc_map_gear_sw,