2015-05-29 23:12:49 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
2012-11-10 01:43:43 -04:00
|
|
|
// ---------------------------------------------
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::set_auto_armed(bool b)
|
2012-11-10 01:43:43 -04:00
|
|
|
{
|
2013-01-12 11:13:10 -04:00
|
|
|
// if no change, exit immediately
|
|
|
|
if( ap.auto_armed == b )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ap.auto_armed = b;
|
|
|
|
if(b){
|
|
|
|
Log_Write_Event(DATA_AUTO_ARMED);
|
|
|
|
}
|
2012-11-10 01:43:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2017-05-06 21:30:50 -03:00
|
|
|
/**
|
|
|
|
* Set Simple mode
|
|
|
|
*
|
|
|
|
* @param [in] b 0:false or disabled, 1:true or SIMPLE, 2:SUPERSIMPLE
|
|
|
|
*/
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::set_simple_mode(uint8_t b)
|
2012-11-10 01:43:43 -04:00
|
|
|
{
|
2017-05-06 21:30:50 -03:00
|
|
|
if (ap.simple_mode != b) {
|
2016-10-04 10:12:29 -03:00
|
|
|
switch (b) {
|
2017-05-06 21:30:50 -03:00
|
|
|
case 0:
|
|
|
|
Log_Write_Event(DATA_SET_SIMPLE_OFF);
|
2017-07-09 00:47:39 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode off");
|
2017-05-06 21:30:50 -03:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Log_Write_Event(DATA_SET_SIMPLE_ON);
|
2017-07-09 00:47:39 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode on");
|
2017-05-06 21:30:50 -03:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
// initialise super simple heading
|
|
|
|
update_super_simple_bearing(true);
|
|
|
|
Log_Write_Event(DATA_SET_SUPERSIMPLE_ON);
|
2017-07-09 00:47:39 -03:00
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "SUPERSIMPLE mode on");
|
2017-05-06 21:30:50 -03:00
|
|
|
break;
|
2013-01-12 11:13:10 -04:00
|
|
|
}
|
2013-09-11 02:36:38 -03:00
|
|
|
ap.simple_mode = b;
|
2013-01-12 11:13:10 -04:00
|
|
|
}
|
2012-11-10 01:43:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::set_failsafe_radio(bool b)
|
2012-11-10 01:43:43 -04:00
|
|
|
{
|
|
|
|
// only act on changes
|
|
|
|
// -------------------
|
2013-09-26 05:54:33 -03:00
|
|
|
if(failsafe.radio != b) {
|
2012-11-10 01:43:43 -04:00
|
|
|
|
|
|
|
// store the value so we don't trip the gate twice
|
|
|
|
// -----------------------------------------------
|
2013-09-26 05:54:33 -03:00
|
|
|
failsafe.radio = b;
|
2012-11-10 01:43:43 -04:00
|
|
|
|
2013-09-26 05:54:33 -03:00
|
|
|
if (failsafe.radio == false) {
|
2012-11-10 01:43:43 -04:00
|
|
|
// We've regained radio contact
|
|
|
|
// ----------------------------
|
2013-03-16 05:14:21 -03:00
|
|
|
failsafe_radio_off_event();
|
2012-11-10 01:43:43 -04:00
|
|
|
}else{
|
|
|
|
// We've lost radio contact
|
|
|
|
// ------------------------
|
2013-03-16 05:14:21 -03:00
|
|
|
failsafe_radio_on_event();
|
2012-11-10 01:43:43 -04:00
|
|
|
}
|
2013-09-11 02:36:38 -03:00
|
|
|
|
|
|
|
// update AP_Notify
|
|
|
|
AP_Notify::flags.failsafe_radio = b;
|
2012-11-10 01:43:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-29 09:30:22 -03:00
|
|
|
// ---------------------------------------------
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::set_failsafe_gcs(bool b)
|
2013-04-29 09:30:22 -03:00
|
|
|
{
|
2013-09-26 05:54:33 -03:00
|
|
|
failsafe.gcs = b;
|
2013-04-29 09:30:22 -03:00
|
|
|
}
|
|
|
|
|
2012-11-10 01:43:43 -04:00
|
|
|
// ---------------------------------------------
|
|
|
|
|
2015-11-15 21:58:15 -04:00
|
|
|
void Copter::update_using_interlock()
|
2015-03-12 21:44:46 -03:00
|
|
|
{
|
2015-11-15 21:58:15 -04:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
|
|
|
// helicopters are always using motor interlock
|
|
|
|
ap.using_interlock = true;
|
|
|
|
#else
|
2016-01-08 03:34:16 -04:00
|
|
|
// check if we are using motor interlock control on an aux switch or are in throw mode
|
|
|
|
// which uses the interlock to stop motors while the copter is being thrown
|
2018-06-04 00:06:32 -03:00
|
|
|
ap.using_interlock = rc().find_channel_for_option(RC_Channel::aux_func::MOTOR_INTERLOCK) != nullptr;
|
2015-11-15 21:58:15 -04:00
|
|
|
#endif
|
2015-03-12 21:44:46 -03:00
|
|
|
}
|
|
|
|
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::set_motor_emergency_stop(bool b)
|
2015-03-17 18:53:40 -03:00
|
|
|
{
|
2015-04-22 14:56:05 -03:00
|
|
|
if(ap.motor_emergency_stop != b) {
|
|
|
|
ap.motor_emergency_stop = b;
|
2015-03-17 18:53:40 -03:00
|
|
|
}
|
2015-04-22 15:36:59 -03:00
|
|
|
|
|
|
|
// Log new status
|
|
|
|
if (ap.motor_emergency_stop){
|
|
|
|
Log_Write_Event(DATA_MOTORS_EMERGENCY_STOPPED);
|
|
|
|
} else {
|
|
|
|
Log_Write_Event(DATA_MOTORS_EMERGENCY_STOP_CLEARED);
|
|
|
|
}
|
2015-05-29 23:12:49 -03:00
|
|
|
}
|