ManualControl: start to distinguish rc arming methods

This commit is contained in:
Matthias Grob
2021-02-17 18:07:17 +01:00
parent c16b48fd2c
commit 935423b563
3 changed files with 30 additions and 20 deletions
+25 -16
View File
@@ -95,15 +95,20 @@ bool ManualControl::wantsDisarm(const vehicle_control_mode_s &vehicle_control_mo
{
bool ret = false;
// no switch or button is mapped
const bool use_stick = manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_NONE;
// arm switch mapped and "switch is button" configured
const bool use_button = !use_stick && _param_com_arm_swisbtn.get();
// arm switch mapped and "switch_is_button" configured
const bool use_switch = !use_stick && !use_button;
const bool armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
const bool arm_switch_or_button_mapped =
manual_control_switches.arm_switch != manual_control_switches_s::SWITCH_POS_NONE;
const bool arm_button_pressed = _param_arm_switch_is_button.get()
&& (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON);
const bool stick_in_lower_left = _manual_control_setpoint.r < -.9f
const bool stick_in_lower_left = use_stick
&& isThrottleLow()
&& !arm_switch_or_button_mapped;
const bool arm_switch_to_disarm_transition = !_param_arm_switch_is_button.get()
&& _manual_control_setpoint.r < -.9f;
const bool arm_button_pressed = (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON)
&& use_button;
const bool arm_switch_to_disarm_transition = use_switch
&& (_last_manual_control_switches_arm_switch == manual_control_switches_s::SWITCH_POS_ON)
&& (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_OFF);
const bool mc_manual_thrust_mode = vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
@@ -136,16 +141,20 @@ bool ManualControl::wantsArm(const vehicle_control_mode_s &vehicle_control_mode,
{
bool ret = false;
const bool armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
const bool arm_switch_or_button_mapped =
manual_control_switches.arm_switch != manual_control_switches_s::SWITCH_POS_NONE;
const bool arm_button_pressed = _param_arm_switch_is_button.get()
&& (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON);
const bool stick_in_lower_right = _manual_control_setpoint.r > .9f
&& isThrottleLow()
&& !arm_switch_or_button_mapped;
// no switch or button is mapped
const bool use_stick = manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_NONE;
// arm switch mapped and "switch is button" configured
const bool use_button = !use_stick && _param_com_arm_swisbtn.get();
// arm switch mapped and "switch_is_button" configured
const bool use_switch = !use_stick && !use_button;
const bool arm_switch_to_arm_transition = !_param_arm_switch_is_button.get()
const bool armed = (vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED);
const bool stick_in_lower_right = use_stick
&& isThrottleLow()
&& _manual_control_setpoint.r > .9f;
const bool arm_button_pressed = use_button
&& (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON);
const bool arm_switch_to_arm_transition = use_switch
&& (_last_manual_control_switches_arm_switch == manual_control_switches_s::SWITCH_POS_OFF)
&& (manual_control_switches.arm_switch == manual_control_switches_s::SWITCH_POS_ON);
+1 -1
View File
@@ -88,7 +88,7 @@ private:
DEFINE_PARAMETERS(
(ParamFloat<px4::params::COM_RC_LOSS_T>) _param_com_rc_loss_t,
(ParamInt<px4::params::COM_RC_ARM_HYST>) _param_rc_arm_hyst,
(ParamBool<px4::params::COM_ARM_SWISBTN>) _param_arm_switch_is_button,
(ParamBool<px4::params::COM_ARM_SWISBTN>) _param_com_arm_swisbtn,
(ParamBool<px4::params::COM_REARM_GRACE>) _param_com_rearm_grace,
(ParamInt<px4::params::COM_RC_OVERRIDE>) _param_rc_override,
(ParamFloat<px4::params::COM_RC_STICK_OV>) _param_com_rc_stick_ov
+4 -3
View File
@@ -313,10 +313,11 @@ PARAM_DEFINE_FLOAT(COM_DISARM_PRFLT, 10.0f);
PARAM_DEFINE_INT32(COM_ARM_WO_GPS, 1);
/**
* Arm switch is only a button
* Arm switch is a momentary button
*
* The default uses the arm switch as real switch.
* If parameter set button gets handled like stick arming.
* 0: Arming/disarming triggers on switch transition.
* 1: Arming/disarming triggers when holding the momentary button down
* for COM_RC_ARM_HYST like the stick gesture.
*
* @group Commander
* @boolean