mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2025-12-08 19:53:05 +08:00
Add RC termination switch
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -223,6 +223,7 @@ protected:
|
||||
(ParamInt<px4::params::RC_MAP_LOITER_SW>) _param_rc_map_loiter_sw,
|
||||
(ParamInt<px4::params::RC_MAP_OFFB_SW>) _param_rc_map_offb_sw,
|
||||
(ParamInt<px4::params::RC_MAP_KILL_SW>) _param_rc_map_kill_sw,
|
||||
(ParamInt<px4::params::RC_MAP_TERM_SW>) _param_rc_map_term_sw,
|
||||
(ParamInt<px4::params::RC_MAP_ARM_SW>) _param_rc_map_arm_sw,
|
||||
(ParamInt<px4::params::RC_MAP_TRANS_SW>) _param_rc_map_trans_sw,
|
||||
(ParamInt<px4::params::RC_MAP_GEAR_SW>) _param_rc_map_gear_sw,
|
||||
|
||||
Reference in New Issue
Block a user