Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nav_geofence.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 216 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 
34 #include <stdbool.h>
35 
36 #ifdef GEOFENCE_DATALINK_LOST_TIME
37 /*
38  * from the airfame config file:
39  * go to HOME mode if datalink lost for GEOFENCE_DATALINK_LOST_TIME
40  */
41 static inline bool datalink_lost(void)
42 {
43  return (datalink_time > GEOFENCE_DATALINK_LOST_TIME);
44 }
45 #else // dont trigger this exception
46 static inline bool datalink_lost(void)
47 {
48  return false;
49 }
50 #endif /* GEOFENCE_DATALINK_LOST_TIME */
51 
52 
53 #if defined GEOFENCE_MAX_ALTITUDE || defined GEOFENCE_MAX_HEIGHT// user defined geofence_max_altitude (or AGL) in the flight plan
54 static inline bool higher_than_max_altitude(void)
55 {
56  bool above_max_alt = false;
57 #ifdef GEOFENCE_MAX_ALTITUDE
58  above_max_alt = above_max_alt || (GetPosAlt() > GEOFENCE_MAX_ALTITUDE);
59 #endif /* GEOFENCE_MAX_ALTITUDE */
60 
61 #ifdef GEOFENCE_MAX_HEIGHT
62  above_max_alt = above_max_alt || (GetPosAlt() > ( GetAltRef() + GEOFENCE_MAX_HEIGHT));
63 #endif /* GEOFENCE_MAX_HEIGHT */
64  return above_max_alt;
65 }
66 #else // we dont have max altitude specified, so the condition is never true
67 static inline bool higher_than_max_altitude(void)
68 {
69  return false;
70 }
71 #endif /* GEOFENCE_MAX_ALTITUDE */
uint16_t datalink_time
Definition: sim_ap.c:42