From 572890f8c0da331f2e3a1257631029d575b5688d Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 22 Nov 2021 15:21:22 +0100 Subject: [PATCH] ManualControl: add parameter to disable arm/disarm stick gesture --- src/modules/manual_control/ManualControl.cpp | 4 +- src/modules/manual_control/ManualControl.hpp | 1 + .../manual_control/manual_control_params.c | 44 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/modules/manual_control/manual_control_params.c diff --git a/src/modules/manual_control/ManualControl.cpp b/src/modules/manual_control/ManualControl.cpp index 6fc1a99d03..f6f54ad22f 100644 --- a/src/modules/manual_control/ManualControl.cpp +++ b/src/modules/manual_control/ManualControl.cpp @@ -267,7 +267,7 @@ void ManualControl::processStickArming(const manual_control_setpoint_s &input) const bool previous_stick_arm_hysteresis = _stick_arm_hysteresis.get_state(); _stick_arm_hysteresis.set_state_and_update(left_stick_lower_right && right_stick_centered, input.timestamp); - if (!previous_stick_arm_hysteresis && _stick_arm_hysteresis.get_state()) { + if (_param_man_arm_gesture.get() && !previous_stick_arm_hysteresis && _stick_arm_hysteresis.get_state()) { sendActionRequest(action_request_s::ACTION_ARM, action_request_s::SOURCE_RC_STICK_GESTURE); } @@ -277,7 +277,7 @@ void ManualControl::processStickArming(const manual_control_setpoint_s &input) const bool previous_stick_disarm_hysteresis = _stick_disarm_hysteresis.get_state(); _stick_disarm_hysteresis.set_state_and_update(left_stick_lower_left && right_stick_centered, input.timestamp); - if (!previous_stick_disarm_hysteresis && _stick_disarm_hysteresis.get_state()) { + if (_param_man_arm_gesture.get() && !previous_stick_disarm_hysteresis && _stick_disarm_hysteresis.get_state()) { sendActionRequest(action_request_s::ACTION_DISARM, action_request_s::SOURCE_RC_STICK_GESTURE); } } diff --git a/src/modules/manual_control/ManualControl.hpp b/src/modules/manual_control/ManualControl.hpp index a904fbd444..e6e8b1f3a9 100644 --- a/src/modules/manual_control/ManualControl.hpp +++ b/src/modules/manual_control/ManualControl.hpp @@ -120,6 +120,7 @@ private: (ParamInt) _param_com_rc_in_mode, (ParamFloat) _param_com_rc_loss_t, (ParamFloat) _param_com_rc_stick_ov, + (ParamBool) _param_man_arm_gesture, (ParamInt) _param_com_rc_arm_hyst, (ParamBool) _param_com_arm_swisbtn, (ParamInt) _param_fltmode_1, diff --git a/src/modules/manual_control/manual_control_params.c b/src/modules/manual_control/manual_control_params.c new file mode 100644 index 0000000000..5be9c736c7 --- /dev/null +++ b/src/modules/manual_control/manual_control_params.c @@ -0,0 +1,44 @@ +/**************************************************************************** + * + * Copyright (c) 2021 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * Enable arm/disarm stick gesture + * + * This determines if moving the left stick to the lower right + * arms and to the lower left disarms the vehicle. + * + * @boolean + * @reboot_required true + * @group Manual Control + */ +PARAM_DEFINE_INT32(MAN_ARM_GESTURE, 1);