Paparazzi UAS  v7.0_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)
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 */
Common flight_plan functions shared between fixedwing and rotorcraft.
float get_time_to_home(void)
Compute time to home use wind and airspeed when available.
Definition: common_nav.c:66
void nav_reset_reference(void)
Reset the geographic reference to the current GPS fix.
Definition: navigation.c:234
void nav_send_waypoint(uint8_t wp_id)
Send a waypoint throught default telemetry channel.
Definition: common_nav.c:210
float max_dist_from_home
Definition: navigation.c:53
float dist2_to_wp
Definition: common_nav.c:34
void nav_reset_alt(void)
Reset the altitude reference to the current GPS alt.
Definition: navigation.c:241
int32_t nav_utm_east0
Definition: common_nav.c:43
bool too_far_from_home
Definition: common_nav.c:36
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
void compute_dist2_to_home(void)
Computes squared distance to the HOME waypoint potentially sets too_far_from_home.
Definition: navigation.c:326
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
float y
Definition: common_nav.h:41
uint8_t nav_utm_zone0
Definition: common_nav.c:45
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:41
float a
Definition: common_nav.h:42
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
struct point waypoints[]
Definition: common_nav.c:39
float x
Definition: common_nav.h:40
void nav_reset_utm_zone(void)
Reset the UTM zone to current GPS fix.
Definition: common_nav.c:102
float dist2_to_home
Definition: common_nav.c:33
const uint8_t nb_waypoint
Definition: common_nav.c:38
int32_t nav_utm_north0
Definition: common_nav.c:44
void common_nav_periodic_task(void)
Definition: common_nav.c:153
void nav_update_waypoints_alt(void)
Shift altitude of the waypoint according to a new ground altitude.
Definition: common_nav.c:145
static float p[2][2]
API to get/set the generic vehicle states.
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98