-
Notifications
You must be signed in to change notification settings - Fork 459
/
types.h
336 lines (306 loc) · 8.68 KB
/
types.h
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
28
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#ifndef TYPES_H_
#define TYPES_H_
enum rc {
ROLL,
PITCH,
YAW,
THROTTLE,
AUX1,
AUX2,
AUX3,
AUX4,
AUX5,
AUX6,
AUX7,
AUX8
};
enum pid {
PIDROLL,
PIDPITCH,
PIDYAW,
PIDALT,
PIDPOS,
PIDPOSR,
PIDNAVR,
PIDLEVEL,
PIDMAG,
PIDVEL, // not used currently
PIDITEMS
};
enum box {
BOXARM,
#if ACC
BOXANGLE,
BOXHORIZON,
#endif
#if BARO && (!defined(SUPPRESS_BARO_ALTHOLD))
BOXBARO,
#endif
#ifdef VARIOMETER
BOXVARIO,
#endif
BOXMAG,
#if defined(HEADFREE)
BOXHEADFREE,
BOXHEADADJ, // acquire heading for HEADFREE mode
#endif
#if defined(SERVO_TILT) || defined(GIMBAL) || defined(SERVO_MIX_TILT)
BOXCAMSTAB,
#endif
#if defined(CAMTRIG)
BOXCAMTRIG,
#endif
#if GPS
BOXGPSHOME,
BOXGPSHOLD,
#endif
#if defined(FIXEDWING) || defined(HELICOPTER)
BOXPASSTHRU,
#endif
#if defined(BUZZER)
BOXBEEPERON,
#endif
#if defined(LED_FLASHER)
BOXLEDMAX, // we want maximum illumination
BOXLEDLOW, // low/no lights
#endif
#if defined(LANDING_LIGHTS_DDR)
BOXLLIGHTS, // enable landing lights at any altitude
#endif
#ifdef INFLIGHT_ACC_CALIBRATION
BOXCALIB,
#endif
#ifdef GOVERNOR_P
BOXGOV,
#endif
#ifdef OSD_SWITCH
BOXOSD,
#endif
#if GPS
BOXGPSNAV,
BOXLAND,
#endif
CHECKBOXITEMS
};
typedef struct {
int16_t accSmooth[3];
int16_t gyroData[3];
int16_t magADC[3];
int16_t gyroADC[3];
int16_t accADC[3];
} imu_t;
typedef struct {
uint8_t vbat; // battery voltage in 0.1V steps
uint16_t intPowerMeterSum;
uint16_t rssi; // range: [0;1023]
uint16_t amperage; // 1unit == 100mA
uint16_t watts; // 1unit == 1W
uint16_t vbatcells[VBAT_CELLS_NUM];
} analog_t;
typedef struct {
int32_t EstAlt; // in cm
int16_t vario; // variometer in cm/s
} alt_t;
typedef struct {
int16_t angle[2]; // absolute angle inclination in multiple of 0.1 degree 180 deg = 1800
int16_t heading; // variometer in cm/s
} att_t;
typedef struct {
uint8_t OK_TO_ARM :1 ;
uint8_t ARMED :1 ;
uint8_t ACC_CALIBRATED :1 ;
uint8_t ANGLE_MODE :1 ;
uint8_t HORIZON_MODE :1 ;
uint8_t MAG_MODE :1 ;
uint8_t BARO_MODE :1 ;
#ifdef HEADFREE
uint8_t HEADFREE_MODE :1 ;
#endif
#if defined(FIXEDWING) || defined(HELICOPTER)
uint8_t PASSTHRU_MODE :1 ;
#endif
uint8_t SMALL_ANGLES_25 :1 ;
#if MAG
uint8_t CALIBRATE_MAG :1 ;
#endif
#ifdef VARIOMETER
uint8_t VARIO_MODE :1;
#endif
uint8_t GPS_mode: 2; // 0-3 NONE,HOLD, HOME, NAV (see GPS_MODE_* defines
#if BARO || GPS
uint8_t THROTTLE_IGNORED : 1; // If it is 1 then ignore throttle stick movements in baro mode;
#endif
#if GPS
uint8_t GPS_FIX :1 ;
uint8_t GPS_FIX_HOME :1 ;
uint8_t GPS_BARO_MODE : 1; // This flag is used when GPS controls baro mode instead of user (it will replace rcOptions[BARO]
uint8_t GPS_head_set: 1; // it is 1 if the navigation engine got commands to control heading (SET_POI or SET_HEAD) CLEAR_HEAD will zero it
uint8_t LAND_COMPLETED: 1;
uint8_t LAND_IN_PROGRESS: 1;
#endif
} flags_struct_t;
typedef struct {
uint8_t currentSet;
int16_t accZero[3];
int16_t magZero[3];
uint16_t flashsum;
uint8_t checksum; // MUST BE ON LAST POSITION OF STRUCTURE !
} global_conf_t;
struct pid_ {
uint8_t P8;
uint8_t I8;
uint8_t D8;
};
struct servo_conf_ { // this is a generic way to configure a servo, every multi type with a servo should use it
int16_t min; // minimum value, must be more than 1020 with the current implementation
int16_t max; // maximum value, must be less than 2000 with the current implementation
int16_t middle; // default should be 1500
int8_t rate; // range [-100;+100] ; can be used to ajust a rate 0-100% and a direction
};
typedef struct {
pid_ pid[PIDITEMS];
uint8_t rcRate8;
uint8_t rcExpo8;
uint8_t rollPitchRate;
uint8_t yawRate;
uint8_t dynThrPID;
uint8_t thrMid8;
uint8_t thrExpo8;
int16_t angleTrim[2];
#if defined(EXTENDED_AUX_STATES)
uint32_t activate[CHECKBOXITEMS]; //Extended aux states define six different aux state for each aux channel
#else
uint16_t activate[CHECKBOXITEMS];
#endif
uint8_t powerTrigger1;
#if MAG
int16_t mag_declination;
#endif
servo_conf_ servoConf[8];
#if defined(GYRO_SMOOTHING)
uint8_t Smoothing[3];
#endif
#if defined (FAILSAFE)
int16_t failsafe_throttle;
#endif
#ifdef VBAT
uint8_t vbatscale;
uint8_t vbatlevel_warn1;
uint8_t vbatlevel_warn2;
uint8_t vbatlevel_crit;
#endif
#ifdef POWERMETER
uint8_t pint2ma;
#endif
#ifdef POWERMETER_HARD
uint16_t psensornull;
#endif
#ifdef MMGYRO
uint8_t mmgyro;
#endif
#ifdef ARMEDTIMEWARNING
uint16_t armedtimewarning;
#endif
int16_t minthrottle;
#ifdef GOVERNOR_P
int16_t governorP;
int16_t governorD;
#endif
#ifdef YAW_COLL_PRECOMP
uint8_t yawCollPrecomp;
uint16_t yawCollPrecompDeadband;
#endif
uint8_t checksum; // MUST BE ON LAST POSITION OF CONF STRUCTURE !
} conf_t;
#ifdef LOG_PERMANENT
typedef struct {
uint16_t arm; // #arm events
uint16_t disarm; // #disarm events
uint16_t start; // #powercycle/reset/initialize events
uint32_t armed_time ; // copy of armedTime @ disarm
uint32_t lifetime; // sum (armed) lifetime in seconds
uint16_t failsafe; // #failsafe state @ disarm
uint16_t i2c; // #i2c errs state @ disarm
uint8_t running; // toggle on arm & disarm to monitor for clean shutdown vs. powercut
uint8_t checksum; // MUST BE ON LAST POSITION OF CONF STRUCTURE !
} plog_t;
#endif
#if GPS
// TODO: cross check with I2C gps and add relevant defines
//This is the mode what is selected via the remote (NONE, HOLD, RTH and NAV (NAV-> exectute mission)
enum gpsmode {
GPS_MODE_NONE = 0,
GPS_MODE_HOLD,
GPS_MODE_RTH,
GPS_MODE_NAV
};
enum navstate {
NAV_STATE_NONE = 0,
NAV_STATE_RTH_START,
NAV_STATE_RTH_ENROUTE,
NAV_STATE_HOLD_INFINIT,
NAV_STATE_HOLD_TIMED,
NAV_STATE_WP_ENROUTE,
NAV_STATE_PROCESS_NEXT,
NAV_STATE_DO_JUMP,
NAV_STATE_LAND_START,
NAV_STATE_LAND_IN_PROGRESS,
NAV_STATE_LANDED,
NAV_STATE_LAND_SETTLE,
NAV_STATE_LAND_START_DESCENT
};
enum naverror {
NAV_ERROR_NONE = 0, //All systems clear
NAV_ERROR_TOOFAR, //Next waypoint distance is more than safety distance
NAV_ERROR_SPOILED_GPS, //GPS reception is compromised - Nav paused - copter is adrift !
NAV_ERROR_WP_CRC, //CRC error reading WP data from EEPROM - Nav stopped
NAV_ERROR_FINISH, //End flag detected, navigation finished
NAV_ERROR_TIMEWAIT, //Waiting for poshold timer
NAV_ERROR_INVALID_JUMP, //Invalid jump target detected, aborting
NAV_ERROR_INVALID_DATA, //Invalid mission step action code, aborting, copter is adrift
NAV_ERROR_WAIT_FOR_RTH_ALT, //Waiting to reach RTH Altitude
NAV_ERROR_GPS_FIX_LOST, //Gps fix lost, aborting mission
NAV_ERROR_DISARMED, //NAV engine disabled due disarm
NAV_ERROR_LANDING //Landing
};
typedef struct {
uint8_t number; //Waypoint number
int32_t pos[2]; //GPS position
uint8_t action; //Action to follow
int16_t parameter1; //Parameter for the action
int16_t parameter2; //Parameter for the action
int16_t parameter3; //Parameter for the action
uint32_t altitude; //Altitude in cm (AGL)
uint8_t flag; //flags the last wp and other fancy things that are not yet defined
uint8_t checksum; //this must be at the last position
} mission_step_struct;
typedef struct {
//Don't forget to change the reply size in GUI when change this struct;
// on/off flags
// First byte
uint8_t filtering : 1;
uint8_t lead_filter : 1;
uint8_t dont_reset_home_at_arm : 1;
uint8_t nav_controls_heading : 1;
uint8_t nav_tail_first : 1;
uint8_t nav_rth_takeoff_heading : 1;
uint8_t slow_nav : 1;
uint8_t wait_for_rth_alt : 1;
// Second byte
uint8_t ignore_throttle: 1; // Disable stick controls during mission and RTH
uint8_t takeover_baro: 1;
uint16_t wp_radius; // in cm
uint16_t safe_wp_distance; // in meter
uint16_t nav_max_altitude; // in meter
uint16_t nav_speed_max; // in cm/s
uint16_t nav_speed_min; // in cm/s
uint8_t crosstrack_gain; // * 100 (0-2.56)
uint16_t nav_bank_max; // degree * 100; (3000 default)
uint16_t rth_altitude; // in meter
uint8_t land_speed; // between 50 and 255 (100 approx = 50cm/sec)
uint16_t fence; // fence control in meters
uint8_t max_wp_number;
uint8_t checksum;
} gps_conf_struct;
#endif
#endif /* TYPES_H_ */