commander: check if battery was already disconnected on arming

If so, don't report.
Happens e.g. with USB powered pixhawk.
This commit is contained in:
Beat Küng
2022-10-11 22:31:20 -04:00
committed by Daniel Agar
parent 24142bc014
commit 693af897b3
2 changed files with 8 additions and 1 deletions
@@ -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<uint8_t>(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)
@@ -53,5 +53,7 @@ private:
uORB::SubscriptionMultiArray<battery_status_s, battery_status_s::MAX_INSTANCES> _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] {};
};