From 967f741a0e1ab8d79f0ca61ac4fac72186c0f848 Mon Sep 17 00:00:00 2001 From: Nicolas MARTIN <59083163+NicolasM0@users.noreply.github.com> Date: Thu, 1 Oct 2020 17:20:08 +0200 Subject: [PATCH] commander: add parameter COM_REARM_GRACE to optionally disable re-arming grace period --- src/modules/commander/Commander.cpp | 8 ++++---- src/modules/commander/Commander.hpp | 1 + src/modules/commander/commander_params.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 21e2164069..434f75dc7c 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -2017,13 +2017,13 @@ Commander::run() && !arm_switch_or_button_mapped; /* allow a grace period for re-arming: preflight checks don't need to pass during that time, * for example for accidential in-air disarming */ - const bool in_arming_grace_period = (_last_disarmed_timestamp != 0) - && (hrt_elapsed_time(&_last_disarmed_timestamp) < 5_s); + const bool in_rearming_grace_period = _param_com_rearm_grace.get() && (_last_disarmed_timestamp != 0) + && (hrt_elapsed_time(&_last_disarmed_timestamp) < 5_s); const bool arm_switch_to_arm_transition = !_param_arm_switch_is_button.get() && (_last_manual_control_setpoint_arm_switch == manual_control_setpoint_s::SWITCH_POS_OFF) && (_manual_control_setpoint.arm_switch == manual_control_setpoint_s::SWITCH_POS_ON) && - (_manual_control_setpoint.z < 0.1f || in_arming_grace_period); + (_manual_control_setpoint.z < 0.1f || in_rearming_grace_period); if (!in_armed_state && (status.rc_input_mode != vehicle_status_s::RC_IN_MODE_OFF) && @@ -2051,7 +2051,7 @@ Commander::run() } else if (status.arming_state == vehicle_status_s::ARMING_STATE_STANDBY) { arming_ret = arming_state_transition(&status, _safety, vehicle_status_s::ARMING_STATE_ARMED, &armed, - !in_arming_grace_period /* fRunPreArmChecks */, + !in_rearming_grace_period /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, _arm_requirements, hrt_elapsed_time(&_boot_timestamp), (arm_switch_to_arm_transition ? arm_disarm_reason_t::RC_SWITCH : arm_disarm_reason_t::RC_STICK)); diff --git a/src/modules/commander/Commander.hpp b/src/modules/commander/Commander.hpp index f99d88fd85..1c2d65a246 100644 --- a/src/modules/commander/Commander.hpp +++ b/src/modules/commander/Commander.hpp @@ -225,6 +225,7 @@ private: (ParamBool) _param_arm_mission_required, (ParamBool) _param_arm_auth_required, (ParamBool) _param_escs_checks_required, + (ParamBool) _param_com_rearm_grace, (ParamInt) _param_flight_uuid, (ParamInt) _param_takeoff_finished_action, diff --git a/src/modules/commander/commander_params.c b/src/modules/commander/commander_params.c index 239901afd2..3bd0c63c58 100644 --- a/src/modules/commander/commander_params.c +++ b/src/modules/commander/commander_params.c @@ -614,6 +614,16 @@ PARAM_DEFINE_INT32(COM_ARM_MAG_ANG, 45); */ PARAM_DEFINE_INT32(COM_ARM_MAG_STR, 1); +/** + * Rearming grace period + * + * Re-arming grace allows to rearm the drone with manual command without running prearmcheck during 5 s after disarming. + * + * @group Commander + * @boolean + */ +PARAM_DEFINE_INT32(COM_REARM_GRACE, 1); + /** * Enable RC stick override of auto and/or offboard modes *