Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 extern void nav_move_waypoint_enu(uint8_t wp_id, float x, float y, float alt);
53 extern void nav_move_waypoint_point(uint8_t wp_id, struct point *p);
54 extern void nav_send_waypoint(uint8_t wp_id);
55 
56 extern const uint8_t nb_waypoint;
57 extern struct point waypoints[];
61 extern float ground_alt;
62 
63 extern int32_t nav_utm_east0; /* m */
64 extern int32_t nav_utm_north0; /* m */
65 extern uint8_t nav_utm_zone0;
66 
67 
68 extern void compute_dist2_to_home(void);
69 extern void nav_reset_utm_zone(void);
70 extern void nav_reset_reference(void) __attribute__((unused));
71 extern void nav_reset_alt(void) __attribute__((unused));
72 extern void nav_update_waypoints_alt(void) __attribute__((unused));
73 extern void common_nav_periodic_task(void);
74 extern float get_time_to_home(void); /* estimated time to home point in seconds */
75 
76 
77 #define NavSetGroundReferenceHere() ({ nav_reset_reference(); nav_update_waypoints_alt(); false; })
78 
79 #define NavSetAltitudeReferenceHere() ({ nav_reset_alt(); nav_update_waypoints_alt(); false; })
80 
81 #define NavSetWaypointHere(_wp) ({ \
82  waypoints[_wp].x = stateGetPositionEnu_f()->x; \
83  waypoints[_wp].y = stateGetPositionEnu_f()->y; \
84  false; \
85  })
86 
87 #define NavSetWaypointPosAndAltHere(_wp) ({ \
88  waypoints[_wp].x = stateGetPositionEnu_f()->x; \
89  waypoints[_wp].y = stateGetPositionEnu_f()->y; \
90  waypoints[_wp].a = stateGetPositionEnu_f()->z + ground_alt; \
91  false; \
92  })
93 
94 #endif /* COMMON_NAV_H */
point::a
float a
Definition: common_nav.h:42
nav_utm_zone0
uint8_t nav_utm_zone0
Definition: common_nav.c:45
common_flight_plan.h
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
get_time_to_home
float get_time_to_home(void)
Compute time to home use wind and airspeed when available.
Definition: common_nav.c:66
common_nav_periodic_task
void common_nav_periodic_task(void)
Definition: common_nav.c:153
nav_reset_reference
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
Definition: navigation.c:382
point
Definition: common_nav.h:39
max_dist_from_home
float max_dist_from_home
Definition: navigation.c:88
nav_reset_alt
void nav_reset_alt(void)
Reset the altitude reference to the current GPS alt.
Definition: navigation.c:389
nav_utm_east0
int32_t nav_utm_east0
Definition: common_nav.c:43
nav_move_waypoint_enu
void nav_move_waypoint_enu(uint8_t wp_id, float x, float y, float alt)
Move a waypoint in local frame.
Definition: common_nav.c:184
std.h
dist2_to_home
float dist2_to_home
squared distance to home waypoint
Definition: navigation.c:91
nav_utm_north0
int32_t nav_utm_north0
Definition: common_nav.c:44
nav_update_waypoints_alt
void nav_update_waypoints_alt(void)
Shift altitude of the waypoint according to a new ground altitude.
Definition: common_nav.c:145
nav_reset_utm_zone
void nav_reset_utm_zone(void)
Reset the UTM zone to current GPS fix.
Definition: common_nav.c:102
point::x
float x
Definition: common_nav.h:40
dist2_to_wp
float dist2_to_wp
squared distance to next waypoint
Definition: navigation.c:94
waypoints
struct point waypoints[]
Definition: common_nav.c:39
int32_t
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
compute_dist2_to_home
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
Definition: navigation.c:483
nav_move_waypoint_point
void nav_move_waypoint_point(uint8_t wp_id, struct point *p)
Move a waypoint from point structure (local frame).
Definition: common_nav.c:202
too_far_from_home
bool too_far_from_home
Definition: navigation.c:92
point::y
float y
Definition: common_nav.h:41
nav_move_waypoint
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:164
nb_waypoint
const uint8_t nb_waypoint
Definition: common_nav.c:38
state.h
ground_alt
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:41
nav_send_waypoint
void nav_send_waypoint(uint8_t wp_id)
Send a waypoint throught default telemetry channel.
Definition: common_nav.c:210
p
static float p[2][2]
Definition: ins_alt_float.c:257