Paparazzi UAS  v6.0_unstable-94-gda5b527-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
waypoints.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Felix Ruess <felix.ruess@gmail.com>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
26 #ifndef WAYPOINTS_H
27 #define WAYPOINTS_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include "std.h"
34 #include "math/pprz_geodetic_int.h"
36 
37 #define WP_FLAG_GLOBAL 0
38 #define WP_FLAG_ENU_I 1
39 #define WP_FLAG_ENU_F 2
40 #define WP_FLAG_LLA_I 3
41 
42 struct Waypoint {
44  struct EnuCoor_i enu_i;
45  struct EnuCoor_f enu_f;
46  struct LlaCoor_i lla;
47 };
48 
49 extern const uint8_t nb_waypoint;
51 extern struct Waypoint waypoints[];
52 
53 /* aliases for backwards compatibilty */
54 #define WaypointX(_wp) waypoint_get_x(_wp)
55 #define WaypointY(_wp) waypoint_get_y(_wp)
56 #define WaypointAlt(_wp) waypoint_get_alt(_wp)
57 #define Height(_h) (_h)
58 
59 extern void waypoints_init(void);
60 
61 extern bool waypoint_is_global(uint8_t wp_id);
62 extern void waypoint_set_global_flag(uint8_t wp_id);
63 extern void waypoint_clear_global_flag(uint8_t wp_id);
64 
65 
66 /*
67  * Get waypoint coordinates.
68  */
70 extern float waypoint_get_x(uint8_t wp_id);
72 extern float waypoint_get_y(uint8_t wp_id);
74 extern float waypoint_get_alt(uint8_t wp_id);
75 
83 extern struct LlaCoor_i *waypoint_get_lla(uint8_t wp_id);
84 
85 
86 /*
87  * Set waypoint coordinates.
88  */
90 extern void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu);
92 extern void waypoint_set_alt(uint8_t wp_id, float alt);
93 
95 extern void waypoint_set_here(uint8_t wp_id);
97 extern void waypoint_set_here_2d(uint8_t wp_id);
98 
99 /* functions to set fixedpoint representation directly */
100 extern void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu);
101 extern void waypoint_set_xy_i(uint8_t wp_id, int32_t x, int32_t y);
102 extern void waypoint_set_alt_i(uint8_t wp_id, int32_t alt);
103 extern void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla);
104 
106 extern void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla);
107 
109 extern void waypoint_copy(uint8_t wp_dest, uint8_t wp_src);
110 extern void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src);
111 
112 
113 /*
114  * Move waypoints.
115  * Basically sets the coordinates and sends the WP_MOVED telemetry message as ack.
116  */
117 extern void waypoint_move_here_2d(uint8_t wp_id);
118 extern void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos);
119 extern void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y);
120 extern void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla);
121 
122 
123 /*
124  * Global(LLA) / Local(ENU) conversions.
125  */
126 
128 extern void waypoint_globalize(uint8_t wp_id);
129 
131 extern void waypoint_localize(uint8_t wp_id);
133 extern void waypoints_localize_all(void);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* WAYPOINTS_H */
bool waypoint_is_global(uint8_t wp_id)
Definition: waypoints.c:55
float waypoint_get_y(uint8_t wp_id)
Get Y/North coordinate of waypoint in meters.
Definition: waypoints.c:85
void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:179
struct EnuCoor_f enu_f
Definition: waypoints.h:45
vector in East North Up coordinates Units: meters
void waypoint_move_here_2d(uint8_t wp_id)
Definition: waypoints.c:246
void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src)
Definition: waypoints.c:330
void waypoint_set_alt(uint8_t wp_id, float alt)
Set altitude of waypoint in meters (above reference)
Definition: waypoints.c:169
const uint8_t nb_waypoint
Definition: common_nav.c:37
void waypoint_set_global_flag(uint8_t wp_id)
Definition: waypoints.c:63
void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu)
Set local ENU waypoint coordinates.
Definition: waypoints.c:113
vector in Latitude, Longitude and Altitude
void waypoint_globalize(uint8_t wp_id)
update global LLA coordinates from its ENU coordinates
Definition: waypoints.c:265
int32_t alt
in millimeters above WGS84 reference ellipsoid
void waypoint_set_alt_i(uint8_t wp_id, int32_t alt)
Definition: waypoints.c:159
Paparazzi floating point math for geodetic calculations.
float waypoint_get_alt(uint8_t wp_id)
Get altitude of waypoint in meters (above reference)
Definition: waypoints.c:93
void waypoints_localize_all(void)
update local ENU coordinates of all global waypoints
Definition: waypoints.c:293
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:189
void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos)
Definition: waypoints.c:125
void waypoint_set_xy_i(uint8_t wp_id, int32_t x, int32_t y)
Set only local XY coordinates of waypoint without update altitude.
Definition: waypoints.c:138
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
void waypoint_set_here(uint8_t wp_id)
set waypoint to current location and altitude
Definition: waypoints.c:221
void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla)
set waypoint latitude/longitude without updating altitude
Definition: waypoints.c:209
void waypoint_clear_global_flag(uint8_t wp_id)
Definition: waypoints.c:70
struct LlaCoor_i lla
Definition: waypoints.h:46
Paparazzi fixed point math for geodetic calculations.
struct LlaCoor_i * waypoint_get_lla(uint8_t wp_id)
Get LLA coordinates of waypoint.
Definition: waypoints.c:310
void waypoint_copy(uint8_t wp_dest, uint8_t wp_src)
copy one waypoint to another, this includes all flags from the source waypoint
Definition: waypoints.c:323
vector in East North Up coordinates
float waypoint_get_x(uint8_t wp_id)
Get X/East coordinate of waypoint in meters.
Definition: waypoints.c:77
void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu)
Definition: waypoints.c:101
void waypoints_init(void)
initialize global and local waypoints
Definition: waypoints.c:35
struct EnuCoor_i enu_i
with INT32_POS_FRAC
Definition: waypoints.h:44
void waypoint_set_here_2d(uint8_t wp_id)
set waypoint to current horizontal location without modifying altitude
Definition: waypoints.c:234
uint8_t flags
bitmask encoding valid representations and if local or global
Definition: waypoints.h:43
void waypoint_localize(uint8_t wp_id)
update local ENU coordinates from its LLA coordinates
Definition: waypoints.c:276
struct Waypoint waypoints[]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:38
void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y)
Definition: waypoints.c:150
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98