Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
autopilot_arming_switch.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012 The Paparazzi Team
3
*
4
* This file is part of paparazzi.
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, write to
18
* the Free Software Foundation, 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
20
*/
21
29
#ifndef AUTOPILOT_ARMING_SWITCH_H
30
#define AUTOPILOT_ARMING_SWITCH_H
31
32
#include "
autopilot_arming_common.h
"
33
34
#ifndef RADIO_KILL_SWITCH
35
#error "You need to have a RADIO_KILL_SWITCH configured to arm the motors with the switch!"
36
#endif
37
38
enum
arming_state
{
39
STATE_UNINIT
,
40
STATE_WAITING
,
41
STATE_STARTABLE
,
42
STATE_MOTORS_ON
43
};
44
45
enum
arming_state
autopilot_arming_state
;
46
bool
autopilot_unarmed_in_auto
;
47
48
static
inline
void
autopilot_arming_init
(
void
)
49
{
50
autopilot_arming_state
=
STATE_UNINIT
;
51
autopilot_unarmed_in_auto
=
false
;
52
}
53
54
static
inline
void
autopilot_arming_set
(
bool
motors_on)
55
{
56
if
(motors_on) {
57
autopilot_arming_state
=
STATE_MOTORS_ON
;
58
}
else
{
59
if
(
autopilot_arming_state
==
STATE_MOTORS_ON
) {
60
autopilot_arming_state
=
STATE_STARTABLE
;
61
/* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
62
if
(
autopilot_get_mode
() !=
MODE_MANUAL
&&
autopilot_get_mode
() !=
AP_MODE_KILL
&&
63
autopilot_get_mode
() !=
AP_MODE_FAILSAFE
) {
64
autopilot_unarmed_in_auto
=
true
;
65
}
else
{
66
autopilot_unarmed_in_auto
=
false
;
67
}
68
}
69
}
70
}
71
79
static
inline
void
autopilot_arming_check_motors_on
(
void
)
80
{
81
switch
(
autopilot_arming_state
) {
82
case
STATE_UNINIT
:
83
autopilot
.
motors_on
=
false
;
84
if
(
kill_switch_is_on
()) {
85
autopilot_arming_state
=
STATE_STARTABLE
;
86
}
else
{
87
autopilot_arming_state
=
STATE_WAITING
;
88
}
89
break
;
90
case
STATE_WAITING
:
91
autopilot
.
motors_on
=
false
;
92
if
(
kill_switch_is_on
()) {
93
autopilot_arming_state
=
STATE_STARTABLE
;
94
}
95
break
;
96
case
STATE_STARTABLE
:
97
autopilot
.
motors_on
=
false
;
98
/* don't allow to start if in KILL mode or kill switch is on */
99
if
(
autopilot_get_mode
() ==
AP_MODE_KILL
||
kill_switch_is_on
()) {
100
break
;
101
}
102
else
if
(
THROTTLE_STICK_DOWN
() &&
rc_attitude_sticks_centered
() &&
103
(
autopilot_get_mode
() ==
MODE_MANUAL
||
autopilot_unarmed_in_auto
)) {
104
autopilot_arming_state
=
STATE_MOTORS_ON
;
105
}
106
break
;
107
case
STATE_MOTORS_ON
:
108
if
(
kill_switch_is_on
()) {
109
/* kill motors, go to startable state */
110
autopilot
.
motors_on
=
false
;
111
autopilot_arming_state
=
STATE_STARTABLE
;
112
/* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
113
if
(
autopilot_get_mode
() !=
MODE_MANUAL
&&
autopilot_get_mode
() !=
AP_MODE_KILL
&&
114
autopilot_get_mode
() !=
AP_MODE_FAILSAFE
) {
115
autopilot_unarmed_in_auto
=
true
;
116
}
else
{
117
autopilot_unarmed_in_auto
=
false
;
118
}
119
}
else
{
120
autopilot
.
motors_on
=
true
;
121
}
122
break
;
123
default
:
124
break
;
125
}
126
127
}
128
129
#endif
/* AUTOPILOT_ARMING_SWITCH_H */
STATE_MOTORS_ON
@ STATE_MOTORS_ON
Definition:
autopilot_arming_switch.h:42
AP_MODE_FAILSAFE
#define AP_MODE_FAILSAFE
Definition:
autopilot_static.h:36
STATE_STARTABLE
@ STATE_STARTABLE
Definition:
autopilot_arming_switch.h:41
STATE_WAITING
@ STATE_WAITING
Definition:
autopilot_arming_switch.h:40
arming_state
arming_state
Definition:
autopilot_arming_switch.h:38
THROTTLE_STICK_DOWN
#define THROTTLE_STICK_DOWN()
Definition:
autopilot_rc_helpers.h:40
AP_MODE_KILL
#define AP_MODE_KILL
Static autopilot modes.
Definition:
autopilot_static.h:35
autopilot_unarmed_in_auto
bool autopilot_unarmed_in_auto
Definition:
autopilot_arming_switch.h:46
pprz_autopilot::motors_on
bool motors_on
motor status
Definition:
autopilot.h:68
STATE_UNINIT
@ STATE_UNINIT
Definition:
autopilot_arming_switch.h:39
autopilot
struct pprz_autopilot autopilot
Global autopilot structure.
Definition:
autopilot.c:50
autopilot_arming_init
static void autopilot_arming_init(void)
Definition:
autopilot_arming_switch.h:48
autopilot_arming_state
enum arming_state autopilot_arming_state
Definition:
autopilot_arming_switch.h:45
kill_switch_is_on
static bool kill_switch_is_on(void)
Definition:
autopilot_rc_helpers.h:97
rc_attitude_sticks_centered
static bool rc_attitude_sticks_centered(void)
Convenience macro for 3way switch.
Definition:
autopilot_rc_helpers.h:82
autopilot_arming_check_motors_on
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF using the kill switch.
Definition:
autopilot_arming_switch.h:79
autopilot_arming_set
static void autopilot_arming_set(bool motors_on)
Definition:
autopilot_arming_switch.h:54
autopilot_get_mode
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition:
autopilot.c:184
autopilot_arming_common.h
MODE_MANUAL
#define MODE_MANUAL
Default RC mode.
Definition:
autopilot_static.h:60
sw
airborne
firmwares
rotorcraft
autopilot_arming_switch.h
Generated on Tue Feb 1 2022 13:51:13 for Paparazzi UAS by
1.8.17