mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
batteryCheck: refine low battery reporting sevirity
To make sure QGC also shows a box and reads out for "low battery" and make events and mavlink_log reports consistent. Low - Critical Critical - Critical Emergency - Emergency
This commit is contained in:
@@ -204,12 +204,12 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
const bool critical_or_higher = reporter.failsafeFlags().battery_warning >= battery_status_s::WARNING_CRITICAL;
|
const bool critical_or_higher = reporter.failsafeFlags().battery_warning >= battery_status_s::WARNING_CRITICAL;
|
||||||
NavModes affected_modes = (!configured_arm_threshold_in_use && critical_or_higher)
|
NavModes affected_modes = (!configured_arm_threshold_in_use && critical_or_higher)
|
||||||
|| (configured_arm_threshold_in_use && below_configured_arm_threshold) ? NavModes::All : NavModes::None;
|
|| (configured_arm_threshold_in_use && below_configured_arm_threshold) ? NavModes::All : NavModes::None;
|
||||||
events::LogLevel log_level = critical_or_higher || below_configured_arm_threshold
|
|
||||||
? events::Log::Critical : events::Log::Warning;
|
|
||||||
|
|
||||||
switch (reporter.failsafeFlags().battery_warning) {
|
switch (reporter.failsafeFlags().battery_warning) {
|
||||||
default:
|
default:
|
||||||
case battery_status_s::WARNING_LOW:
|
case battery_status_s::WARNING_LOW:
|
||||||
|
// This is declared critical so QGC displays a yellow box and reads "low battery" out loud making the user aware
|
||||||
|
|
||||||
/* EVENT
|
/* EVENT
|
||||||
* @description
|
* @description
|
||||||
* The lowest battery state of charge is below the low threshold.
|
* The lowest battery state of charge is below the low threshold.
|
||||||
@@ -219,10 +219,10 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
* </profile>
|
* </profile>
|
||||||
*/
|
*/
|
||||||
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_low"),
|
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_low"),
|
||||||
log_level, "Low battery");
|
events::Log::Critical, "Low battery");
|
||||||
|
|
||||||
if (reporter.mavlink_log_pub()) {
|
if (reporter.mavlink_log_pub()) {
|
||||||
mavlink_log_warning(reporter.mavlink_log_pub(), "Low battery\t");
|
mavlink_log_critical(reporter.mavlink_log_pub(), "Low battery\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -237,7 +237,7 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
* </profile>
|
* </profile>
|
||||||
*/
|
*/
|
||||||
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_critical"),
|
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_critical"),
|
||||||
log_level, "Critical battery");
|
events::Log::Critical, "Critical battery");
|
||||||
|
|
||||||
if (reporter.mavlink_log_pub()) {
|
if (reporter.mavlink_log_pub()) {
|
||||||
mavlink_log_critical(reporter.mavlink_log_pub(), "Critical battery\t");
|
mavlink_log_critical(reporter.mavlink_log_pub(), "Critical battery\t");
|
||||||
@@ -255,7 +255,7 @@ void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
* </profile>
|
* </profile>
|
||||||
*/
|
*/
|
||||||
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_emergency"),
|
reporter.armingCheckFailure(affected_modes, health_component_t::battery, events::ID("check_battery_emergency"),
|
||||||
log_level, "Emergency battery level");
|
events::Log::Emergency, "Emergency battery level");
|
||||||
|
|
||||||
if (reporter.mavlink_log_pub()) {
|
if (reporter.mavlink_log_pub()) {
|
||||||
mavlink_log_emergency(reporter.mavlink_log_pub(), "Emergency battery level\t");
|
mavlink_log_emergency(reporter.mavlink_log_pub(), "Emergency battery level\t");
|
||||||
|
|||||||
@@ -292,9 +292,8 @@ void FailsafeBase::notifyUser(uint8_t user_intended_mode, Action action, Action
|
|||||||
|
|
||||||
if (action != Action::Warn) {
|
if (action != Action::Warn) {
|
||||||
mavlink_log_critical(&_mavlink_log_pub, "Failsafe activated\t");
|
mavlink_log_critical(&_mavlink_log_pub, "Failsafe activated\t");
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EMSCRIPTEN_BUILD */
|
#endif /* EMSCRIPTEN_BUILD */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user