Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 #ifdef GEOFENCE_DATALINK_LOST_TIME
36 /*
37  * from the airfame config file:
38  * go to HOME mode if datalink lost for GEOFENCE_DATALINK_LOST_TIME
39  */
40 static inline bool datalink_lost(void)
41 {
42  return (datalink_time > GEOFENCE_DATALINK_LOST_TIME);
43 }
44 #else // dont trigger this exception
45 static inline bool datalink_lost(void)
46 {
47  return false;
48 }
49 #endif /* GEOFENCE_DATALINK_LOST_TIME */
50 
51 
52 #if defined GEOFENCE_MAX_ALTITUDE || defined GEOFENCE_MAX_HEIGHT// user defined geofence_max_altitude (or AGL) in the flight plan
53 static inline bool higher_than_max_altitude(void)
54 {
55  bool above_max_alt = false;
56 #ifdef GEOFENCE_MAX_ALTITUDE
57  above_max_alt = above_max_alt || (GetPosAlt() > GEOFENCE_MAX_ALTITUDE);
58 #endif /* GEOFENCE_MAX_ALTITUDE */
59 
60 #ifdef GEOFENCE_MAX_HEIGHT
61  above_max_alt = above_max_alt || (GetPosAlt() > ( GetAltRef() + GEOFENCE_MAX_HEIGHT));
62 #endif /* GEOFENCE_MAX_HEIGHT */
63  return above_max_alt;
64 }
65 #else // we dont have max altitude specified, so the condition is never true
66 static inline bool higher_than_max_altitude(void)
67 {
68  return false;
69 }
70 #endif /* GEOFENCE_MAX_ALTITUDE */
#define GetPosAlt()
Get current altitude above MSL.
Definition: nav.h:232
#define GetAltRef()
Get current altitude reference for local coordinates.
Definition: nav.h:241
static bool higher_than_max_altitude(void)
Definition: nav_geofence.h:66
static bool datalink_lost(void)
Definition: nav_geofence.h:45