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
common_nav.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2009 ENAC, Pascal Brisset, Antoine Drouin
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 
27 #ifndef COMMON_NAV_H
28 #define COMMON_NAV_H
29 
30 #include "std.h"
31 #include "state.h"
33 
34 extern float max_dist_from_home;
35 extern float dist2_to_home;
36 extern float dist2_to_wp;
37 extern bool too_far_from_home;
38 
39 struct point {
40  float x;
41  float y;
42  float a;
43 };
44 
45 #define WaypointX(_wp) (waypoints[_wp].x)
46 #define WaypointY(_wp) (waypoints[_wp].y)
47 
48 #define WaypointAlt(_wp) (waypoints[_wp].a)
49 #define Height(_h) (_h + ground_alt)
50 
51 extern void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt);
52 
53 extern const uint8_t nb_waypoint;
54 extern struct point waypoints[];
58 extern float ground_alt;
59 
60 extern int32_t nav_utm_east0; /* m */
61 extern int32_t nav_utm_north0; /* m */
62 extern uint8_t nav_utm_zone0;
63 
64 
65 extern void compute_dist2_to_home(void);
66 extern void nav_reset_utm_zone(void);
67 extern void nav_reset_reference(void) __attribute__((unused));
68 extern void nav_reset_alt(void) __attribute__((unused));
69 extern void nav_update_waypoints_alt(void) __attribute__((unused));
70 extern void common_nav_periodic_task_4Hz(void);
71 
72 
73 #define NavSetGroundReferenceHere() ({ nav_reset_reference(); nav_update_waypoints_alt(); false; })
74 
75 #define NavSetAltitudeReferenceHere() ({ nav_reset_alt(); nav_update_waypoints_alt(); false; })
76 
77 #define NavSetWaypointHere(_wp) ({ \
78  waypoints[_wp].x = stateGetPositionEnu_f()->x; \
79  waypoints[_wp].y = stateGetPositionEnu_f()->y; \
80  false; \
81  })
82 
83 #define NavSetWaypointPosAndAltHere(_wp) ({ \
84  waypoints[_wp].x = stateGetPositionEnu_f()->x; \
85  waypoints[_wp].y = stateGetPositionEnu_f()->y; \
86  waypoints[_wp].a = stateGetPositionEnu_f()->z + ground_alt; \
87  false; \
88  })
89 
90 #endif /* COMMON_NAV_H */
float max_dist_from_home
Definition: navigation.c:79
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
Definition: navigation.c:473
const uint8_t nb_waypoint
Definition: common_nav.c:37
float dist2_to_home
squared distance to home waypoint
Definition: navigation.c:82
float x
Definition: common_nav.h:40
void nav_update_waypoints_alt(void)
Shift altitude of the waypoint according to a new ground altitude.
Definition: common_nav.c:109
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
Definition: navigation.c:348
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:40
void common_nav_periodic_task_4Hz(void)
Definition: common_nav.c:117
void nav_reset_alt(void)
Reset the altitude reference to the current GPS alt.
Definition: navigation.c:355
float y
Definition: common_nav.h:41
uint8_t nav_utm_zone0
Definition: common_nav.c:44
void nav_reset_utm_zone(void)
Reset the UTM zone to current GPS fix.
Definition: common_nav.c:66
int32_t nav_utm_north0
Definition: common_nav.c:43
signed long int32_t
Definition: types.h:19
struct point waypoints[]
Definition: common_nav.c:38
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
Common flight_plan functions shared between fixedwing and rotorcraft.
float a
Definition: common_nav.h:42
void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt)
Move a waypoint to given UTM coordinates.
Definition: common_nav.c:128
bool too_far_from_home
Definition: navigation.c:83
float dist2_to_wp
squared distance to next waypoint
Definition: navigation.c:85
int32_t nav_utm_east0
Definition: common_nav.c:42