commander: changes when USB connected

- skip avionics rail voltage check when USB connected
 - skip forced reboot on USB disconnect if circuit breaker set
 - avionics voltage preflight check don't silently fail if system_power unavailble
     - explicitly set supply check circuit breaker (CBRK_SUPPLY_CHK)
This commit is contained in:
Daniel Agar
2020-05-04 13:07:58 -04:00
parent 746a8f5cf9
commit 04113b4d57
27 changed files with 77 additions and 37 deletions
@@ -65,9 +65,7 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
&& !status_flags.condition_calibration_enabled);
const bool checkSensors = !hil_enabled;
const bool checkRC = (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT);
const bool checkDynamic = !hil_enabled;
const bool checkPower = (status_flags.condition_power_input_valid && !status_flags.circuit_breaker_engaged_power_check);
bool checkAirspeed = false;
@@ -245,7 +243,7 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
}
/* ---- RC CALIBRATION ---- */
if (checkRC) {
if (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT) {
if (rcCalibrationCheck(mavlink_log_pub, reportFailures, status.is_vtol) != OK) {
if (reportFailures) {
mavlink_log_critical(mavlink_log_pub, "RC calibration check failed");
@@ -265,7 +263,7 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
}
/* ---- SYSTEM POWER ---- */
if (checkPower) {
if (status_flags.condition_power_input_valid && !status_flags.circuit_breaker_engaged_power_check) {
if (!powerCheck(mavlink_log_pub, status, reportFailures, prearm)) {
failed = true;
}
@@ -54,31 +54,37 @@ bool PreFlightCheck::powerCheck(orb_advert_t *mavlink_log_pub, const vehicle_sta
system_power_sub.update();
const system_power_s &system_power = system_power_sub.get();
if (hrt_elapsed_time(&system_power.timestamp) < 200_ms) {
if (hrt_elapsed_time(&system_power.timestamp) < 1_s) {
// Check avionics rail voltages (if USB isn't connected)
if (!system_power.usb_connected) {
float avionics_power_rail_voltage = system_power.voltage5v_v;
/* copy avionics voltage */
float avionics_power_rail_voltage = system_power.voltage5v_v;
if (avionics_power_rail_voltage < 4.5f) {
success = false;
// avionics rail
// Check avionics rail voltages
if (avionics_power_rail_voltage < 4.5f) {
success = false;
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Avionics Power low: %6.2f Volt",
(double)avionics_power_rail_voltage);
}
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Avionics Power low: %6.2f Volt",
(double)avionics_power_rail_voltage);
}
} else if (avionics_power_rail_voltage < 4.9f) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "CAUTION: Avionics Power low: %6.2f Volt", (double)avionics_power_rail_voltage);
}
} else if (avionics_power_rail_voltage < 4.9f) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "CAUTION: Avionics Power low: %6.2f Volt", (double)avionics_power_rail_voltage);
}
} else if (avionics_power_rail_voltage > 5.4f) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "CAUTION: Avionics Power high: %6.2f Volt", (double)avionics_power_rail_voltage);
} else if (avionics_power_rail_voltage > 5.4f) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "CAUTION: Avionics Power high: %6.2f Volt", (double)avionics_power_rail_voltage);
}
}
}
} else {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "system power unavailable");
}
success = false;
}
return success;
+18 -14
View File
@@ -1436,7 +1436,7 @@ Commander::run()
system_power_s system_power{};
_system_power_sub.copy(&system_power);
if (hrt_elapsed_time(&system_power.timestamp) < 200_ms) {
if (hrt_elapsed_time(&system_power.timestamp) < 1_s) {
if (system_power.servo_valid &&
!system_power.brick_valid &&
!system_power.usb_connected) {
@@ -1449,24 +1449,28 @@ Commander::run()
#if defined(CONFIG_BOARDCTL_RESET)
/* if the USB hardware connection went away, reboot */
if (status_flags.usb_connected && !system_power.usb_connected) {
/*
* Apparently the USB cable went away but we are still powered,
* so we bring the system back to a nominal state for flight.
* This is important to unload the USB stack of the OS which is
* a relatively complex piece of software that is non-essential
* for flight and continuing to run it would add a software risk
* without a need. The clean approach to unload it is to reboot.
*/
if (shutdown_if_allowed() && (px4_reboot_request(400_ms) == 0)) {
mavlink_log_critical(&mavlink_log_pub, "USB disconnected, rebooting for flight safety");
if (!status_flags.circuit_breaker_engaged_usb_check && status_flags.usb_connected) {
/* if the USB hardware connection went away, reboot */
if (_system_power_usb_connected && !system_power.usb_connected) {
/*
* Apparently the USB cable went away but we are still powered,
* so we bring the system back to a nominal state for flight.
* This is important to unload the USB stack of the OS which is
* a relatively complex piece of software that is non-essential
* for flight and continuing to run it would add a software risk
* without a need. The clean approach to unload it is to reboot.
*/
if (shutdown_if_allowed() && (px4_reboot_request(false, 400_ms) == 0)) {
mavlink_log_critical(&mavlink_log_pub, "USB disconnected, rebooting for flight safety");
while (1) { px4_usleep(1); }
while (1) { px4_usleep(1); }
}
}
}
#endif // CONFIG_BOARDCTL_RESET
_system_power_usb_connected = system_power.usb_connected;
}
}
+1
View File
@@ -366,6 +366,7 @@ private:
bool _have_taken_off_since_arming{false};
bool _should_set_home_on_takeoff{true};
bool _flight_termination_printed{false};
bool _system_power_usb_connected{false};
main_state_t _main_state_pre_offboard{commander_state_s::MAIN_STATE_MANUAL};