From 132e9d243966586d7aaf21d9600d9413993e5cc8 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 7 Mar 2023 19:55:01 +0100 Subject: [PATCH] modeCheck: add warning when RC enabled but not present --- src/modules/commander/HealthAndArmingChecks/Common.hpp | 4 ++-- .../commander/HealthAndArmingChecks/checks/modeCheck.cpp | 9 +++++++-- .../commander/HealthAndArmingChecks/checks/modeCheck.hpp | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/commander/HealthAndArmingChecks/Common.hpp b/src/modules/commander/HealthAndArmingChecks/Common.hpp index 3767dc15f0..b0fb2b5dd8 100644 --- a/src/modules/commander/HealthAndArmingChecks/Common.hpp +++ b/src/modules/commander/HealthAndArmingChecks/Common.hpp @@ -246,6 +246,8 @@ public: void armingCheckFailure(NavModes required_modes, HealthComponentIndex component, uint32_t event_id, const events::LogLevels &log_levels, const char *message); + void clearArmingBits(NavModes modes); + /** * Clear can_run bits for certain modes. This will prevent mode switching and trigger failsafe if the * mode is being run. @@ -302,8 +304,6 @@ private: NavModes reportedModes(NavModes required_modes); - void clearArmingBits(NavModes modes); - NavModes getModeGroup(uint8_t nav_state) const; friend class HealthAndArmingChecks; diff --git a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp index 7f2e981532..598531a0da 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.cpp @@ -144,6 +144,10 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter) } if (reporter.failsafeFlags().manual_control_signal_lost && reporter.failsafeFlags().mode_req_manual_control != 0) { + const bool rc_disabled = (_param_com_rc_in_mode.get() == 4); + NavModes nav_modes = rc_disabled ? (NavModes)reporter.failsafeFlags().mode_req_manual_control : NavModes::None; + events::LogLevel log_level = rc_disabled ? events::Log::Error : events::Log::Warning; + /* EVENT * @description * Connect and enable stick input or use autonomous mode. @@ -151,10 +155,11 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter) * Sticks can be enabled via COM_RC_IN_MODE parameter. * */ - reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_manual_control, + reporter.armingCheckFailure(nav_modes, health_component_t::remote_control, events::ID("check_modes_manual_control"), - events::Log::Critical, "No manual control input"); + log_level, "No manual control input"); + reporter.clearArmingBits((NavModes)reporter.failsafeFlags().mode_req_manual_control); reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_manual_control); } diff --git a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.hpp b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.hpp index 6ab8db25d3..ee1e7042b0 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.hpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/modeCheck.hpp @@ -49,6 +49,7 @@ private: void checkArmingRequirement(const Context &context, Report &reporter); DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase, - (ParamBool) _param_com_arm_mis_req + (ParamBool) _param_com_arm_mis_req, + (ParamInt) _param_com_rc_in_mode ); };