Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 #if USE_ALT_LLA_WAYPOINTS
57 #define WaypointAlt(_wp) waypoint_get_lla_alt(_wp)
58 #else
59 #define WaypointAlt(_wp) waypoint_get_alt(_wp)
60 #endif
61 #define Height(_h) (_h)
62 
63 extern void waypoints_init(void);
64 
65 extern bool waypoint_is_global(uint8_t wp_id);
66 extern void waypoint_set_global_flag(uint8_t wp_id);
67 extern void waypoint_clear_global_flag(uint8_t wp_id);
68 
69 
70 /*
71  * Get waypoint coordinates.
72  */
74 extern float waypoint_get_x(uint8_t wp_id);
76 extern float waypoint_get_y(uint8_t wp_id);
78 extern float waypoint_get_alt(uint8_t wp_id);
79 extern float waypoint_get_lla_alt(uint8_t wp_id);
81 extern float waypoint_get_lat_deg(uint8_t wp_id);
83 extern float waypoint_get_lat_rad(uint8_t wp_id);
85 extern float waypoint_get_lon_deg(uint8_t wp_id);
87 extern float waypoint_get_lon_rad(uint8_t wp_id);
88 
96 extern struct LlaCoor_i *waypoint_get_lla(uint8_t wp_id);
97 
102 extern struct EnuCoor_f *waypoint_get_enu_f(uint8_t wp_id);
103 
108 extern struct EnuCoor_i *waypoint_get_enu_i(uint8_t wp_id);
109 
110 /*
111  * Set waypoint coordinates.
112  */
114 extern void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu);
116 extern void waypoint_set_alt(uint8_t wp_id, float alt);
117 
119 extern void waypoint_set_here(uint8_t wp_id);
121 extern void waypoint_set_here_2d(uint8_t wp_id);
122 
123 /* functions to set fixedpoint representation directly */
124 extern void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu);
125 extern void waypoint_set_xy_i(uint8_t wp_id, int32_t x, int32_t y);
126 extern void waypoint_set_alt_i(uint8_t wp_id, int32_t alt);
127 extern void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla);
128 
130 extern void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla);
131 
133 extern void waypoint_copy(uint8_t wp_dest, uint8_t wp_src);
134 extern void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src);
135 
136 
137 /*
138  * Move waypoints.
139  * Basically sets the coordinates and sends the WP_MOVED telemetry message as ack.
140  */
141 extern void waypoint_move_here_2d(uint8_t wp_id);
142 extern void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos);
143 extern void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y);
144 extern void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla);
145 
146 
147 /*
148  * Global(LLA) / Local(ENU) conversions.
149  */
150 
152 extern void waypoint_globalize(uint8_t wp_id);
153 
155 extern void waypoint_localize(uint8_t wp_id);
157 extern void waypoints_localize_all(void);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* WAYPOINTS_H */
int32_t y
North.
int32_t x
East.
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
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:413
void waypoint_globalize(uint8_t wp_id)
update global LLA coordinates from its ENU coordinates
Definition: waypoints.c:329
struct LlaCoor_i lla
Definition: waypoints.h:46
void waypoint_set_here_2d(uint8_t wp_id)
set waypoint to current horizontal location without modifying altitude
Definition: waypoints.c:298
struct Waypoint waypoints[]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:39
void waypoints_localize_all(void)
update local ENU coordinates of all global waypoints
Definition: waypoints.c:357
struct LlaCoor_i * waypoint_get_lla(uint8_t wp_id)
Get LLA coordinates of waypoint.
Definition: waypoints.c:374
void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src)
Definition: waypoints.c:420
void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y)
Definition: waypoints.c:214
bool waypoint_is_global(uint8_t wp_id)
Definition: waypoints.c:75
float waypoint_get_lon_rad(uint8_t wp_id)
Get longitude of waypoint in rad.
Definition: waypoints.c:160
float waypoint_get_alt(uint8_t wp_id)
Get altitude of waypoint in meters (above reference)
Definition: waypoints.c:113
float waypoint_get_x(uint8_t wp_id)
Get X/East coordinate of waypoint in meters.
Definition: waypoints.c:97
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:202
void waypoint_set_here(uint8_t wp_id)
set waypoint to current location and altitude
Definition: waypoints.c:285
float waypoint_get_lon_deg(uint8_t wp_id)
Get longitude of waypoint in deg.
Definition: waypoints.c:147
void waypoint_set_global_flag(uint8_t wp_id)
Definition: waypoints.c:83
uint8_t flags
bitmask encoding valid representations and if local or global
Definition: waypoints.h:43
void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla)
set waypoint latitude/longitude without updating altitude
Definition: waypoints.c:273
void waypoints_init(void)
initialize global and local waypoints
Definition: waypoints.c:51
struct EnuCoor_i enu_i
with INT32_POS_FRAC
Definition: waypoints.h:44
float waypoint_get_lla_alt(uint8_t wp_id)
Definition: waypoints.c:121
float waypoint_get_lat_deg(uint8_t wp_id)
Get latitude of waypoint in deg.
Definition: waypoints.c:129
void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos)
Definition: waypoints.c:189
struct EnuCoor_f enu_f
Definition: waypoints.h:45
struct EnuCoor_i * waypoint_get_enu_i(uint8_t wp_id)
Get ENU coordinates (integer)
Definition: waypoints.c:400
float waypoint_get_y(uint8_t wp_id)
Get Y/North coordinate of waypoint in meters.
Definition: waypoints.c:105
const uint8_t nb_waypoint
Definition: common_nav.c:38
void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu)
Definition: waypoints.c:165
void waypoint_clear_global_flag(uint8_t wp_id)
Definition: waypoints.c:90
void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:243
void waypoint_set_alt_i(uint8_t wp_id, int32_t alt)
Definition: waypoints.c:223
void waypoint_move_here_2d(uint8_t wp_id)
Definition: waypoints.c:310
void waypoint_localize(uint8_t wp_id)
update local ENU coordinates from its LLA coordinates
Definition: waypoints.c:340
void waypoint_set_alt(uint8_t wp_id, float alt)
Set altitude of waypoint in meters (above reference)
Definition: waypoints.c:233
struct EnuCoor_f * waypoint_get_enu_f(uint8_t wp_id)
Get ENU coordinates (float)
Definition: waypoints.c:387
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:253
float waypoint_get_lat_rad(uint8_t wp_id)
Get latitude of waypoint in rad.
Definition: waypoints.c:142
void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu)
Set local ENU waypoint coordinates.
Definition: waypoints.c:177
Paparazzi floating point math for geodetic calculations.
vector in East North Up coordinates Units: meters
Paparazzi fixed point math for geodetic calculations.
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