Paparazzi UAS  v5.18.0_stable
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 #include "std.h"
30 #include "math/pprz_geodetic_int.h"
32 
33 #define WP_FLAG_GLOBAL 0
34 #define WP_FLAG_ENU_I 1
35 #define WP_FLAG_ENU_F 2
36 #define WP_FLAG_LLA_I 3
37 
38 struct Waypoint {
40  struct EnuCoor_i enu_i;
41  struct EnuCoor_f enu_f;
42  struct LlaCoor_i lla;
43 };
44 
45 extern const uint8_t nb_waypoint;
47 extern struct Waypoint waypoints[];
48 
49 /* aliases for backwards compatibilty */
50 #define WaypointX(_wp) waypoint_get_x(_wp)
51 #define WaypointY(_wp) waypoint_get_y(_wp)
52 #define WaypointAlt(_wp) waypoint_get_alt(_wp)
53 #define Height(_h) (_h)
54 
55 extern void waypoints_init(void);
56 
57 extern bool waypoint_is_global(uint8_t wp_id);
58 extern void waypoint_set_global_flag(uint8_t wp_id);
59 extern void waypoint_clear_global_flag(uint8_t wp_id);
60 
61 
62 /*
63  * Get waypoint coordinates.
64  */
66 extern float waypoint_get_x(uint8_t wp_id);
68 extern float waypoint_get_y(uint8_t wp_id);
70 extern float waypoint_get_alt(uint8_t wp_id);
71 
79 extern struct LlaCoor_i *waypoint_get_lla(uint8_t wp_id);
80 
81 
82 /*
83  * Set waypoint coordinates.
84  */
86 extern void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu);
88 extern void waypoint_set_alt(uint8_t wp_id, float alt);
89 
91 extern void waypoint_set_here(uint8_t wp_id);
93 extern void waypoint_set_here_2d(uint8_t wp_id);
94 
95 /* functions to set fixedpoint representation directly */
96 extern void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu);
97 extern void waypoint_set_xy_i(uint8_t wp_id, int32_t x, int32_t y);
98 extern void waypoint_set_alt_i(uint8_t wp_id, int32_t alt);
99 extern void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla);
100 
102 extern void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla);
103 
105 extern void waypoint_copy(uint8_t wp_dest, uint8_t wp_src);
106 extern void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src);
107 
108 
109 /*
110  * Move waypoints.
111  * Basically sets the coordinates and sends the WP_MOVED telemetry message as ack.
112  */
113 extern void waypoint_move_here_2d(uint8_t wp_id);
114 extern void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos);
115 extern void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y);
116 extern void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla);
117 
118 
119 /*
120  * Global(LLA) / Local(ENU) conversions.
121  */
122 
124 extern void waypoint_globalize(uint8_t wp_id);
125 
127 extern void waypoint_localize(uint8_t wp_id);
129 extern void waypoints_localize_all(void);
130 
131 #endif /* WAYPOINTS_H */
nb_waypoint
const uint8_t nb_waypoint
Definition: common_nav.c:37
waypoint_localize
void waypoint_localize(uint8_t wp_id)
update local ENU coordinates from its LLA coordinates
Definition: waypoints.c:276
Waypoint::flags
uint8_t flags
bitmask encoding valid representations and if local or global
Definition: waypoints.h:39
LlaCoor_i::alt
int32_t alt
in millimeters above WGS84 reference ellipsoid
Definition: pprz_geodetic_int.h:62
waypoint_copy
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
waypoints_localize_all
void waypoints_localize_all(void)
update local ENU coordinates of all global waypoints
Definition: waypoints.c:293
waypoint_set_latlon
void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla)
set waypoint latitude/longitude without updating altitude
Definition: waypoints.c:209
waypoint_move_xy_i
void waypoint_move_xy_i(uint8_t wp_id, int32_t x, int32_t y)
Definition: waypoints.c:150
pprz_geodetic_int.h
Paparazzi fixed point math for geodetic calculations.
Waypoint::enu_i
struct EnuCoor_i enu_i
with INT32_POS_FRAC
Definition: waypoints.h:40
waypoint_set_here_2d
void waypoint_set_here_2d(uint8_t wp_id)
set waypoint to current horizontal location without modifying altitude
Definition: waypoints.c:234
waypoint_get_x
float waypoint_get_x(uint8_t wp_id)
Get X/East coordinate of waypoint in meters.
Definition: waypoints.c:77
waypoint_move_here_2d
void waypoint_move_here_2d(uint8_t wp_id)
Definition: waypoints.c:246
std.h
pprz_geodetic_float.h
Paparazzi floating point math for geodetic calculations.
waypoint_get_lla
struct LlaCoor_i * waypoint_get_lla(uint8_t wp_id)
Get LLA coordinates of waypoint.
Definition: waypoints.c:310
uint8_t
unsigned char uint8_t
Definition: types.h:14
waypoint_set_alt
void waypoint_set_alt(uint8_t wp_id, float alt)
Set altitude of waypoint in meters (above reference)
Definition: waypoints.c:169
waypoint_set_lla
void waypoint_set_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:179
EnuCoor_f
vector in East North Up coordinates Units: meters
Definition: pprz_geodetic_float.h:72
waypoints
struct Waypoint waypoints[]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:38
Waypoint
Definition: waypoints.h:38
waypoint_is_global
bool waypoint_is_global(uint8_t wp_id)
Definition: waypoints.c:55
waypoint_set_enu
void waypoint_set_enu(uint8_t wp_id, struct EnuCoor_f *enu)
Set local ENU waypoint coordinates.
Definition: waypoints.c:113
waypoint_globalize
void waypoint_globalize(uint8_t wp_id)
update global LLA coordinates from its ENU coordinates
Definition: waypoints.c:265
waypoint_set_enu_i
void waypoint_set_enu_i(uint8_t wp_id, struct EnuCoor_i *enu)
Definition: waypoints.c:101
waypoint_get_y
float waypoint_get_y(uint8_t wp_id)
Get Y/North coordinate of waypoint in meters.
Definition: waypoints.c:85
LlaCoor_i
vector in Latitude, Longitude and Altitude
Definition: pprz_geodetic_int.h:59
int32_t
signed long int32_t
Definition: types.h:19
Waypoint::enu_f
struct EnuCoor_f enu_f
Definition: waypoints.h:41
waypoint_set_global_flag
void waypoint_set_global_flag(uint8_t wp_id)
Definition: waypoints.c:63
waypoint_get_alt
float waypoint_get_alt(uint8_t wp_id)
Get altitude of waypoint in meters (above reference)
Definition: waypoints.c:93
waypoint_move_enu_i
void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos)
Definition: waypoints.c:125
waypoint_move_lla
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:189
waypoint_clear_global_flag
void waypoint_clear_global_flag(uint8_t wp_id)
Definition: waypoints.c:70
waypoint_set_xy_i
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
waypoints_init
void waypoints_init(void)
initialize global and local waypoints
Definition: waypoints.c:35
waypoint_set_here
void waypoint_set_here(uint8_t wp_id)
set waypoint to current location and altitude
Definition: waypoints.c:221
Waypoint::lla
struct LlaCoor_i lla
Definition: waypoints.h:42
waypoint_set_alt_i
void waypoint_set_alt_i(uint8_t wp_id, int32_t alt)
Definition: waypoints.c:159
EnuCoor_i
vector in East North Up coordinates
Definition: pprz_geodetic_int.h:77
waypoint_position_copy
void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src)
Definition: waypoints.c:330