CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduCopter/AP_State.cpp
Views: 1798
1
#include "Copter.h"
2
3
// ---------------------------------------------
4
void Copter::set_auto_armed(bool b)
5
{
6
// if no change, exit immediately
7
if( ap.auto_armed == b )
8
return;
9
10
ap.auto_armed = b;
11
if(b){
12
LOGGER_WRITE_EVENT(LogEvent::AUTO_ARMED);
13
}
14
}
15
16
// ---------------------------------------------
17
/**
18
* Set Simple mode
19
*
20
* @param [in] b 0:false or disabled, 1:true or SIMPLE, 2:SUPERSIMPLE
21
*/
22
void Copter::set_simple_mode(SimpleMode b)
23
{
24
if (simple_mode != b) {
25
switch (b) {
26
case SimpleMode::NONE:
27
LOGGER_WRITE_EVENT(LogEvent::SET_SIMPLE_OFF);
28
gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode off");
29
break;
30
case SimpleMode::SIMPLE:
31
LOGGER_WRITE_EVENT(LogEvent::SET_SIMPLE_ON);
32
gcs().send_text(MAV_SEVERITY_INFO, "SIMPLE mode on");
33
break;
34
case SimpleMode::SUPERSIMPLE:
35
// initialise super simple heading
36
update_super_simple_bearing(true);
37
LOGGER_WRITE_EVENT(LogEvent::SET_SUPERSIMPLE_ON);
38
gcs().send_text(MAV_SEVERITY_INFO, "SUPERSIMPLE mode on");
39
break;
40
}
41
simple_mode = b;
42
}
43
}
44
45
// ---------------------------------------------
46
void Copter::set_failsafe_radio(bool b)
47
{
48
// only act on changes
49
// -------------------
50
if(failsafe.radio != b) {
51
52
// store the value so we don't trip the gate twice
53
// -----------------------------------------------
54
failsafe.radio = b;
55
56
if (failsafe.radio == false) {
57
// We've regained radio contact
58
// ----------------------------
59
failsafe_radio_off_event();
60
}else{
61
// We've lost radio contact
62
// ------------------------
63
failsafe_radio_on_event();
64
}
65
66
// update AP_Notify
67
AP_Notify::flags.failsafe_radio = b;
68
}
69
}
70
71
72
// ---------------------------------------------
73
void Copter::set_failsafe_gcs(bool b)
74
{
75
failsafe.gcs = b;
76
77
// update AP_Notify
78
AP_Notify::flags.failsafe_gcs = b;
79
}
80
81
// ---------------------------------------------
82
83
void Copter::update_using_interlock()
84
{
85
#if FRAME_CONFIG == HELI_FRAME
86
// helicopters are always using motor interlock
87
ap.using_interlock = true;
88
#else
89
// check if we are using motor interlock control on an aux switch or are in throw mode
90
// which uses the interlock to stop motors while the copter is being thrown
91
ap.using_interlock = rc().find_channel_for_option(RC_Channel::AUX_FUNC::MOTOR_INTERLOCK) != nullptr;
92
#endif
93
}
94
95