Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_gps_raw_int.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE GPS_RAW_INT PACKING
3
4#define MAVLINK_MSG_ID_GPS_RAW_INT 24
5
6MAVPACKED(
7typedef struct __mavlink_gps_raw_int_t {
8 uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
9 int32_t lat; /*< [degE7] Latitude (WGS84, EGM96 ellipsoid)*/
10 int32_t lon; /*< [degE7] Longitude (WGS84, EGM96 ellipsoid)*/
11 int32_t alt; /*< [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.*/
12 uint16_t eph; /*< GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX*/
13 uint16_t epv; /*< GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX*/
14 uint16_t vel; /*< [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX*/
15 uint16_t cog; /*< [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX*/
16 uint8_t fix_type; /*< GPS fix type.*/
17 uint8_t satellites_visible; /*< Number of satellites visible. If unknown, set to UINT8_MAX*/
18 int32_t alt_ellipsoid; /*< [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.*/
19 uint32_t h_acc; /*< [mm] Position uncertainty.*/
20 uint32_t v_acc; /*< [mm] Altitude uncertainty.*/
21 uint32_t vel_acc; /*< [mm/s] Speed uncertainty.*/
22 uint32_t hdg_acc; /*< [degE5] Heading / track uncertainty*/
23 uint16_t yaw; /*< [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.*/
24}) mavlink_gps_raw_int_t;
25
26#define MAVLINK_MSG_ID_GPS_RAW_INT_LEN 52
27#define MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN 30
28#define MAVLINK_MSG_ID_24_LEN 52
29#define MAVLINK_MSG_ID_24_MIN_LEN 30
30
31#define MAVLINK_MSG_ID_GPS_RAW_INT_CRC 24
32#define MAVLINK_MSG_ID_24_CRC 24
33
34
35
36#if MAVLINK_COMMAND_24BIT
37#define MAVLINK_MESSAGE_INFO_GPS_RAW_INT {
38 24,
39 "GPS_RAW_INT",
40 16,
41 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_gps_raw_int_t, time_usec) },
42 { "fix_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_gps_raw_int_t, fix_type) },
43 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_gps_raw_int_t, lat) },
44 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_gps_raw_int_t, lon) },
45 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_gps_raw_int_t, alt) },
46 { "eph", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_gps_raw_int_t, eph) },
47 { "epv", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_gps_raw_int_t, epv) },
48 { "vel", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_gps_raw_int_t, vel) },
49 { "cog", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_gps_raw_int_t, cog) },
50 { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_gps_raw_int_t, satellites_visible) },
51 { "alt_ellipsoid", NULL, MAVLINK_TYPE_INT32_T, 0, 30, offsetof(mavlink_gps_raw_int_t, alt_ellipsoid) },
52 { "h_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 34, offsetof(mavlink_gps_raw_int_t, h_acc) },
53 { "v_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 38, offsetof(mavlink_gps_raw_int_t, v_acc) },
54 { "vel_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 42, offsetof(mavlink_gps_raw_int_t, vel_acc) },
55 { "hdg_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 46, offsetof(mavlink_gps_raw_int_t, hdg_acc) },
56 { "yaw", NULL, MAVLINK_TYPE_UINT16_T, 0, 50, offsetof(mavlink_gps_raw_int_t, yaw) },
57 } \
58}
59#else
60#define MAVLINK_MESSAGE_INFO_GPS_RAW_INT {
61 "GPS_RAW_INT",
62 16,
63 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_gps_raw_int_t, time_usec) },
64 { "fix_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_gps_raw_int_t, fix_type) },
65 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_gps_raw_int_t, lat) },
66 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_gps_raw_int_t, lon) },
67 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_gps_raw_int_t, alt) },
68 { "eph", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_gps_raw_int_t, eph) },
69 { "epv", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_gps_raw_int_t, epv) },
70 { "vel", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_gps_raw_int_t, vel) },
71 { "cog", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_gps_raw_int_t, cog) },
72 { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_gps_raw_int_t, satellites_visible) },
73 { "alt_ellipsoid", NULL, MAVLINK_TYPE_INT32_T, 0, 30, offsetof(mavlink_gps_raw_int_t, alt_ellipsoid) },
74 { "h_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 34, offsetof(mavlink_gps_raw_int_t, h_acc) },
75 { "v_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 38, offsetof(mavlink_gps_raw_int_t, v_acc) },
76 { "vel_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 42, offsetof(mavlink_gps_raw_int_t, vel_acc) },
77 { "hdg_acc", NULL, MAVLINK_TYPE_UINT32_T, 0, 46, offsetof(mavlink_gps_raw_int_t, hdg_acc) },
78 { "yaw", NULL, MAVLINK_TYPE_UINT16_T, 0, 50, offsetof(mavlink_gps_raw_int_t, yaw) },
79 } \
80}
81#endif
82
83/**
84 * @brief Pack a gps_raw_int message
85 * @param system_id ID of this system
86 * @param component_id ID of this component (e.g. 200 for IMU)
87 * @param msg The MAVLink message to compress the data into
88 *
89 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
90 * @param fix_type GPS fix type.
91 * @param lat [degE7] Latitude (WGS84, EGM96 ellipsoid)
92 * @param lon [degE7] Longitude (WGS84, EGM96 ellipsoid)
93 * @param alt [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.
94 * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
95 * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
96 * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX
97 * @param cog [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
98 * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX
99 * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.
100 * @param h_acc [mm] Position uncertainty.
101 * @param v_acc [mm] Altitude uncertainty.
102 * @param vel_acc [mm/s] Speed uncertainty.
103 * @param hdg_acc [degE5] Heading / track uncertainty
104 * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.
105 * @return length of the message in bytes (excluding serial stream start sign)
106 */
107static inline uint16_t mavlink_msg_gps_raw_int_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
108 uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc, uint16_t yaw)
109{
110#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
112 _mav_put_uint64_t(buf, 0, time_usec);
113 _mav_put_int32_t(buf, 8, lat);
114 _mav_put_int32_t(buf, 12, lon);
115 _mav_put_int32_t(buf, 16, alt);
116 _mav_put_uint16_t(buf, 20, eph);
117 _mav_put_uint16_t(buf, 22, epv);
118 _mav_put_uint16_t(buf, 24, vel);
119 _mav_put_uint16_t(buf, 26, cog);
120 _mav_put_uint8_t(buf, 28, fix_type);
121 _mav_put_uint8_t(buf, 29, satellites_visible);
122 _mav_put_int32_t(buf, 30, alt_ellipsoid);
123 _mav_put_uint32_t(buf, 34, h_acc);
124 _mav_put_uint32_t(buf, 38, v_acc);
125 _mav_put_uint32_t(buf, 42, vel_acc);
126 _mav_put_uint32_t(buf, 46, hdg_acc);
127 _mav_put_uint16_t(buf, 50, yaw);
128
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
130#else
131 mavlink_gps_raw_int_t packet;
132 packet.time_usec = time_usec;
133 packet.lat = lat;
134 packet.lon = lon;
135 packet.alt = alt;
136 packet.eph = eph;
137 packet.epv = epv;
138 packet.vel = vel;
139 packet.cog = cog;
140 packet.fix_type = fix_type;
141 packet.satellites_visible = satellites_visible;
142 packet.alt_ellipsoid = alt_ellipsoid;
143 packet.h_acc = h_acc;
144 packet.v_acc = v_acc;
145 packet.vel_acc = vel_acc;
146 packet.hdg_acc = hdg_acc;
147 packet.yaw = yaw;
148
149 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
150#endif
151
152 msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT;
153 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
154}
155
156/**
157 * @brief Pack a gps_raw_int message
158 * @param system_id ID of this system
159 * @param component_id ID of this component (e.g. 200 for IMU)
160 * @param status MAVLink status structure
161 * @param msg The MAVLink message to compress the data into
162 *
163 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
164 * @param fix_type GPS fix type.
165 * @param lat [degE7] Latitude (WGS84, EGM96 ellipsoid)
166 * @param lon [degE7] Longitude (WGS84, EGM96 ellipsoid)
167 * @param alt [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.
168 * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
169 * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
170 * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX
171 * @param cog [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
172 * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX
173 * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.
174 * @param h_acc [mm] Position uncertainty.
175 * @param v_acc [mm] Altitude uncertainty.
176 * @param vel_acc [mm/s] Speed uncertainty.
177 * @param hdg_acc [degE5] Heading / track uncertainty
178 * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.
179 * @return length of the message in bytes (excluding serial stream start sign)
180 */
181static inline uint16_t mavlink_msg_gps_raw_int_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
182 uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc, uint16_t yaw)
183{
184#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
186 _mav_put_uint64_t(buf, 0, time_usec);
187 _mav_put_int32_t(buf, 8, lat);
188 _mav_put_int32_t(buf, 12, lon);
189 _mav_put_int32_t(buf, 16, alt);
190 _mav_put_uint16_t(buf, 20, eph);
191 _mav_put_uint16_t(buf, 22, epv);
192 _mav_put_uint16_t(buf, 24, vel);
193 _mav_put_uint16_t(buf, 26, cog);
194 _mav_put_uint8_t(buf, 28, fix_type);
195 _mav_put_uint8_t(buf, 29, satellites_visible);
196 _mav_put_int32_t(buf, 30, alt_ellipsoid);
197 _mav_put_uint32_t(buf, 34, h_acc);
198 _mav_put_uint32_t(buf, 38, v_acc);
199 _mav_put_uint32_t(buf, 42, vel_acc);
200 _mav_put_uint32_t(buf, 46, hdg_acc);
201 _mav_put_uint16_t(buf, 50, yaw);
202
203 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
204#else
205 mavlink_gps_raw_int_t packet;
206 packet.time_usec = time_usec;
207 packet.lat = lat;
208 packet.lon = lon;
209 packet.alt = alt;
210 packet.eph = eph;
211 packet.epv = epv;
212 packet.vel = vel;
213 packet.cog = cog;
214 packet.fix_type = fix_type;
215 packet.satellites_visible = satellites_visible;
216 packet.alt_ellipsoid = alt_ellipsoid;
217 packet.h_acc = h_acc;
218 packet.v_acc = v_acc;
219 packet.vel_acc = vel_acc;
220 packet.hdg_acc = hdg_acc;
221 packet.yaw = yaw;
222
223 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
224#endif
225
226 msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT;
227#if MAVLINK_CRC_EXTRA
228 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
229#else
230 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
231#endif
232}
233
234/**
235 * @brief Pack a gps_raw_int message on a channel
236 * @param system_id ID of this system
237 * @param component_id ID of this component (e.g. 200 for IMU)
238 * @param chan The MAVLink channel this message will be sent over
239 * @param msg The MAVLink message to compress the data into
240 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
241 * @param fix_type GPS fix type.
242 * @param lat [degE7] Latitude (WGS84, EGM96 ellipsoid)
243 * @param lon [degE7] Longitude (WGS84, EGM96 ellipsoid)
244 * @param alt [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.
245 * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
246 * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
247 * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX
248 * @param cog [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
249 * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX
250 * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.
251 * @param h_acc [mm] Position uncertainty.
252 * @param v_acc [mm] Altitude uncertainty.
253 * @param vel_acc [mm/s] Speed uncertainty.
254 * @param hdg_acc [degE5] Heading / track uncertainty
255 * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.
256 * @return length of the message in bytes (excluding serial stream start sign)
257 */
258static inline uint16_t mavlink_msg_gps_raw_int_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
259 mavlink_message_t* msg,
260 uint64_t time_usec,uint8_t fix_type,int32_t lat,int32_t lon,int32_t alt,uint16_t eph,uint16_t epv,uint16_t vel,uint16_t cog,uint8_t satellites_visible,int32_t alt_ellipsoid,uint32_t h_acc,uint32_t v_acc,uint32_t vel_acc,uint32_t hdg_acc,uint16_t yaw)
261{
262#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
264 _mav_put_uint64_t(buf, 0, time_usec);
265 _mav_put_int32_t(buf, 8, lat);
266 _mav_put_int32_t(buf, 12, lon);
267 _mav_put_int32_t(buf, 16, alt);
268 _mav_put_uint16_t(buf, 20, eph);
269 _mav_put_uint16_t(buf, 22, epv);
270 _mav_put_uint16_t(buf, 24, vel);
271 _mav_put_uint16_t(buf, 26, cog);
272 _mav_put_uint8_t(buf, 28, fix_type);
273 _mav_put_uint8_t(buf, 29, satellites_visible);
274 _mav_put_int32_t(buf, 30, alt_ellipsoid);
275 _mav_put_uint32_t(buf, 34, h_acc);
276 _mav_put_uint32_t(buf, 38, v_acc);
277 _mav_put_uint32_t(buf, 42, vel_acc);
278 _mav_put_uint32_t(buf, 46, hdg_acc);
279 _mav_put_uint16_t(buf, 50, yaw);
280
281 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
282#else
283 mavlink_gps_raw_int_t packet;
284 packet.time_usec = time_usec;
285 packet.lat = lat;
286 packet.lon = lon;
287 packet.alt = alt;
288 packet.eph = eph;
289 packet.epv = epv;
290 packet.vel = vel;
291 packet.cog = cog;
292 packet.fix_type = fix_type;
293 packet.satellites_visible = satellites_visible;
294 packet.alt_ellipsoid = alt_ellipsoid;
295 packet.h_acc = h_acc;
296 packet.v_acc = v_acc;
297 packet.vel_acc = vel_acc;
298 packet.hdg_acc = hdg_acc;
299 packet.yaw = yaw;
300
301 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
302#endif
303
304 msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT;
305 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
306}
307
308/**
309 * @brief Encode a gps_raw_int struct
310 *
311 * @param system_id ID of this system
312 * @param component_id ID of this component (e.g. 200 for IMU)
313 * @param msg The MAVLink message to compress the data into
314 * @param gps_raw_int C-struct to read the message contents from
315 */
316static inline uint16_t mavlink_msg_gps_raw_int_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_raw_int_t* gps_raw_int)
317{
318 return mavlink_msg_gps_raw_int_pack(system_id, component_id, msg, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw);
319}
320
321/**
322 * @brief Encode a gps_raw_int struct on a channel
323 *
324 * @param system_id ID of this system
325 * @param component_id ID of this component (e.g. 200 for IMU)
326 * @param chan The MAVLink channel this message will be sent over
327 * @param msg The MAVLink message to compress the data into
328 * @param gps_raw_int C-struct to read the message contents from
329 */
330static inline uint16_t mavlink_msg_gps_raw_int_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_raw_int_t* gps_raw_int)
331{
332 return mavlink_msg_gps_raw_int_pack_chan(system_id, component_id, chan, msg, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw);
333}
334
335/**
336 * @brief Encode a gps_raw_int struct with provided status structure
337 *
338 * @param system_id ID of this system
339 * @param component_id ID of this component (e.g. 200 for IMU)
340 * @param status MAVLink status structure
341 * @param msg The MAVLink message to compress the data into
342 * @param gps_raw_int C-struct to read the message contents from
343 */
344static inline uint16_t mavlink_msg_gps_raw_int_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_gps_raw_int_t* gps_raw_int)
345{
346 return mavlink_msg_gps_raw_int_pack_status(system_id, component_id, _status, msg, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw);
347}
348
349/**
350 * @brief Send a gps_raw_int message
351 * @param chan MAVLink channel to send the message
352 *
353 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
354 * @param fix_type GPS fix type.
355 * @param lat [degE7] Latitude (WGS84, EGM96 ellipsoid)
356 * @param lon [degE7] Longitude (WGS84, EGM96 ellipsoid)
357 * @param alt [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.
358 * @param eph GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
359 * @param epv GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
360 * @param vel [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX
361 * @param cog [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
362 * @param satellites_visible Number of satellites visible. If unknown, set to UINT8_MAX
363 * @param alt_ellipsoid [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.
364 * @param h_acc [mm] Position uncertainty.
365 * @param v_acc [mm] Altitude uncertainty.
366 * @param vel_acc [mm/s] Speed uncertainty.
367 * @param hdg_acc [degE5] Heading / track uncertainty
368 * @param yaw [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.
369 */
370#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
371
372static inline void mavlink_msg_gps_raw_int_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc, uint16_t yaw)
373{
374#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
375 char buf[MAVLINK_MSG_ID_GPS_RAW_INT_LEN];
376 _mav_put_uint64_t(buf, 0, time_usec);
377 _mav_put_int32_t(buf, 8, lat);
378 _mav_put_int32_t(buf, 12, lon);
379 _mav_put_int32_t(buf, 16, alt);
380 _mav_put_uint16_t(buf, 20, eph);
381 _mav_put_uint16_t(buf, 22, epv);
382 _mav_put_uint16_t(buf, 24, vel);
383 _mav_put_uint16_t(buf, 26, cog);
384 _mav_put_uint8_t(buf, 28, fix_type);
385 _mav_put_uint8_t(buf, 29, satellites_visible);
386 _mav_put_int32_t(buf, 30, alt_ellipsoid);
387 _mav_put_uint32_t(buf, 34, h_acc);
388 _mav_put_uint32_t(buf, 38, v_acc);
389 _mav_put_uint32_t(buf, 42, vel_acc);
390 _mav_put_uint32_t(buf, 46, hdg_acc);
391 _mav_put_uint16_t(buf, 50, yaw);
392
393 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RAW_INT, buf, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
394#else
395 mavlink_gps_raw_int_t packet;
396 packet.time_usec = time_usec;
397 packet.lat = lat;
398 packet.lon = lon;
399 packet.alt = alt;
400 packet.eph = eph;
401 packet.epv = epv;
402 packet.vel = vel;
403 packet.cog = cog;
404 packet.fix_type = fix_type;
405 packet.satellites_visible = satellites_visible;
406 packet.alt_ellipsoid = alt_ellipsoid;
407 packet.h_acc = h_acc;
408 packet.v_acc = v_acc;
409 packet.vel_acc = vel_acc;
410 packet.hdg_acc = hdg_acc;
411 packet.yaw = yaw;
412
413 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RAW_INT, (const char *)&packet, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
414#endif
415}
416
417/**
418 * @brief Send a gps_raw_int message
419 * @param chan MAVLink channel to send the message
420 * @param struct The MAVLink struct to serialize
421 */
422static inline void mavlink_msg_gps_raw_int_send_struct(mavlink_channel_t chan, const mavlink_gps_raw_int_t* gps_raw_int)
423{
424#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
425 mavlink_msg_gps_raw_int_send(chan, gps_raw_int->time_usec, gps_raw_int->fix_type, gps_raw_int->lat, gps_raw_int->lon, gps_raw_int->alt, gps_raw_int->eph, gps_raw_int->epv, gps_raw_int->vel, gps_raw_int->cog, gps_raw_int->satellites_visible, gps_raw_int->alt_ellipsoid, gps_raw_int->h_acc, gps_raw_int->v_acc, gps_raw_int->vel_acc, gps_raw_int->hdg_acc, gps_raw_int->yaw);
426#else
427 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RAW_INT, (const char *)gps_raw_int, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
428#endif
429}
430
431#if MAVLINK_MSG_ID_GPS_RAW_INT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
432/*
433 This variant of _send() can be used to save stack space by reusing
434 memory from the receive buffer. The caller provides a
435 mavlink_message_t which is the size of a full mavlink message. This
436 is usually the receive buffer for the channel, and allows a reply to an
437 incoming message with minimum stack space usage.
438 */
439static inline void mavlink_msg_gps_raw_int_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, uint16_t cog, uint8_t satellites_visible, int32_t alt_ellipsoid, uint32_t h_acc, uint32_t v_acc, uint32_t vel_acc, uint32_t hdg_acc, uint16_t yaw)
440{
441#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
442 char *buf = (char *)msgbuf;
443 _mav_put_uint64_t(buf, 0, time_usec);
444 _mav_put_int32_t(buf, 8, lat);
445 _mav_put_int32_t(buf, 12, lon);
446 _mav_put_int32_t(buf, 16, alt);
447 _mav_put_uint16_t(buf, 20, eph);
448 _mav_put_uint16_t(buf, 22, epv);
449 _mav_put_uint16_t(buf, 24, vel);
450 _mav_put_uint16_t(buf, 26, cog);
451 _mav_put_uint8_t(buf, 28, fix_type);
452 _mav_put_uint8_t(buf, 29, satellites_visible);
453 _mav_put_int32_t(buf, 30, alt_ellipsoid);
454 _mav_put_uint32_t(buf, 34, h_acc);
455 _mav_put_uint32_t(buf, 38, v_acc);
456 _mav_put_uint32_t(buf, 42, vel_acc);
457 _mav_put_uint32_t(buf, 46, hdg_acc);
458 _mav_put_uint16_t(buf, 50, yaw);
459
460 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RAW_INT, buf, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
461#else
462 mavlink_gps_raw_int_t *packet = (mavlink_gps_raw_int_t *)msgbuf;
463 packet->time_usec = time_usec;
464 packet->lat = lat;
465 packet->lon = lon;
466 packet->alt = alt;
467 packet->eph = eph;
468 packet->epv = epv;
469 packet->vel = vel;
470 packet->cog = cog;
471 packet->fix_type = fix_type;
472 packet->satellites_visible = satellites_visible;
473 packet->alt_ellipsoid = alt_ellipsoid;
474 packet->h_acc = h_acc;
475 packet->v_acc = v_acc;
476 packet->vel_acc = vel_acc;
477 packet->hdg_acc = hdg_acc;
478 packet->yaw = yaw;
479
480 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RAW_INT, (const char *)packet, MAVLINK_MSG_ID_GPS_RAW_INT_MIN_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_LEN, MAVLINK_MSG_ID_GPS_RAW_INT_CRC);
481#endif
482}
483#endif
484
485#endif
486
487// MESSAGE GPS_RAW_INT UNPACKING
488
489
490/**
491 * @brief Get field time_usec from gps_raw_int message
492 *
493 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
494 */
495static inline uint64_t mavlink_msg_gps_raw_int_get_time_usec(const mavlink_message_t* msg)
496{
497 return _MAV_RETURN_uint64_t(msg, 0);
498}
499
500/**
501 * @brief Get field fix_type from gps_raw_int message
502 *
503 * @return GPS fix type.
504 */
505static inline uint8_t mavlink_msg_gps_raw_int_get_fix_type(const mavlink_message_t* msg)
506{
507 return _MAV_RETURN_uint8_t(msg, 28);
508}
509
510/**
511 * @brief Get field lat from gps_raw_int message
512 *
513 * @return [degE7] Latitude (WGS84, EGM96 ellipsoid)
514 */
515static inline int32_t mavlink_msg_gps_raw_int_get_lat(const mavlink_message_t* msg)
516{
517 return _MAV_RETURN_int32_t(msg, 8);
518}
519
520/**
521 * @brief Get field lon from gps_raw_int message
522 *
523 * @return [degE7] Longitude (WGS84, EGM96 ellipsoid)
524 */
525static inline int32_t mavlink_msg_gps_raw_int_get_lon(const mavlink_message_t* msg)
526{
527 return _MAV_RETURN_int32_t(msg, 12);
528}
529
530/**
531 * @brief Get field alt from gps_raw_int message
532 *
533 * @return [mm] Altitude (MSL). Positive for up. Note that virtually all GPS modules provide the MSL altitude in addition to the WGS84 altitude.
534 */
535static inline int32_t mavlink_msg_gps_raw_int_get_alt(const mavlink_message_t* msg)
536{
537 return _MAV_RETURN_int32_t(msg, 16);
538}
539
540/**
541 * @brief Get field eph from gps_raw_int message
542 *
543 * @return GPS HDOP horizontal dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
544 */
545static inline uint16_t mavlink_msg_gps_raw_int_get_eph(const mavlink_message_t* msg)
546{
547 return _MAV_RETURN_uint16_t(msg, 20);
548}
549
550/**
551 * @brief Get field epv from gps_raw_int message
552 *
553 * @return GPS VDOP vertical dilution of position (unitless * 100). If unknown, set to: UINT16_MAX
554 */
555static inline uint16_t mavlink_msg_gps_raw_int_get_epv(const mavlink_message_t* msg)
556{
557 return _MAV_RETURN_uint16_t(msg, 22);
558}
559
560/**
561 * @brief Get field vel from gps_raw_int message
562 *
563 * @return [cm/s] GPS ground speed. If unknown, set to: UINT16_MAX
564 */
565static inline uint16_t mavlink_msg_gps_raw_int_get_vel(const mavlink_message_t* msg)
566{
567 return _MAV_RETURN_uint16_t(msg, 24);
568}
569
570/**
571 * @brief Get field cog from gps_raw_int message
572 *
573 * @return [cdeg] Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
574 */
575static inline uint16_t mavlink_msg_gps_raw_int_get_cog(const mavlink_message_t* msg)
576{
577 return _MAV_RETURN_uint16_t(msg, 26);
578}
579
580/**
581 * @brief Get field satellites_visible from gps_raw_int message
582 *
583 * @return Number of satellites visible. If unknown, set to UINT8_MAX
584 */
585static inline uint8_t mavlink_msg_gps_raw_int_get_satellites_visible(const mavlink_message_t* msg)
586{
587 return _MAV_RETURN_uint8_t(msg, 29);
588}
589
590/**
591 * @brief Get field alt_ellipsoid from gps_raw_int message
592 *
593 * @return [mm] Altitude (above WGS84, EGM96 ellipsoid). Positive for up.
594 */
595static inline int32_t mavlink_msg_gps_raw_int_get_alt_ellipsoid(const mavlink_message_t* msg)
596{
597 return _MAV_RETURN_int32_t(msg, 30);
598}
599
600/**
601 * @brief Get field h_acc from gps_raw_int message
602 *
603 * @return [mm] Position uncertainty.
604 */
605static inline uint32_t mavlink_msg_gps_raw_int_get_h_acc(const mavlink_message_t* msg)
606{
607 return _MAV_RETURN_uint32_t(msg, 34);
608}
609
610/**
611 * @brief Get field v_acc from gps_raw_int message
612 *
613 * @return [mm] Altitude uncertainty.
614 */
615static inline uint32_t mavlink_msg_gps_raw_int_get_v_acc(const mavlink_message_t* msg)
616{
617 return _MAV_RETURN_uint32_t(msg, 38);
618}
619
620/**
621 * @brief Get field vel_acc from gps_raw_int message
622 *
623 * @return [mm/s] Speed uncertainty.
624 */
625static inline uint32_t mavlink_msg_gps_raw_int_get_vel_acc(const mavlink_message_t* msg)
626{
627 return _MAV_RETURN_uint32_t(msg, 42);
628}
629
630/**
631 * @brief Get field hdg_acc from gps_raw_int message
632 *
633 * @return [degE5] Heading / track uncertainty
634 */
635static inline uint32_t mavlink_msg_gps_raw_int_get_hdg_acc(const mavlink_message_t* msg)
636{
637 return _MAV_RETURN_uint32_t(msg, 46);
638}
639
640/**
641 * @brief Get field yaw from gps_raw_int message
642 *
643 * @return [cdeg] Yaw in earth frame from north. Use 0 if this GPS does not provide yaw. Use UINT16_MAX if this GPS is configured to provide yaw and is currently unable to provide it. Use 36000 for north.
644 */
645static inline uint16_t mavlink_msg_gps_raw_int_get_yaw(const mavlink_message_t* msg)
646{
647 return _MAV_RETURN_uint16_t(msg, 50);
648}
649
650/**
651 * @brief Decode a gps_raw_int message into a struct
652 *
653 * @param msg The message to decode
654 * @param gps_raw_int C-struct to decode the message contents into
655 */
656static inline void mavlink_msg_gps_raw_int_decode(const mavlink_message_t* msg, mavlink_gps_raw_int_t* gps_raw_int)
657{
658#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
659 gps_raw_int->time_usec = mavlink_msg_gps_raw_int_get_time_usec(msg);
660 gps_raw_int->lat = mavlink_msg_gps_raw_int_get_lat(msg);
661 gps_raw_int->lon = mavlink_msg_gps_raw_int_get_lon(msg);
662 gps_raw_int->alt = mavlink_msg_gps_raw_int_get_alt(msg);
663 gps_raw_int->eph = mavlink_msg_gps_raw_int_get_eph(msg);
664 gps_raw_int->epv = mavlink_msg_gps_raw_int_get_epv(msg);
665 gps_raw_int->vel = mavlink_msg_gps_raw_int_get_vel(msg);
666 gps_raw_int->cog = mavlink_msg_gps_raw_int_get_cog(msg);
667 gps_raw_int->fix_type = mavlink_msg_gps_raw_int_get_fix_type(msg);
668 gps_raw_int->satellites_visible = mavlink_msg_gps_raw_int_get_satellites_visible(msg);
669 gps_raw_int->alt_ellipsoid = mavlink_msg_gps_raw_int_get_alt_ellipsoid(msg);
670 gps_raw_int->h_acc = mavlink_msg_gps_raw_int_get_h_acc(msg);
671 gps_raw_int->v_acc = mavlink_msg_gps_raw_int_get_v_acc(msg);
672 gps_raw_int->vel_acc = mavlink_msg_gps_raw_int_get_vel_acc(msg);
673 gps_raw_int->hdg_acc = mavlink_msg_gps_raw_int_get_hdg_acc(msg);
674 gps_raw_int->yaw = mavlink_msg_gps_raw_int_get_yaw(msg);
675#else
676 uint8_t len = msg->len < MAVLINK_MSG_ID_GPS_RAW_INT_LEN? msg->len : MAVLINK_MSG_ID_GPS_RAW_INT_LEN;
677 memset(gps_raw_int, 0, MAVLINK_MSG_ID_GPS_RAW_INT_LEN);
678 memcpy(gps_raw_int, _MAV_PAYLOAD(msg), len);
679#endif
680}