Firmware
navigation.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (C) 2012 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
42 #pragma once
43 
44 #include <stdint.h>
45 #include <stdbool.h>
46 
47 #if defined(MEMORY_CONSTRAINED_SYSTEM)
48 # define NUM_MISSIONS_SUPPORTED 50
49 #elif defined(__PX4_POSIX)
50 # define NUM_MISSIONS_SUPPORTED (UINT16_MAX-1) // This is allocated as needed.
51 #else
52 # define NUM_MISSIONS_SUPPORTED 2000 // This allocates a file of around 181 kB on the SD card.
53 #endif
54 
55 #define NAV_EPSILON_POSITION 0.001f
57 /* compatible to mavlink MAV_CMD */
58 enum NAV_CMD {
59  NAV_CMD_IDLE = 0,
60  NAV_CMD_WAYPOINT = 16,
61  NAV_CMD_LOITER_UNLIMITED = 17,
62  NAV_CMD_LOITER_TIME_LIMIT = 19,
63  NAV_CMD_RETURN_TO_LAUNCH = 20,
64  NAV_CMD_LAND = 21,
65  NAV_CMD_TAKEOFF = 22,
66  NAV_CMD_LOITER_TO_ALT = 31,
67  NAV_CMD_DO_FOLLOW_REPOSITION = 33,
68  NAV_CMD_VTOL_TAKEOFF = 84,
69  NAV_CMD_VTOL_LAND = 85,
70  NAV_CMD_DELAY = 93,
71  NAV_CMD_DO_JUMP = 177,
72  NAV_CMD_DO_CHANGE_SPEED = 178,
73  NAV_CMD_DO_SET_HOME = 179,
74  NAV_CMD_DO_SET_SERVO = 183,
75  NAV_CMD_DO_LAND_START = 189,
76  NAV_CMD_DO_SET_ROI_LOCATION = 195,
77  NAV_CMD_DO_SET_ROI_WPNEXT_OFFSET = 196,
78  NAV_CMD_DO_SET_ROI_NONE = 197,
79  NAV_CMD_DO_SET_ROI = 201,
80  NAV_CMD_DO_DIGICAM_CONTROL = 203,
81  NAV_CMD_DO_MOUNT_CONFIGURE = 204,
82  NAV_CMD_DO_MOUNT_CONTROL = 205,
83  NAV_CMD_DO_SET_CAM_TRIGG_INTERVAL = 214,
84  NAV_CMD_DO_SET_CAM_TRIGG_DIST = 206,
85  NAV_CMD_SET_CAMERA_MODE = 530,
86  NAV_CMD_IMAGE_START_CAPTURE = 2000,
87  NAV_CMD_IMAGE_STOP_CAPTURE = 2001,
88  NAV_CMD_DO_TRIGGER_CONTROL = 2003,
89  NAV_CMD_VIDEO_START_CAPTURE = 2500,
90  NAV_CMD_VIDEO_STOP_CAPTURE = 2501,
91  NAV_CMD_DO_VTOL_TRANSITION = 3000,
92  NAV_CMD_FENCE_RETURN_POINT = 5000,
93  NAV_CMD_FENCE_POLYGON_VERTEX_INCLUSION = 5001,
94  NAV_CMD_FENCE_POLYGON_VERTEX_EXCLUSION = 5002,
95  NAV_CMD_FENCE_CIRCLE_INCLUSION = 5003,
96  NAV_CMD_FENCE_CIRCLE_EXCLUSION = 5004,
97  NAV_CMD_INVALID = UINT16_MAX /* ensure that casting a large number results in a specific error */
98 };
99 
100 enum ORIGIN {
101  ORIGIN_MAVLINK = 0,
102  ORIGIN_ONBOARD
103 };
104 
105 /* compatible to mavlink MAV_FRAME */
106 enum NAV_FRAME {
107  NAV_FRAME_GLOBAL = 0,
108  NAV_FRAME_LOCAL_NED = 1,
109  NAV_FRAME_MISSION = 2,
110  NAV_FRAME_GLOBAL_RELATIVE_ALT = 3,
111  NAV_FRAME_LOCAL_ENU = 4,
112  NAV_FRAME_GLOBAL_INT = 5,
113  NAV_FRAME_GLOBAL_RELATIVE_ALT_INT = 6,
114  NAV_FRAME_LOCAL_OFFSET_NED = 7,
115  NAV_FRAME_BODY_NED = 8,
116  NAV_FRAME_BODY_OFFSET_NED = 9,
117  NAV_FRAME_GLOBAL_TERRAIN_ALT = 10,
118  NAV_FRAME_GLOBAL_TERRAIN_ALT_INT = 11
119 };
120 
135 // Mission Item structure
136 // We explicitly handle struct padding to ensure consistency between in memory and on disk formats across different platforms, toolchains, etc
137 // The use of #pragma pack is avoided to prevent the possibility of unaligned memory accesses.
138 
139 #if (__GNUC__ >= 5) || __clang__
140 // Disabled in GCC 4.X as the warning doesn't seem to "pop" correctly
141 #pragma GCC diagnostic push
142 #pragma GCC diagnostic error "-Wpadded"
143 #endif // GCC >= 5 || Clang
144 
146  double lat;
147  double lon;
148  union {
149  struct {
150  union {
151  float time_inside;
152  float pitch_min;
154  };
157  float yaw;
158  float ___lat_float;
159  float ___lon_float;
160  float altitude;
161  };
162  float params[7];
163  };
164 
165  uint16_t nav_cmd;
170  union {
172  uint16_t vertex_count;
173  uint16_t land_precision;
174  };
175 
176  struct {
177  uint16_t frame : 4,
178  origin : 3,
179  loiter_exit_xtrack : 1,
180  force_heading : 1,
182  autocontinue : 1,
184  _padding0 : 4;
185  };
186 
187  uint8_t _padding1[2];
188 };
189 
195  uint16_t num_items;
196  uint16_t update_counter;
197 };
198 
204  double lat;
205  double lon;
206  float alt;
207 
208  union {
209  uint16_t vertex_count;
211  };
212 
213  uint16_t nav_cmd;
214  uint8_t frame;
216  uint8_t _padding0[5];
217 };
218 
224  double lat;
225  double lon;
226  float alt;
227  uint8_t frame;
229  uint8_t _padding0[3];
230 };
231 
232 #if (__GNUC__ >= 5) || __clang__
233 #pragma GCC diagnostic pop
234 #endif // GCC >= 5 || Clang
235 
236 #include <uORB/topics/mission.h>
237 
Global position setpoint in WGS84 coordinates.
Definition: navigation.h:145
uint16_t frame
mission frame
Definition: navigation.h:177
uint16_t vertex_count
Polygon vertex count (geofence)
Definition: navigation.h:172
float altitude
altitude in meters (AMSL)
Definition: navigation.h:160
uint16_t autocontinue
true if next waypoint should follow after this one
Definition: navigation.h:177
float acceptance_radius
default radius in which the mission is accepted as reached in meters
Definition: navigation.h:155
uint16_t vtol_back_transition
part of the vtol back transition sequence
Definition: navigation.h:177
uint16_t origin
how the mission item was generated
Definition: navigation.h:177
uint16_t vertex_count
number of vertices in this polygon
Definition: navigation.h:209
uint16_t do_jump_repeat_count
how many times do jump needs to be done
Definition: navigation.h:168
float circle_radius
geofence circle radius in meters (only used for NAV_CMD_NAV_FENCE_CIRCLE*)
Definition: navigation.h:210
double lon
longitude in degrees
Definition: navigation.h:147
float ___lat_float
padding
Definition: navigation.h:158
float ___lon_float
padding
Definition: navigation.h:159
uint16_t _padding0
padding remaining unused bits
Definition: navigation.h:177
Geofence vertex point.
Definition: navigation.h:203
float circle_radius
geofence circle radius in meters (only used for NAV_CMD_NAV_FENCE_CIRCLE*)
Definition: navigation.h:153
uint16_t nav_cmd
navigation command
Definition: navigation.h:165
uint16_t do_jump_current_count
count how many times the jump has been done
Definition: navigation.h:171
Save Point (Rally Point).
Definition: navigation.h:223
dataman housekeeping information for a specific item.
Definition: navigation.h:194
float time_inside
time that the MAV should stay inside the radius before advancing in seconds
Definition: navigation.h:151
uint16_t land_precision
Defines if landing should be precise: 0 = normal landing, 1 = opportunistic precision landing...
Definition: navigation.h:173
uint16_t nav_cmd
navigation command (one of MAV_CMD_NAV_FENCE_*)
Definition: navigation.h:213
uint16_t num_items
total number of items stored (excluding this one)
Definition: navigation.h:195
int16_t do_jump_mission_index
index where the do jump will go to
Definition: navigation.h:167
uint16_t update_counter
This counter is increased when (some) items change (this can wrap)
Definition: navigation.h:196
Definition: params.h:43
float pitch_min
minimal pitch angle for fixed wing takeoff waypoints
Definition: navigation.h:152
uint16_t loiter_exit_xtrack
exit xtrack location: 0 for center of loiter wp, 1 for exit location
Definition: navigation.h:177
uint8_t frame
MAV_FRAME.
Definition: navigation.h:227
uint8_t _padding1[2]
padding struct size to alignment boundary
Definition: navigation.h:187
uint16_t force_heading
heading needs to be reached
Definition: navigation.h:177
float yaw
in radians NED -PI..+PI, NAN means don&#39;t change yaw
Definition: navigation.h:157
float loiter_radius
loiter radius in meters, 0 for a VTOL to hover, negative for counter-clockwise
Definition: navigation.h:156
uint8_t frame
MAV_FRAME.
Definition: navigation.h:214
uint16_t altitude_is_relative
true if altitude is relative from start point
Definition: navigation.h:177
double lat
latitude in degrees
Definition: navigation.h:146