5
0
mirror of https://github.com/ArduPilot/ardupilot synced 2025-03-08 22:53:57 -04:00

APM_OBC: added AFS_ENABLE parameter

AFS system is disabled by default
This commit is contained in:
Andrew Tridgell 2014-08-08 13:30:00 +10:00
parent 226e42f1d7
commit a812bf621f
2 changed files with 34 additions and 7 deletions
libraries/APM_OBC

View File

@ -92,6 +92,12 @@ const AP_Param::GroupInfo APM_OBC::var_info[] PROGMEM = {
// @User: Advanced // @User: Advanced
AP_GROUPINFO("QNH_PRESSURE", 10, APM_OBC, _qnh_pressure, 0), AP_GROUPINFO("QNH_PRESSURE", 10, APM_OBC, _qnh_pressure, 0),
// @Param: ENABLE
// @DisplayName: Enable Advanced Failsafe
// @Description: This enables the advanced failsafe system. If this is set to zero (disable) then all the other AFS options have no effect
// @User: Advanced
AP_GROUPINFO("ENABLE", 11, APM_OBC, _enable, 0),
AP_GROUPEND AP_GROUPEND
}; };
@ -103,6 +109,9 @@ extern bool geofence_breached(void);
void void
APM_OBC::check(APM_OBC::control_mode mode, uint32_t last_heartbeat_ms) APM_OBC::check(APM_OBC::control_mode mode, uint32_t last_heartbeat_ms)
{ {
if (!_enable) {
return;
}
// we always check for fence breach // we always check for fence breach
if (geofence_breached() || check_altlimit()) { if (geofence_breached() || check_altlimit()) {
if (!_terminate) { if (!_terminate) {
@ -159,8 +168,10 @@ APM_OBC::check(APM_OBC::control_mode mode, uint32_t last_heartbeat_ms)
if (!gps_lock_ok) { if (!gps_lock_ok) {
// losing GPS lock when data link is lost // losing GPS lock when data link is lost
// leads to termination // leads to termination
if (!_terminate) {
hal.console->println_P(PSTR("Dual loss TERMINATE")); hal.console->println_P(PSTR("Dual loss TERMINATE"));
_terminate.set(1); _terminate.set(1);
}
} else if (gcs_link_ok) { } else if (gcs_link_ok) {
_state = STATE_AUTO; _state = STATE_AUTO;
hal.console->println_P(PSTR("GCS OK")); hal.console->println_P(PSTR("GCS OK"));
@ -175,8 +186,10 @@ APM_OBC::check(APM_OBC::control_mode mode, uint32_t last_heartbeat_ms)
if (!gcs_link_ok) { if (!gcs_link_ok) {
// losing GCS link when GPS lock lost // losing GCS link when GPS lock lost
// leads to termination // leads to termination
if (!_terminate) {
hal.console->println_P(PSTR("Dual loss TERMINATE")); hal.console->println_P(PSTR("Dual loss TERMINATE"));
_terminate.set(1); _terminate.set(1);
}
} else if (gps_lock_ok) { } else if (gps_lock_ok) {
hal.console->println_P(PSTR("GPS OK")); hal.console->println_P(PSTR("GPS OK"));
_state = STATE_AUTO; _state = STATE_AUTO;
@ -207,6 +220,9 @@ APM_OBC::check(APM_OBC::control_mode mode, uint32_t last_heartbeat_ms)
bool bool
APM_OBC::check_altlimit(void) APM_OBC::check_altlimit(void)
{ {
if (!_enable) {
return false;
}
if (_amsl_limit == 0 || _qnh_pressure <= 0) { if (_amsl_limit == 0 || _qnh_pressure <= 0) {
// no limit set // no limit set
return false; return false;
@ -240,6 +256,9 @@ APM_OBC::check_altlimit(void)
*/ */
void APM_OBC::setup_failsafe(void) void APM_OBC::setup_failsafe(void)
{ {
if (!_enable) {
return;
}
const RC_Channel *ch_roll = RC_Channel::rc_channel(rcmap.roll()-1); const RC_Channel *ch_roll = RC_Channel::rc_channel(rcmap.roll()-1);
const RC_Channel *ch_pitch = RC_Channel::rc_channel(rcmap.pitch()-1); const RC_Channel *ch_pitch = RC_Channel::rc_channel(rcmap.pitch()-1);
const RC_Channel *ch_yaw = RC_Channel::rc_channel(rcmap.yaw()-1); const RC_Channel *ch_yaw = RC_Channel::rc_channel(rcmap.yaw()-1);
@ -258,6 +277,8 @@ void APM_OBC::setup_failsafe(void)
RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_rudder, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_rudder, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_elevator, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_elevator, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_elevator_with_input, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_elevator_with_input, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_manual, RC_Channel::RC_CHANNEL_LIMIT_TRIM);
RC_Channel_aux::set_servo_failsafe(RC_Channel_aux::k_none, RC_Channel::RC_CHANNEL_LIMIT_TRIM);
} }
/* /*
@ -266,6 +287,9 @@ void APM_OBC::setup_failsafe(void)
*/ */
void APM_OBC::check_crash_plane(void) void APM_OBC::check_crash_plane(void)
{ {
if (!_enable) {
return;
}
// ensure failsafe values are setup for if FMU crashes on PX4/Pixhawk // ensure failsafe values are setup for if FMU crashes on PX4/Pixhawk
if (!_failsafe_setup) { if (!_failsafe_setup) {
_failsafe_setup = true; _failsafe_setup = true;
@ -297,4 +321,6 @@ void APM_OBC::check_crash_plane(void)
RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_rudder, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_rudder, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_elevator, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_elevator, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_elevator_with_input, RC_Channel::RC_CHANNEL_LIMIT_MAX); RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_elevator_with_input, RC_Channel::RC_CHANNEL_LIMIT_MAX);
RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_manual, RC_Channel::RC_CHANNEL_LIMIT_TRIM);
RC_Channel_aux::set_servo_limit(RC_Channel_aux::k_none, RC_Channel::RC_CHANNEL_LIMIT_TRIM);
} }

View File

@ -78,6 +78,7 @@ private:
const AP_GPS &gps; const AP_GPS &gps;
const RCMapper &rcmap; const RCMapper &rcmap;
AP_Int8 _enable;
// digital output pins for communicating with the failsafe board // digital output pins for communicating with the failsafe board
AP_Int8 _heartbeat_pin; AP_Int8 _heartbeat_pin;
AP_Int8 _manual_pin; AP_Int8 _manual_pin;