Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 Pascal Brisset, Antoine Drouin
3  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
4  * Copyright (C) 2016-2017 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
20  * <http://www.gnu.org/licenses/>.
21  */
22 
32 #ifndef AUTOPILOT_H
33 #define AUTOPILOT_H
34 
35 #include "std.h"
36 #include "paparazzi.h"
37 #include "generated/airframe.h"
38 #include "state.h"
39 #include "autopilot_utils.h"
40 
41 // include firmware specific header
42 #include "autopilot_firmware.h"
43 
44 // include static or generated autopilot
45 // static version by default
46 #ifndef USE_GENERATED_AUTOPILOT
47 #define USE_GENERATED_AUTOPILOT FALSE
48 #endif
49 
50 #if USE_GENERATED_AUTOPILOT
51 #include "autopilot_generated.h"
52 #else
53 #include "autopilot_static.h"
54 #endif
55 
63  bool motors_on;
65  bool in_flight;
66  bool launch;
67  bool use_rc;
68  bool power_switch;
71 };
72 
73 
76 extern struct pprz_autopilot autopilot;
77 
80 extern void autopilot_init(void);
81 
84 extern void autopilot_periodic(void);
85 
88 extern void autopilot_event(void);
89 
92 extern void autopilot_on_rc_frame(void);
93 
99 extern bool autopilot_set_mode(uint8_t new_autopilot_mode);
100 
103 extern void autopilot_SetModeHandler(float new_autopilot_mode);
104 
109 extern uint8_t autopilot_get_mode(void);
110 
114 extern void autopilot_reset_flight_time(void);
115 #define autopilot_ResetFlightTimeAndLaunch(_) autopilot_reset_flight_time()
116 
122 extern void autopilot_set_motors_on(bool motors_on);
123 
128 extern bool autopilot_get_motors_on(void);
129 
135 extern void autopilot_set_kill_throttle(bool kill);
136 #define autopilot_KillThrottle(_kill) autopilot_set_kill_throttle(_kill)
137 
142 extern bool autopilot_throttle_killed(void);
143 
148 extern void autopilot_check_in_flight(bool motors_on);
149 
154 extern void autopilot_set_in_flight(bool in_flight);
155 
160 extern bool autopilot_in_flight(void);
161 
165 extern void autopilot_reset_in_flight_counter(void);
166 
173 extern void autopilot_set_power_switch(bool power_switch);
174 #define autopilot_SetPowerSwitch(_ps) autopilot_set_power_switch(_ps)
175 
180 extern void autopilot_store_settings(void);
181 #define autopilot_StoreSettings(_) autopilot_store_settings()
182 
187 extern void autopilot_clear_settings(void);
188 #define autopilot_ClearSettings(_) autopilot_clear_settings()
189 
192 extern void autopilot_send_version(void);
193 
196 extern void autopilot_send_mode(void);
197 
198 #endif /* AUTOPILOT_H */
199 
unsigned short uint16_t
Definition: types.h:16
bool launch
request launch
Definition: autopilot.h:66
bool use_rc
enable/disable RC input
Definition: autopilot.h:67
void autopilot_init(void)
Autopilot initialization function.
Definition: autopilot.c:91
bool in_flight
in flight status
Definition: autopilot.h:65
void autopilot_set_in_flight(bool in_flight)
Set in flight status.
Definition: autopilot.c:246
uint16_t flight_time
flight time in seconds
Definition: autopilot.h:61
bool autopilot_set_mode(uint8_t new_autopilot_mode)
Set new autopilot mode.
Definition: autopilot.c:160
bool autopilot_throttle_killed(void)
Get kill status.
Definition: autopilot.c:229
void autopilot_check_in_flight(bool motors_on)
Check if airframe is in flight.
Definition: autopilot.c:237
void autopilot_store_settings(void)
Store marked settings in flash Try to make sure that we don't write to flash while flying Also provid...
Definition: autopilot.c:277
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
void autopilot_reset_in_flight_counter(void)
reset in_flight counter actual implementation is firmware dependent
Definition: autopilot.c:242
bool detect_ground_once
enable automatic detection of ground (one shot)
Definition: autopilot.h:70
bool power_switch
enable/disable power from power switch (if any)
Definition: autopilot.h:68
uint8_t mode_auto2
FIXME hide this in a private part ?
Definition: autopilot.h:60
void autopilot_reset_flight_time(void)
Reset flight time and launch status Also provide macro for dl_setting backward compatibility.
Definition: autopilot.c:190
void autopilot_SetModeHandler(float new_autopilot_mode)
Handler for setter function with dl_setting.
Definition: autopilot.c:172
uint8_t arming_status
Definition: autopilot.h:62
PPRZ Autopilot structure definition.
Definition: autopilot.h:58
void autopilot_periodic(void)
Autopilot periodic call at PERIODIC_FREQUENCY.
Definition: autopilot.c:134
uint8_t autopilot_get_mode(void)
Get autopilot mode.
Definition: autopilot.c:183
bool motors_on
arming status
Definition: autopilot.h:63
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
void autopilot_set_power_switch(bool power_switch)
Set power switch state This will actually enable the switch if POWER_SWITCH_GPIO is defined Also prov...
Definition: autopilot.c:263
void autopilot_send_mode(void)
Report autopilot mode on default downlink channel.
Definition: autopilot.c:305
void autopilot_set_motors_on(bool motors_on)
Start or stop motors May have no effect if motors has auto-start based on throttle setpoint...
Definition: autopilot.c:199
void autopilot_set_kill_throttle(bool kill)
Enable or disable motor control from autopilot Also provide macro for dl_setting backward compatibili...
Definition: autopilot.c:218
bool autopilot_get_motors_on(void)
Get motor status.
Definition: autopilot.c:211
void autopilot_on_rc_frame(void)
Autopilot RC input event hadler.
Definition: autopilot.c:149
void autopilot_send_version(void)
Report autopilot version on default downlink channel.
Definition: autopilot.c:297
bool kill_throttle
allow autopilot to use throttle
Definition: autopilot.h:64
bool ground_detected
automatic detection of landing
Definition: autopilot.h:69
uint8_t mode
current autopilot mode
Definition: autopilot.h:59
void autopilot_event(void)
Autopilot event check function.
Definition: autopilot.c:145
bool autopilot_in_flight(void)
Get in flight status.
Definition: autopilot.c:256
void autopilot_clear_settings(void)
Clear marked settings in flash try to make sure that we don't write to flash while flying Also provid...
Definition: autopilot.c:287