Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
autopilot_arming_throttle.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_THROTTLE_H
30
#define AUTOPILOT_ARMING_THROTTLE_H
31
32
#include "
autopilot_rc_helpers.h
"
33
34
#define AUTOPILOT_ARMING_DELAY 10
35
36
enum
arming_throttle_state
{
37
STATE_UNINIT
,
38
STATE_WAITING
,
39
STATE_MOTORS_OFF_READY
,
40
STATE_ARMING
,
41
STATE_MOTORS_ON
,
42
STATE_UNARMING
43
};
44
45
enum
arming_throttle_state
autopilot_arming_state
;
46
uint8_t
autopilot_arming_delay_counter
;
47
bool
autopilot_unarmed_in_auto
;
48
49
static
inline
void
autopilot_arming_init
(
void
)
50
{
51
autopilot_arming_state
=
STATE_UNINIT
;
52
autopilot_arming_delay_counter
= 0;
53
autopilot_unarmed_in_auto
=
false
;
54
}
55
56
static
inline
void
autopilot_arming_set
(
bool
motors_on)
57
{
58
if
(motors_on) {
59
autopilot_arming_state
=
STATE_MOTORS_ON
;
60
}
else
{
61
if
(
autopilot_arming_state
==
STATE_MOTORS_ON
) {
62
autopilot_arming_state
=
STATE_WAITING
;
63
}
64
}
65
}
66
74
static
inline
void
autopilot_arming_check_motors_on
(
void
)
75
{
76
77
/* only allow switching motor if not in KILL mode */
78
if
(
autopilot_mode
!=
AP_MODE_KILL
) {
79
80
switch
(
autopilot_arming_state
) {
81
case
STATE_UNINIT
:
82
autopilot_motors_on
=
false
;
83
autopilot_arming_delay_counter
= 0;
84
if
(
THROTTLE_STICK_DOWN
()) {
85
autopilot_arming_state
=
STATE_MOTORS_OFF_READY
;
86
}
else
{
87
autopilot_arming_state
=
STATE_WAITING
;
88
}
89
break
;
90
case
STATE_WAITING
:
91
autopilot_motors_on
=
false
;
92
autopilot_arming_delay_counter
= 0;
93
if
(
THROTTLE_STICK_DOWN
()) {
94
autopilot_arming_state
=
STATE_MOTORS_OFF_READY
;
95
}
96
break
;
97
case
STATE_MOTORS_OFF_READY
:
98
autopilot_motors_on
=
false
;
99
autopilot_arming_delay_counter
= 0;
100
if
(!
THROTTLE_STICK_DOWN
() &&
101
rc_attitude_sticks_centered
() &&
102
(
autopilot_mode
==
MODE_MANUAL
||
autopilot_unarmed_in_auto
)) {
103
autopilot_arming_state
=
STATE_ARMING
;
104
}
105
break
;
106
case
STATE_ARMING
:
107
autopilot_motors_on
=
false
;
108
autopilot_arming_delay_counter
++;
109
if
(
THROTTLE_STICK_DOWN
() ||
110
!
rc_attitude_sticks_centered
() ||
111
(
autopilot_mode
!=
MODE_MANUAL
&& !
autopilot_unarmed_in_auto
)) {
112
autopilot_arming_state
=
STATE_MOTORS_OFF_READY
;
113
}
else
if
(
autopilot_arming_delay_counter
>=
AUTOPILOT_ARMING_DELAY
) {
114
autopilot_arming_state
=
STATE_MOTORS_ON
;
115
}
116
break
;
117
case
STATE_MOTORS_ON
:
118
autopilot_motors_on
=
true
;
119
autopilot_arming_delay_counter
=
AUTOPILOT_ARMING_DELAY
;
120
if
(
THROTTLE_STICK_DOWN
()) {
121
autopilot_arming_state
=
STATE_UNARMING
;
122
}
123
break
;
124
case
STATE_UNARMING
:
125
autopilot_motors_on
=
true
;
126
autopilot_arming_delay_counter
--;
127
if
(!
THROTTLE_STICK_DOWN
()) {
128
autopilot_arming_state
=
STATE_MOTORS_ON
;
129
}
else
if
(
autopilot_arming_delay_counter
== 0) {
130
autopilot_arming_state
=
STATE_MOTORS_OFF_READY
;
131
if
(
autopilot_mode
!=
MODE_MANUAL
) {
132
autopilot_unarmed_in_auto
=
true
;
133
}
else
{
134
autopilot_unarmed_in_auto
=
false
;
135
}
136
}
137
break
;
138
default
:
139
break
;
140
}
141
}
142
143
}
144
145
#endif
/* AUTOPILOT_ARMING_THROTTLE_H */
AP_MODE_KILL
#define AP_MODE_KILL
Definition:
autopilot.h:36
STATE_ARMING
Definition:
autopilot_arming_throttle.h:40
autopilot_arming_state
enum arming_throttle_state autopilot_arming_state
Definition:
autopilot_arming_throttle.h:45
autopilot_mode
uint8_t autopilot_mode
Definition:
autopilot.c:69
arming_throttle_state
arming_throttle_state
Definition:
autopilot_arming_throttle.h:36
autopilot_arming_set
static void autopilot_arming_set(bool motors_on)
Definition:
autopilot_arming_throttle.h:56
autopilot_arming_delay_counter
uint8_t autopilot_arming_delay_counter
Definition:
autopilot_arming_throttle.h:46
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.
Definition:
autopilot_arming_throttle.h:74
autopilot_motors_on
bool autopilot_motors_on
Definition:
autopilot.c:76
rc_attitude_sticks_centered
static bool rc_attitude_sticks_centered(void)
Definition:
autopilot_rc_helpers.h:55
STATE_WAITING
Definition:
autopilot_arming_throttle.h:38
THROTTLE_STICK_DOWN
#define THROTTLE_STICK_DOWN()
Definition:
autopilot_rc_helpers.h:40
STATE_MOTORS_OFF_READY
Definition:
autopilot_arming_throttle.h:39
AUTOPILOT_ARMING_DELAY
#define AUTOPILOT_ARMING_DELAY
Definition:
autopilot_arming_throttle.h:34
STATE_MOTORS_ON
Definition:
autopilot_arming_throttle.h:41
autopilot_rc_helpers.h
Some helper functions to check RC sticks.
uint8_t
unsigned char uint8_t
Definition:
types.h:14
STATE_UNINIT
Definition:
autopilot_arming_throttle.h:37
STATE_UNARMING
Definition:
autopilot_arming_throttle.h:42
autopilot_unarmed_in_auto
bool autopilot_unarmed_in_auto
Definition:
autopilot_arming_throttle.h:47
autopilot_arming_init
static void autopilot_arming_init(void)
Definition:
autopilot_arming_throttle.h:49
MODE_MANUAL
#define MODE_MANUAL
Default RC mode.
Definition:
autopilot.h:82
sw
airborne
firmwares
rotorcraft
autopilot_arming_throttle.h
Generated on Wed Aug 28 2019 16:28:57 for Paparazzi UAS by
1.8.8