mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 11:47:35 +08:00
Commander: Indicate low battery
This commit is contained in:
@@ -2017,16 +2017,8 @@ int commander_thread_main(int argc, char *argv[])
|
|||||||
critical_battery_voltage_actions_done = true;
|
critical_battery_voltage_actions_done = true;
|
||||||
status.battery_warning = vehicle_status_s::VEHICLE_BATTERY_WARNING_CRITICAL;
|
status.battery_warning = vehicle_status_s::VEHICLE_BATTERY_WARNING_CRITICAL;
|
||||||
|
|
||||||
if (!armed.armed) {
|
if (armed.armed) {
|
||||||
arming_ret = arming_state_transition(&status, &safety,
|
mavlink_and_console_log_critical(&mavlink_log_pub, "CRITICAL BATTERY, SHUT SYSTEM DOWN");
|
||||||
vehicle_status_s::ARMING_STATE_STANDBY_ERROR,
|
|
||||||
&armed, true /* fRunPreArmChecks */, &mavlink_log_pub);
|
|
||||||
|
|
||||||
if (arming_ret == TRANSITION_CHANGED) {
|
|
||||||
arming_state_changed = true;
|
|
||||||
mavlink_and_console_log_critical(&mavlink_log_pub, "LOW BATTERY, LOCKING ARMING DOWN");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LAND IMMEDIATELY");
|
mavlink_and_console_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LAND IMMEDIATELY");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ static const bool arming_transitions[vehicle_status_s::ARMING_STATE_MAX][vehicle
|
|||||||
{ /* vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE */ false, false, false, false, false, false, false }, // NYI
|
{ /* vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE */ false, false, false, false, false, false, false }, // NYI
|
||||||
};
|
};
|
||||||
|
|
||||||
// You can index into the array with an arming_state_t in order to get it's textual representation
|
// You can index into the array with an arming_state_t in order to get its textual representation
|
||||||
static const char * const state_names[vehicle_status_s::ARMING_STATE_MAX] = {
|
static const char * const state_names[vehicle_status_s::ARMING_STATE_MAX] = {
|
||||||
"ARMING_STATE_INIT",
|
"ARMING_STATE_INIT",
|
||||||
"ARMING_STATE_STANDBY",
|
"ARMING_STATE_STANDBY",
|
||||||
@@ -276,7 +276,7 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s
|
|||||||
if ((!status->condition_system_prearm_error_reported &&
|
if ((!status->condition_system_prearm_error_reported &&
|
||||||
status->condition_system_hotplug_timeout) ||
|
status->condition_system_hotplug_timeout) ||
|
||||||
(new_arming_state == vehicle_status_s::ARMING_STATE_ARMED)) {
|
(new_arming_state == vehicle_status_s::ARMING_STATE_ARMED)) {
|
||||||
mavlink_and_console_log_critical(mavlink_log_pub, "Not ready to fly: Sensors need inspection");
|
mavlink_and_console_log_critical(mavlink_log_pub, "Not ready to fly: Sensors not set up correctly");
|
||||||
status->condition_system_prearm_error_reported = true;
|
status->condition_system_prearm_error_reported = true;
|
||||||
}
|
}
|
||||||
feedback_provided = true;
|
feedback_provided = true;
|
||||||
@@ -307,7 +307,7 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s
|
|||||||
if (ret == TRANSITION_DENIED) {
|
if (ret == TRANSITION_DENIED) {
|
||||||
/* print to MAVLink and console if we didn't provide any feedback yet */
|
/* print to MAVLink and console if we didn't provide any feedback yet */
|
||||||
if (!feedback_provided) {
|
if (!feedback_provided) {
|
||||||
mavlink_and_console_log_critical(mavlink_log_pub, "INVAL: %s - %s", state_names[status->arming_state], state_names[new_arming_state]);
|
mavlink_and_console_log_critical(mavlink_log_pub, "TRANSITION_DENIED: %s - %s", state_names[status->arming_state], state_names[new_arming_state]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -880,7 +880,14 @@ int preflight_check(struct vehicle_status_s *status, orb_advert_t *mavlink_log_p
|
|||||||
if (!status->cb_usb && status->usb_connected && prearm) {
|
if (!status->cb_usb && status->usb_connected && prearm) {
|
||||||
preflight_ok = false;
|
preflight_ok = false;
|
||||||
if (reportFailures) {
|
if (reportFailures) {
|
||||||
mavlink_and_console_log_critical(mavlink_log_pub, "NOT ARMING: Flying with USB connected prohibited");
|
mavlink_and_console_log_critical(mavlink_log_pub, "ARMING DENIED: Flying with USB is not safe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status->battery_warning == vehicle_status_s::VEHICLE_BATTERY_WARNING_CRITICAL) {
|
||||||
|
preflight_ok = false;
|
||||||
|
if (reportFailures) {
|
||||||
|
mavlink_and_console_log_critical(mavlink_log_pub, "ARMING DENIED: VERY LOW BATTERY");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user