Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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 #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_t 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 coordinats and sends the WP_MOVED telemetry message as ack.
112  * @todo keep this here?
113  */
114 
115 extern void waypoint_move_enu_i(uint8_t wp_id, struct EnuCoor_i *new_pos);
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 */
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:170
struct EnuCoor_f enu_f
Definition: waypoints.h:41
vector in East North Up coordinates Units: meters
void waypoint_position_copy(uint8_t wp_dest, uint8_t wp_src)
Definition: waypoints.c:302
void waypoint_set_alt(uint8_t wp_id, float alt)
Set altitude of waypoint in meters (above reference)
Definition: waypoints.c:160
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:237
int32_t alt
in millimeters above WGS84 reference ellipsoid
void waypoint_set_alt_i(uint8_t wp_id, int32_t alt)
Definition: waypoints.c:150
Paparazzi floating point math for geodetic calculations.
bool_t waypoint_is_global(uint8_t wp_id)
Definition: waypoints.c:55
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:265
void waypoint_move_lla(uint8_t wp_id, struct LlaCoor_i *lla)
Definition: waypoints.c:180
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
void waypoint_set_here(uint8_t wp_id)
set waypoint to current location and altitude
Definition: waypoints.c:212
void waypoint_set_latlon(uint8_t wp_id, struct LlaCoor_i *lla)
set waypoint latitude/longitude without updating altitude
Definition: waypoints.c:200
void waypoint_clear_global_flag(uint8_t wp_id)
Definition: waypoints.c:70
struct LlaCoor_i lla
Definition: waypoints.h:42
Paparazzi fixed point math for geodetic calculations.
signed long int32_t
Definition: types.h:19
struct LlaCoor_i * waypoint_get_lla(uint8_t wp_id)
Get LLA coordinates of waypoint.
Definition: waypoints.c:282
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:295
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
unsigned char uint8_t
Definition: types.h:14
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:40
void waypoint_set_here_2d(uint8_t wp_id)
set waypoint to current horizontal location without modifying altitude
Definition: waypoints.c:225
uint8_t flags
bitmask encoding valid representations and if local or global
Definition: waypoints.h:39
void waypoint_localize(uint8_t wp_id)
update local ENU coordinates from its LLA coordinates
Definition: waypoints.c:248
struct Waypoint waypoints[]
size == nb_waypoint, waypoint 0 is a dummy waypoint
Definition: common_nav.c:38