Constants.h 6.73 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//    Copyright (C) 2017, ETH Zurich, D-ITET, Paul Beuchat
//
//    This file is part of D-FaLL-System.
//    
//    D-FaLL-System is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//    
//    D-FaLL-System is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//    
//    You should have received a copy of the GNU General Public License
//    along with D-FaLL-System.  If not, see <http://www.gnu.org/licenses/>.
//    
//
//    ----------------------------------------------------------------------------------
//    DDDD        FFFFF        L     L           SSSS  Y   Y   SSSS  TTTTT  EEEEE  M   M
//    D   D       F      aaa   L     L          S       Y Y   S        T    E      MM MM
//    D   D  ---  FFFF  a   a  L     L     ---   SSS     Y     SSS     T    EEE    M M M
//    D   D       F     a  aa  L     L              S    Y        S    T    E      M   M
//    DDDD        F      aa a  LLLL  LLLL       SSSS     Y    SSSS     T    EEEEE  M   M
//
//
//    DESCRIPTION:
28
//    Constants that are used across multiple files
29
30
31
32
//
//    ----------------------------------------------------------------------------------


33
34
35



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//    ----------------------------------------------------------------------------------
//    U   U
//    U   U
//    U   U
//    U   U
//     UUU
//    ----------------------------------------------------------------------------------


// Conversions between degrees and radians
#define RAD2DEG 180.0/PI
#define DEG2RAD PI/180.0

// PI
#define PI 3.141592653589




55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//    ----------------------------------------------------------------------------------
//    
//    
//    
//    
//    
//    ----------------------------------------------------------------------------------



// The types, i.e., agent or coordinator
#define TYPE_INVALID      -1
#define TYPE_COORDINATOR   1
#define TYPE_AGENT         2





75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//    ----------------------------------------------------------------------------------
//    
//    
//    
//    
//    
//    ----------------------------------------------------------------------------------



// These constants define the modes that can be used for controller this is
// running on-board the Crazyflie 2.0.
// Therefore, the constants defined here need to be in agreement with those
// defined in the firmware running on-board the Crazyflie 2.0.
// The following is a short description about each mode:
//
// CF_COMMAND_TYPE_MOTORS
//     In this mode the Crazyflie will apply the requested 16-bit per motor
//     command directly to each of the motors
//
// CF_COMMAND_TYPE_RATE
//     In this mode the Crazyflie will apply the requested 16-bit per motor
//     command directly to each of the motors, and additionally request the
//     body frame roll, pitch, and yaw angular rates from the PID rate
//     controllers implemented in the Crazyflie 2.0 firmware.
//
// CF_COMMAND_TYPE_ANGLE
//     In this mode the Crazyflie will apply the requested 16-bit per motor
//     command directly to each of the motors, and additionally request the
//     body frame roll, pitch, and yaw angles from the PID attitude
//     controllers implemented in the Crazyflie 2.0 firmware.
106
107
108
109
#define CF_COMMAND_TYPE_MOTORS 6
#define CF_COMMAND_TYPE_RATE   7
#define CF_COMMAND_TYPE_ANGLE  8

110
111
112
113
114
115
116
117
118
119
120
121




//    ----------------------------------------------------------------------------------
//    
//    
//    
//    
//    
//    ----------------------------------------------------------------------------------

122
// Types of controllers being used:
123
#define DEFAULT_CONTROLLER      1
124
125
126
127
128
129
#define DEMO_CONTROLLER      2
#define STUDENT_CONTROLLER   3
#define MPC_CONTROLLER       4
#define REMOTE_CONTROLLER    5
#define TUNING_CONTROLLER    6
#define PICKER_CONTROLLER    7
130
#define TEMPLATE_CONTROLLER  8
131
132
133

// The constants that "command" changes in the
// operation state of this agent
134
#define CMD_USE_DEFAULT_CONTROLLER   1
135
136
137
138
139
140
#define CMD_USE_DEMO_CONTROLLER      2
#define CMD_USE_STUDENT_CONTROLLER   3
#define CMD_USE_MPC_CONTROLLER       4
#define CMD_USE_REMOTE_CONTROLLER    5
#define CMD_USE_TUNING_CONTROLLER    6
#define CMD_USE_PICKER_CONTROLLER    7
141
#define CMD_USE_TEMPLATE_CONTROLLER  8
142
143
144
145
146
147


#define CMD_CRAZYFLY_TAKE_OFF        11
#define CMD_CRAZYFLY_LAND            12
#define CMD_CRAZYFLY_MOTORS_OFF      13

beuchatp's avatar
beuchatp committed
148
149
#define CMD_USE_TESTMOTORS_CONTROLLER 21

150
// Flying states
151
152
153
154
155
#define STATE_MOTORS_OFF     1
#define STATE_TAKE_OFF       2
#define STATE_FLYING         3
#define STATE_LAND           4
#define STATE_UNAVAILABLE    5
156
157
158
159
160
161
162
163
164
165
166
167


// Commands for CrazyRadio
#define CMD_RECONNECT  0
#define CMD_DISCONNECT 1


// CrazyRadio states:
#define CRAZY_RADIO_STATE_CONNECTED      0
#define CRAZY_RADIO_STATE_CONNECTING     1
#define CRAZY_RADIO_STATE_DISCONNECTED   2

168
169
170



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//    ----------------------------------------------------------------------------------
//    BBBB     A    TTTTT  TTTTT  EEEEE  RRRR   Y   Y
//    B   B   A A     T      T    E      R   R   Y Y
//    BBBB   A   A    T      T    EEE    RRRR     Y
//    B   B  AAAAA    T      T    E      R   R    Y
//    BBBB   A   A    T      T    EEEEE  R   R    Y
//    ----------------------------------------------------------------------------------

// Battery levels
#define BATTERY_LEVEL_000            0
#define BATTERY_LEVEL_010            1
#define BATTERY_LEVEL_020            2
#define BATTERY_LEVEL_030            3
#define BATTERY_LEVEL_040            4
#define BATTERY_LEVEL_050            5
#define BATTERY_LEVEL_060            6
#define BATTERY_LEVEL_070            7
#define BATTERY_LEVEL_080            8
#define BATTERY_LEVEL_090            9
#define BATTERY_LEVEL_100           10
#define BATTERY_LEVEL_UNAVAILABLE   -1

// Battery states
#define BATTERY_STATE_NORMAL         0
#define BATTERY_STATE_LOW            1





//    ----------------------------------------------------------------------------------
//    Y   Y    A    M   M  L
//     Y Y    A A   MM MM  L
//      Y    A   A  M M M  L
//      Y    AAAAA  M   M  L
//      Y    A   A  M   M  LLLLL
//    ----------------------------------------------------------------------------------

// For where to load the yaml file from
#define LOAD_YAML_FROM_AGENT             1
#define LOAD_YAML_FROM_COORDINATOR       2
212
213
214
215
216
217






218
219
220
221
222
223
224
//    ----------------------------------------------------------------------------------
//    
//    
//    
//    
//    
//    ----------------------------------------------------------------------------------
225

226
// For standard buttons in the GUI
227
#define REQUEST_DEFAULT_SETPOINT_BUTTON_ID    100