Paparazzi UAS  v6.3_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 #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);
76 extern float waypoint_get_lat_deg(uint8_t wp_id);
78 extern float waypoint_get_lat_rad(uint8_t wp_id);
80 extern float waypoint_get_lon_deg(uint8_t wp_id);
82 extern float waypoint_get_lon_rad(uint8_t wp_id);
83 
91 extern struct LlaCoor_i *waypoint_get_lla(uint8_t wp_id);
92 
97 extern struct EnuCoor_f *waypoint_get_enu_f(uint8_t wp_id);
98 
103 extern struct EnuCoor_i *waypoint_get_enu_i(uint8_t wp_id);
104 
105 /*
106  * Set waypoint coordinates.
107  */
109 extern void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu);
111 extern void waypoint_set_alt(uint8_t wp_id, float alt);
112 
114 extern void waypoint_set_here(uint8_t wp_id);
116 extern void waypoint_set_here_2d(uint8_t wp_id);
117 
118 /* functions to set fixedpoint representation directly */
119 extern void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu);
120 extern void waypoint_set_xy_i(uint8_t wp_id, int32_t x, int32_t y);
121 extern void waypoint_set_alt_i(uint8_t wp_id, int32_t alt);
122 extern void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla);
123 
125 extern void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla);
126 
128 extern void waypoint_copy(uint8_t wp_dest, uint8_t wp_src);
129 extern void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src);
130 
131 
132 /*
133  * Move waypoints.
134  * Basically sets the coordinates and sends the WP_MOVED telemetry message as ack.
135  */
136 extern void waypoint_move_here_2d(uint8_t wp_id);
137 extern void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos);
138 extern void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y);
139 extern void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla);
140 
141 
142 /*
143  * Global(LLA) / Local(ENU) conversions.
144  */
145 
147 extern void waypoint_globalize(uint8_t wp_id);
148 
150 extern void waypoint_localize(uint8_t wp_id);
152 extern void waypoints_localize_all(void);
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #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:405
void waypoint_globalize(uint8_t wp_id)
update global LLA coordinates from its ENU coordinates
Definition: waypoints.c:321
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:290
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:349
struct LlaCoor_i * waypoint_get_lla(uint8_t wp_id)
Get LLA coordinates of waypoint.
Definition: waypoints.c:366
void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src)
Definition: waypoints.c:412
void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y)
Definition: waypoints.c:206
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:152
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:194
void waypoint_set_here(uint8_t wp_id)
set waypoint to current location and altitude
Definition: waypoints.c:277
float waypoint_get_lon_deg(uint8_t wp_id)
Get longitude of waypoint in deg.
Definition: waypoints.c:139
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:265
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_lat_deg(uint8_t wp_id)
Get latitude of waypoint in deg.
Definition: waypoints.c:121
void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos)
Definition: waypoints.c:181
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:392
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:157
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:235
void waypoint_set_alt_i(uint8_t wp_id, int32_t alt)
Definition: waypoints.c:215
void waypoint_move_here_2d(uint8_t wp_id)
Definition: waypoints.c:302
void waypoint_localize(uint8_t wp_id)
update local ENU coordinates from its LLA coordinates
Definition: waypoints.c:332
void waypoint_set_alt(uint8_t wp_id, float alt)
Set altitude of waypoint in meters (above reference)
Definition: waypoints.c:225
struct EnuCoor_f * waypoint_get_enu_f(uint8_t wp_id)
Get ENU coordinates (float)
Definition: waypoints.c:379
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:245
float waypoint_get_lat_rad(uint8_t wp_id)
Get latitude of waypoint in rad.
Definition: waypoints.c:134
void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu)
Set local ENU waypoint coordinates.
Definition: waypoints.c:169
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