diff --git a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp index 2e9678fd21..6f617f2728 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp @@ -113,9 +113,13 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter) battery_required_count++; } + if (!_last_armed && context.isArmed()) { + _battery_connected_at_arming[index] = battery.connected; + } + if (context.isArmed()) { - if (!battery.connected) { + if (!battery.connected && _battery_connected_at_arming[index]) { // If disconnected after arming /* EVENT */ reporter.healthFailure(NavModes::All, health_component_t::battery, events::ID("check_battery_disconnected"), @@ -243,6 +247,7 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter) reporter.setIsPresent(health_component_t::battery); } + _last_armed = context.isArmed(); } void BatteryChecks::rtlEstimateCheck(const Context &context, Report &reporter, float worst_battery_time_s) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.hpp b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.hpp index c144f8f3b8..2d5330f5ae 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.hpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.hpp @@ -53,5 +53,7 @@ private: uORB::SubscriptionMultiArray _battery_status_subs{ORB_ID::battery_status}; uORB::Subscription _rtl_time_estimate_sub{ORB_ID(rtl_time_estimate)}; + bool _last_armed{false}; + bool _battery_connected_at_arming[battery_status_s::MAX_INSTANCES] {}; };