From 75209a755276fc4669f06cac7833849e4b7ac554 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 16 Jun 2021 09:08:50 +0200 Subject: [PATCH] manual_control: address review comments --- src/modules/manual_control/ManualControl.cpp | 19 ++++++++----------- src/modules/manual_control/ManualControl.hpp | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/modules/manual_control/ManualControl.cpp b/src/modules/manual_control/ManualControl.cpp index 44389cb7af..5366c67020 100644 --- a/src/modules/manual_control/ManualControl.cpp +++ b/src/modules/manual_control/ManualControl.cpp @@ -132,7 +132,9 @@ void ManualControl::Run() _previous_arm_gesture = true; send_arm_command(ArmingAction::ARM, ArmingOrigin::GESTURE); - } else if (!_selector.setpoint().arm_gesture) { + } + + if (!_selector.setpoint().arm_gesture) { _previous_arm_gesture = false; } @@ -140,7 +142,9 @@ void ManualControl::Run() _previous_disarm_gesture = true; send_arm_command(ArmingAction::DISARM, ArmingOrigin::GESTURE); - } else if (!_selector.setpoint().disarm_gesture) { + } + + if (!_selector.setpoint().disarm_gesture) { _previous_disarm_gesture = false; } @@ -157,7 +161,7 @@ void ManualControl::Run() || (fabsf(_r_diff.diff()) > minimum_stick_change); // Throttle change value doubled to achieve the same scaling even though the range is [0,1] instead of [-1,1] - const bool throttle_moved = (fabsf(_z_diff.diff()) * 2.f > minimum_stick_change); + const bool throttle_moved = (fabsf(_z_diff.diff()) * 2.f) > minimum_stick_change; _selector.setpoint().user_override = rpy_moved || throttle_moved; @@ -243,7 +247,7 @@ void ManualControl::Run() } } else { - // Send an initial command to switch to the mode requested by R + // Send an initial command to switch to the mode requested by RC evaluate_mode_slot(switches.mode_slot); } @@ -251,7 +255,6 @@ void ManualControl::Run() _previous_switches = switches; } else { - _previous_switches = {}; _previous_switches_initialized = false; _last_mode_slot_flt = -1; } @@ -260,16 +263,10 @@ void ManualControl::Run() _selector.setpoint().timestamp = now; _manual_control_setpoint_pub.publish(_selector.setpoint()); - if (_last_selected_input != _selector.instance()) { - _last_selected_input = _selector.instance(); - } - _manual_control_input_subs[_selector.instance()].registerCallback(); _manual_control_switches_sub.registerCallback(); } else { - _last_selected_input = -1; - if (!_published_invalid_once) { _published_invalid_once = true; _manual_control_setpoint_pub.publish(_selector.setpoint()); diff --git a/src/modules/manual_control/ManualControl.hpp b/src/modules/manual_control/ManualControl.hpp index 79b0a5c6d4..410cede1ad 100644 --- a/src/modules/manual_control/ManualControl.hpp +++ b/src/modules/manual_control/ManualControl.hpp @@ -155,7 +155,6 @@ private: ManualControlSelector _selector; bool _published_invalid_once{false}; - int _last_selected_input{-1}; bool _previous_arm_gesture{false}; bool _previous_disarm_gesture{false};