Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
autopilot.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2003 Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
30 #ifndef AUTOPILOT_H
31 #define AUTOPILOT_H
32 
33 #include <inttypes.h>
34 #include "std.h"
35 #include "mcu_periph/sys_time.h"
36 #include "estimator.h"
37 
38 #define THRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
39 
40 #define THRESHOLD1 THRESHOLD_MANUAL_PPRZ
41 #define THRESHOLD2 (MAX_PPRZ/2)
42 
43 
44 #define PPRZ_MODE_MANUAL 0
45 #define PPRZ_MODE_AUTO1 1
46 #define PPRZ_MODE_AUTO2 2
47 #define PPRZ_MODE_HOME 3
48 #define PPRZ_MODE_GPS_OUT_OF_ORDER 4
49 #define PPRZ_MODE_NB 5
50 
51 #define PPRZ_MODE_OF_PULSE(pprz) \
52  (pprz > THRESHOLD2 ? PPRZ_MODE_AUTO2 : \
53  (pprz > THRESHOLD1 ? PPRZ_MODE_AUTO1 : PPRZ_MODE_MANUAL))
54 
55 extern uint8_t pprz_mode;
56 extern bool_t kill_throttle;
57 
58 
59 // FIXME, move to control
60 #define LATERAL_MODE_MANUAL 0
61 #define LATERAL_MODE_ROLL_RATE 1
62 #define LATERAL_MODE_ROLL 2
63 #define LATERAL_MODE_COURSE 3
64 #define LATERAL_MODE_NB 4
65 extern uint8_t lateral_mode;
66 
67 #define STICK_PUSHED(pprz) (pprz < THRESHOLD1 || pprz > THRESHOLD2)
68 
69 #define FLOAT_OF_PPRZ(pprz, center, travel) ((float)pprz / (float)MAX_PPRZ * travel + center)
70 
71 #define THROTTLE_THRESHOLD_TAKEOFF (pprz_t)(MAX_PPRZ * 0.9)
72 
73 extern uint8_t vsupply;
74 extern float energy;
75 
76 extern bool_t launch;
77 
78 extern bool_t gps_lost;
79 
82 #define ModeUpdate(_mode, _value) ({ \
83  uint8_t new_mode = _value; \
84  (_mode != new_mode ? _mode = new_mode, TRUE : FALSE); \
85 })
86 
87 extern bool_t power_switch;
88 
89 #ifdef POWER_SWITCH_LED
90 #define autopilot_SetPowerSwitch(_x) { \
91  power_switch = _x; \
92  if (_x) LED_ON(POWER_SWITCH_LED) else LED_OFF(POWER_SWITCH_LED); \
93 }
94 #else // POWER_SWITCH_LED
95 #define autopilot_SetPowerSwitch(_x) { power_switch = _x; }
96 #endif // POWER_SWITCH_LED
97 
98 #define autopilot_ResetFlightTimeAndLaunch(_) { \
99  estimator_flight_time = 0; launch = FALSE; \
100 }
101 
102 
103 /* For backward compatibility with old airframe files */
104 #include "generated/airframe.h"
105 #ifndef CONTROL_RATE
106 #define CONTROL_RATE 20
107 #endif
108 
109 #endif /* AUTOPILOT_H */
uint8_t pprz_mode
Definition: main_ap.c:111
bool_t launch
Definition: sim_ap.c:41
uint8_t lateral_mode
Definition: main_ap.c:112
bool_t power_switch
Definition: main_ap.c:106
bool_t gps_lost
Definition: main_ap.c:140
Architecture independent timing functions.
bool_t kill_throttle
Definition: main_ap.c:120
unsigned char uint8_t
Definition: types.h:14
float energy
Fuel consumption (mAh) TODO: move to electrical subsystem.
Definition: main_ap.c:138
State estimation, fusioning sensors.
uint8_t vsupply
Supply voltage in deciVolt.
Definition: main_ap.c:128