2 copter specific AP_AdvancedFailsafe class
7 #if AP_COPTER_ADVANCED_FAILSAFE_ENABLED
10 setup radio_out values for all channels to termination values
12 void AP_AdvancedFailsafe_Copter::terminate_vehicle(void)
14 if (_terminate_action
== TERMINATE_ACTION_LAND
) {
15 copter
.set_mode(Mode::Number::LAND
, ModeReason::TERMINATE
);
18 copter
.motors
->set_desired_spool_state(AP_Motors::DesiredSpoolState::SHUT_DOWN
);
19 copter
.motors
->output();
22 copter
.arming
.disarm(AP_Arming::Method::AFS
);
24 // and set all aux channels
25 SRV_Channels::set_output_limit(SRV_Channel::k_heli_rsc
, SRV_Channel::Limit::TRIM
);
26 SRV_Channels::set_output_limit(SRV_Channel::k_heli_tail_rsc
, SRV_Channel::Limit::TRIM
);
27 SRV_Channels::set_output_limit(SRV_Channel::k_engine_run_enable
, SRV_Channel::Limit::TRIM
);
28 SRV_Channels::set_output_limit(SRV_Channel::k_ignition
, SRV_Channel::Limit::TRIM
);
29 SRV_Channels::set_output_limit(SRV_Channel::k_none
, SRV_Channel::Limit::TRIM
);
30 SRV_Channels::set_output_limit(SRV_Channel::k_manual
, SRV_Channel::Limit::TRIM
);
33 SRV_Channels::output_ch_all();
36 void AP_AdvancedFailsafe_Copter::setup_IO_failsafe(void)
38 // setup failsafe for all aux channels
39 SRV_Channels::set_failsafe_limit(SRV_Channel::k_heli_rsc
, SRV_Channel::Limit::TRIM
);
40 SRV_Channels::set_failsafe_limit(SRV_Channel::k_heli_tail_rsc
, SRV_Channel::Limit::TRIM
);
41 SRV_Channels::set_failsafe_limit(SRV_Channel::k_engine_run_enable
, SRV_Channel::Limit::TRIM
);
42 SRV_Channels::set_failsafe_limit(SRV_Channel::k_ignition
, SRV_Channel::Limit::TRIM
);
43 SRV_Channels::set_failsafe_limit(SRV_Channel::k_none
, SRV_Channel::Limit::TRIM
);
44 SRV_Channels::set_failsafe_limit(SRV_Channel::k_manual
, SRV_Channel::Limit::TRIM
);
46 #if FRAME_CONFIG != HELI_FRAME
47 // setup AP_Motors outputs for failsafe
48 uint32_t mask
= copter
.motors
->get_motor_mask();
49 hal
.rcout
->set_failsafe_pwm(mask
, copter
.motors
->get_pwm_output_min());
54 return an AFS_MODE for current control mode
56 AP_AdvancedFailsafe::control_mode
AP_AdvancedFailsafe_Copter::afs_mode(void)
58 return copter
.flightmode
->afs_mode();
61 //to force entering auto mode when datalink loss
62 void AP_AdvancedFailsafe_Copter::set_mode_auto(void)
64 copter
.set_mode(Mode::Number::AUTO
,ModeReason::GCS_FAILSAFE
);
66 #endif // AP_COPTER_ADVANCED_FAILSAFE_ENABLED