Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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_t 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 #define WaypointAlt(_wp) (waypoints[_wp].a)
48 #define Height(_h) (_h + ground_alt)
49 
50 extern void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt);
51 
52 extern const uint8_t nb_waypoint;
53 extern struct point waypoints[];
56 extern float ground_alt; /* m */
57 
58 extern int32_t nav_utm_east0; /* m */
59 extern int32_t nav_utm_north0; /* m */
60 extern uint8_t nav_utm_zone0;
61 
62 
63 void compute_dist2_to_home(void);
64 unit_t nav_reset_reference( void ) __attribute__ ((unused));
65 unit_t nav_update_waypoints_alt( void ) __attribute__ ((unused));
67 
68 
69 #define NavSetGroundReferenceHere() ({ nav_reset_reference(); nav_update_waypoints_alt(); FALSE; })
70 
71 #define NavSetWaypointHere(_wp) ({ \
72  waypoints[_wp].x = stateGetPositionEnu_f()->x; \
73  waypoints[_wp].y = stateGetPositionEnu_f()->y; \
74  FALSE; \
75 })
76 
77 #endif /* COMMON_NAV_H */
float max_dist_from_home
Definition: common_nav.c:45
void compute_dist2_to_home(void)
Computes square distance to the HOME waypoint potentially sets too_far_from_home. ...
Definition: common_nav.c:50
const uint8_t nb_waypoint
Definition: navigation.c:47
float dist2_to_home
Definition: common_nav.c:32
float a
Definition: common_nav.h:42
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: navigation.c:57
void common_nav_periodic_task_4Hz(void)
Definition: common_nav.c:103
uint8_t nav_utm_zone0
Definition: common_nav.c:44
int32_t nav_utm_north0
Definition: common_nav.c:43
signed long int32_t
Definition: types.h:19
unit_t nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
Definition: navigation.c:269
struct point waypoints[]
Definition: navigation.c:48
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
float y
Definition: common_nav.h:41
void nav_move_waypoint(uint8_t wp_id, float utm_east, float utm_north, float alt)
Definition: common_nav.c:107
float dist2_to_wp
Definition: common_nav.c:33
unit_t nav_update_waypoints_alt(void)
Shift altitude of the waypoint according to a new ground altitude.
Definition: common_nav.c:95
float x
Definition: common_nav.h:40
bool_t too_far_from_home
Definition: common_nav.c:35
int32_t nav_utm_east0
Definition: common_nav.c:42