mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
colcon build/test / build-test (push) Has been cancelled
Cygwin Build / build (push) Has been cancelled
ESP32 Build / build (esp32buzz, 10) (push) Has been cancelled
ESP32 Build / build (esp32s3empty, 10) (push) Has been cancelled
Macos Build / build (CubeOrange) (push) Has been cancelled
Macos Build / build (sitl) (push) Has been cancelled
QURT Build / build (push) Has been cancelled
test ccache / build (10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-EKF2, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-ODID, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-PPP, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (CubeRedPrimary-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (MatekF405-Wing, 10, chibios) (push) Has been cancelled
test chibios / build (Pixhawk6X-PPPGW, 10, chibios) (push) Has been cancelled
test chibios / build (SOHW, 10, chibios) (push) Has been cancelled
test chibios / build (build-options-defaults-test, 10, chibios) (push) Has been cancelled
test chibios / build (configure-all, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv2-plane, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv3, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv3-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (iofirmware, 10, chibios) (push) Has been cancelled
test chibios / build (new-check, 10, chibios) (push) Has been cancelled
test chibios / build (periph-build, 10, chibios) (push) Has been cancelled
test chibios / build (revo-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (revo-mini, 10, chibios) (push) Has been cancelled
test chibios / build (signing, 10, chibios) (push) Has been cancelled
test chibios / build (stm32f7, 10, chibios) (push) Has been cancelled
test chibios / build (stm32h7, 10, chibios) (push) Has been cancelled
test chibios / build (stm32h7-debug, 10, chibios) (push) Has been cancelled
test dds / build (sitl) (push) Has been cancelled
test dds / build (stm32h7) (push) Has been cancelled
test Linux SBC / build (bbbmini, armhf) (push) Has been cancelled
test Linux SBC / build (bebop, armhf) (push) Has been cancelled
test Linux SBC / build (bhat, armhf) (push) Has been cancelled
test Linux SBC / build (canzero, armhf) (push) Has been cancelled
test Linux SBC / build (erlebrain2, armhf) (push) Has been cancelled
test Linux SBC / build (linux, base) (push) Has been cancelled
test Linux SBC / build (navigator, armhf-musl) (push) Has been cancelled
test Linux SBC / build (navigator64, aarch64) (push) Has been cancelled
test Linux SBC / build (navio, armhf) (push) Has been cancelled
test Linux SBC / build (navio2, armhf) (push) Has been cancelled
test Linux SBC / build (pxf, armhf) (push) Has been cancelled
test Linux SBC / build (pxfmini, armhf) (push) Has been cancelled
test replay / build (replay, base) (push) Has been cancelled
test replay / build (replay, clang) (push) Has been cancelled
test scripts / build (astyle-cleanliness) (push) Has been cancelled
test scripts / build (check_autotest_options) (push) Has been cancelled
test scripts / build (logger_metadata) (push) Has been cancelled
test scripts / build (param_parse) (push) Has been cancelled
test scripts / build (python-cleanliness) (push) Has been cancelled
test scripts / build (validate_board_list) (push) Has been cancelled
test blimp / build (base) (push) Has been cancelled
test blimp / build (clang) (push) Has been cancelled
test blimp / autotest (sitltest-blimp) (push) Has been cancelled
test copter / build (base) (push) Has been cancelled
test copter / build (clang) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1a) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1b) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1c) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1d) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1e) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests2a) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests2b) (push) Has been cancelled
test copter / build-gcc-heli (push) Has been cancelled
test copter / autotest-heli (sitltest-heli) (push) Has been cancelled
test ap_periph / build-gcc-ap_periph (push) Has been cancelled
test ap_periph / autotest-can (sitltest-can) (push) Has been cancelled
test plane / build (base) (push) Has been cancelled
test plane / build (clang) (push) Has been cancelled
test plane / autotest (sitltest-plane-tests1a) (push) Has been cancelled
test plane / autotest (sitltest-plane-tests1b) (push) Has been cancelled
test plane / autotest (sitltest-quadplane) (push) Has been cancelled
test rover / build (base) (push) Has been cancelled
test rover / build (clang) (push) Has been cancelled
test rover / autotest (sitltest-balancebot) (push) Has been cancelled
test rover / autotest (sitltest-rover) (push) Has been cancelled
test rover / autotest (sitltest-sailboat) (push) Has been cancelled
test sub / build (base) (push) Has been cancelled
test sub / build (clang) (push) Has been cancelled
test sub / autotest (sitltest-sub) (push) Has been cancelled
test tracker / build (base) (push) Has been cancelled
test tracker / build (clang) (push) Has been cancelled
test tracker / autotest (sitltest-tracker) (push) Has been cancelled
test unit tests and sitl building / build (examples, base) (push) Has been cancelled
test unit tests and sitl building / build (examples, clang) (push) Has been cancelled
test unit tests and sitl building / build (sitl, base) (push) Has been cancelled
test unit tests and sitl building / build (sitl, clang) (push) Has been cancelled
test unit tests and sitl building / build (unit-tests, base) (push) Has been cancelled
test unit tests and sitl building / build (unit-tests, clang) (push) Has been cancelled
178 lines
6.3 KiB
C++
178 lines
6.3 KiB
C++
#include "Blimp.h"
|
|
|
|
/*
|
|
* This event will be called when the failsafe changes
|
|
* boolean failsafe reflects the current state
|
|
*/
|
|
|
|
#include <AP_Vehicle/AP_MultiCopter.h>
|
|
|
|
bool Blimp::failsafe_option(FailsafeOption opt) const
|
|
{
|
|
return (g2.fs_options & (uint32_t)opt);
|
|
}
|
|
|
|
void Blimp::failsafe_radio_on_event()
|
|
{
|
|
LOGGER_WRITE_ERROR(LogErrorSubsystem::FAILSAFE_RADIO, LogErrorCode::FAILSAFE_OCCURRED);
|
|
|
|
// set desired action based on FS_THR_ENABLE parameter
|
|
Failsafe_Action desired_action;
|
|
switch (g.failsafe_throttle) {
|
|
case FS_THR_DISABLED:
|
|
desired_action = Failsafe_Action_None;
|
|
break;
|
|
case FS_THR_ENABLED_ALWAYS_LAND:
|
|
desired_action = Failsafe_Action_Land;
|
|
break;
|
|
default:
|
|
desired_action = Failsafe_Action_Land;
|
|
}
|
|
|
|
// Conditions to deviate from FS_THR_ENABLE selection and send specific GCS warning
|
|
if (should_disarm_on_failsafe()) {
|
|
// should immediately disarm when we're on the ground
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Radio Failsafe - Disarming");
|
|
arming.disarm(AP_Arming::Method::RADIOFAILSAFE);
|
|
desired_action = Failsafe_Action_None;
|
|
|
|
} else if (flightmode->is_landing() && ((battery.has_failsafed() && battery.get_highest_failsafe_priority() <= FAILSAFE_LAND_PRIORITY))) {
|
|
// Allow landing to continue when battery failsafe requires it (not a user option)
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Radio + Battery Failsafe - Continuing Landing");
|
|
desired_action = Failsafe_Action_Land;
|
|
|
|
} else if (flightmode->is_landing() && failsafe_option(FailsafeOption::CONTINUE_IF_LANDING)) {
|
|
// Allow landing to continue when FS_OPTIONS is set to continue landing
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Radio Failsafe - Continuing Landing");
|
|
desired_action = Failsafe_Action_Land;
|
|
|
|
} else {
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Radio Failsafe");
|
|
}
|
|
|
|
// Call the failsafe action handler
|
|
do_failsafe_action(desired_action, ModeReason::RADIO_FAILSAFE);
|
|
}
|
|
|
|
// failsafe_off_event - respond to radio contact being regained
|
|
void Blimp::failsafe_radio_off_event()
|
|
{
|
|
// no need to do anything except log the error as resolved
|
|
// user can now override roll, pitch, yaw and throttle and even use flight mode switch to restore previous flight mode
|
|
LOGGER_WRITE_ERROR(LogErrorSubsystem::FAILSAFE_RADIO, LogErrorCode::FAILSAFE_RESOLVED);
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Radio Failsafe Cleared");
|
|
}
|
|
|
|
void Blimp::handle_battery_failsafe(const char *type_str, const int8_t action)
|
|
{
|
|
LOGGER_WRITE_ERROR(LogErrorSubsystem::FAILSAFE_BATT, LogErrorCode::FAILSAFE_OCCURRED);
|
|
|
|
Failsafe_Action desired_action = (Failsafe_Action)action;
|
|
|
|
// Conditions to deviate from BATT_FS_XXX_ACT parameter setting
|
|
if (should_disarm_on_failsafe()) {
|
|
// should immediately disarm when we're on the ground
|
|
arming.disarm(AP_Arming::Method::BATTERYFAILSAFE);
|
|
desired_action = Failsafe_Action_None;
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Battery Failsafe - Disarming");
|
|
|
|
} else if (flightmode->is_landing() && failsafe_option(FailsafeOption::CONTINUE_IF_LANDING) && desired_action != Failsafe_Action_None) {
|
|
// Allow landing to continue when FS_OPTIONS is set to continue when landing
|
|
desired_action = Failsafe_Action_Land;
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Battery Failsafe - Continuing Landing");
|
|
} else {
|
|
gcs().send_text(MAV_SEVERITY_WARNING, "Battery Failsafe");
|
|
}
|
|
|
|
// Battery FS options already use the Failsafe_Options enum. So use them directly.
|
|
do_failsafe_action(desired_action, ModeReason::BATTERY_FAILSAFE);
|
|
|
|
}
|
|
// failsafe_gcs_check - check for ground station failsafe
|
|
void Blimp::failsafe_gcs_check()
|
|
{
|
|
// Bypass GCS failsafe checks if disabled or GCS never connected
|
|
if (g.failsafe_gcs == FS_GCS_DISABLED) {
|
|
return;
|
|
}
|
|
|
|
const uint32_t gcs_last_seen_ms = gcs().sysid_mygcs_last_seen_time_ms();
|
|
if (gcs_last_seen_ms == 0) {
|
|
return;
|
|
}
|
|
|
|
// calc time since last gcs update
|
|
// note: this only looks at the heartbeat from the device id set by gcs().sysid_mygcs()
|
|
const uint32_t last_gcs_update_ms = millis() - gcs_last_seen_ms;
|
|
const uint32_t gcs_timeout_ms = uint32_t(constrain_float(g2.fs_gcs_timeout * 1000.0f, 0.0f, UINT32_MAX));
|
|
|
|
// Determine which event to trigger
|
|
if (last_gcs_update_ms < gcs_timeout_ms && failsafe.gcs) {
|
|
// Recovery from a GCS failsafe
|
|
set_failsafe_gcs(false);
|
|
// failsafe_gcs_off_event();
|
|
|
|
} else if (last_gcs_update_ms < gcs_timeout_ms && !failsafe.gcs) {
|
|
// No problem, do nothing
|
|
|
|
} else if (last_gcs_update_ms > gcs_timeout_ms && failsafe.gcs) {
|
|
// Already in failsafe, do nothing
|
|
|
|
} else if (last_gcs_update_ms > gcs_timeout_ms && !failsafe.gcs) {
|
|
// New GCS failsafe event, trigger events
|
|
set_failsafe_gcs(true);
|
|
arming.disarm(AP_Arming::Method::GCSFAILSAFE); // failsafe_gcs_on_event() should replace this when written
|
|
}
|
|
}
|
|
|
|
bool Blimp::should_disarm_on_failsafe()
|
|
{
|
|
if (ap.in_arming_delay) {
|
|
return true;
|
|
}
|
|
|
|
switch (control_mode) {
|
|
case Mode::Number::MANUAL:
|
|
default:
|
|
// if landed disarm
|
|
return ap.land_complete;
|
|
}
|
|
}
|
|
|
|
|
|
void Blimp::do_failsafe_action(Failsafe_Action action, ModeReason reason)
|
|
{
|
|
|
|
// Execute the specified desired_action
|
|
switch (action) {
|
|
case Failsafe_Action_None:
|
|
return;
|
|
case Failsafe_Action_Land:
|
|
set_mode_land_failsafe(reason);
|
|
break;
|
|
case Failsafe_Action_Terminate: {
|
|
arming.disarm(AP_Arming::Method::FAILSAFE_ACTION_TERMINATE);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// check for gps glitch failsafe
|
|
void Blimp::gpsglitch_check()
|
|
{
|
|
// get filter status
|
|
const bool gps_glitching = AP::ahrs().has_status(AP_AHRS::Status::GPS_GLITCHING);
|
|
|
|
// log start or stop of gps glitch. AP_Notify update is handled from within AP_AHRS
|
|
if (ap.gps_glitching != gps_glitching) {
|
|
ap.gps_glitching = gps_glitching;
|
|
if (gps_glitching) {
|
|
LOGGER_WRITE_ERROR(LogErrorSubsystem::GPS, LogErrorCode::GPS_GLITCH);
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL,"GPS Glitch");
|
|
} else {
|
|
LOGGER_WRITE_ERROR(LogErrorSubsystem::GPS, LogErrorCode::ERROR_RESOLVED);
|
|
gcs().send_text(MAV_SEVERITY_CRITICAL,"GPS Glitch cleared");
|
|
}
|
|
}
|
|
}
|