From bd50a52c9cb473c6e3beeb89927c8b43beba2e21 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 7 Jun 2022 18:24:20 +0200 Subject: [PATCH] Commander: fix startup sound interrupted by safety button initialization The safetyButtonHandler() reports that the safety statatus changed on the first loop iteration when safety is disabled which makes sense to inform the system that safety is off but the tune for the user should not be played because it interrupts the startup tune. --- src/modules/commander/Commander.cpp | 10 ++++++---- src/modules/commander/Safety.hpp | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 46f510a52d..8e07e24572 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -2307,11 +2307,13 @@ Commander::run() _safety.isButtonAvailable(), _vehicle_status); // Notify the user if the status of the safety button changes - if (_safety.isSafetyOff()) { - set_tune(tune_control_s::TUNE_ID_NOTIFY_POSITIVE); + if (!_safety.isSafetyDisabled()) { + if (_safety.isSafetyOff()) { + set_tune(tune_control_s::TUNE_ID_NOTIFY_POSITIVE); - } else { - tune_neutral(true); + } else { + tune_neutral(true); + } } _status_changed = true; diff --git a/src/modules/commander/Safety.hpp b/src/modules/commander/Safety.hpp index 0092903517..443be32a1e 100644 --- a/src/modules/commander/Safety.hpp +++ b/src/modules/commander/Safety.hpp @@ -51,6 +51,7 @@ public: void activateSafety(); bool isButtonAvailable() { return _button_available; } bool isSafetyOff() { return _safety_off; } + bool isSafetyDisabled() { return _safety_disabled; } private: uORB::Subscription _safety_button_sub{ORB_ID::safety_button};