RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_local_position_ned.h
1#pragma once
2// MESSAGE LOCAL_POSITION_NED PACKING
3
4#define MAVLINK_MSG_ID_LOCAL_POSITION_NED 32
5
6MAVPACKED(
7typedef struct __mavlink_local_position_ned_t {
8 uint32_t time_boot_ms; /*< Timestamp (milliseconds since system boot)*/
9 float x; /*< X Position*/
10 float y; /*< Y Position*/
11 float z; /*< Z Position*/
12 float vx; /*< X Speed*/
13 float vy; /*< Y Speed*/
14 float vz; /*< Z Speed*/
15}) mavlink_local_position_ned_t;
16
17#define MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN 28
18#define MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN 28
19#define MAVLINK_MSG_ID_32_LEN 28
20#define MAVLINK_MSG_ID_32_MIN_LEN 28
21
22#define MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC 185
23#define MAVLINK_MSG_ID_32_CRC 185
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED { \
29 32, \
30 "LOCAL_POSITION_NED", \
31 7, \
32 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_local_position_ned_t, time_boot_ms) }, \
33 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_local_position_ned_t, x) }, \
34 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_local_position_ned_t, y) }, \
35 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_local_position_ned_t, z) }, \
36 { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_local_position_ned_t, vx) }, \
37 { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_local_position_ned_t, vy) }, \
38 { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_local_position_ned_t, vz) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED { \
43 "LOCAL_POSITION_NED", \
44 7, \
45 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_local_position_ned_t, time_boot_ms) }, \
46 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_local_position_ned_t, x) }, \
47 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_local_position_ned_t, y) }, \
48 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_local_position_ned_t, z) }, \
49 { "vx", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_local_position_ned_t, vx) }, \
50 { "vy", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_local_position_ned_t, vy) }, \
51 { "vz", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_local_position_ned_t, vz) }, \
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a local_position_ned message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
61 *
62 * @param time_boot_ms Timestamp (milliseconds since system boot)
63 * @param x X Position
64 * @param y Y Position
65 * @param z Z Position
66 * @param vx X Speed
67 * @param vy Y Speed
68 * @param vz Z Speed
69 * @return length of the message in bytes (excluding serial stream start sign)
70 */
71static inline uint16_t mavlink_msg_local_position_ned_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN];
76 _mav_put_uint32_t(buf, 0, time_boot_ms);
77 _mav_put_float(buf, 4, x);
78 _mav_put_float(buf, 8, y);
79 _mav_put_float(buf, 12, z);
80 _mav_put_float(buf, 16, vx);
81 _mav_put_float(buf, 20, vy);
82 _mav_put_float(buf, 24, vz);
83
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN);
85#else
86 mavlink_local_position_ned_t packet;
87 packet.time_boot_ms = time_boot_ms;
88 packet.x = x;
89 packet.y = y;
90 packet.z = z;
91 packet.vx = vx;
92 packet.vy = vy;
93 packet.vz = vz;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
100}
101
102/**
103 * @brief Pack a local_position_ned message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param time_boot_ms Timestamp (milliseconds since system boot)
109 * @param x X Position
110 * @param y Y Position
111 * @param z Z Position
112 * @param vx X Speed
113 * @param vy Y Speed
114 * @param vz Z Speed
115 * @return length of the message in bytes (excluding serial stream start sign)
116 */
117static inline uint16_t mavlink_msg_local_position_ned_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 uint32_t time_boot_ms,float x,float y,float z,float vx,float vy,float vz)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN];
123 _mav_put_uint32_t(buf, 0, time_boot_ms);
124 _mav_put_float(buf, 4, x);
125 _mav_put_float(buf, 8, y);
126 _mav_put_float(buf, 12, z);
127 _mav_put_float(buf, 16, vx);
128 _mav_put_float(buf, 20, vy);
129 _mav_put_float(buf, 24, vz);
130
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN);
132#else
133 mavlink_local_position_ned_t packet;
134 packet.time_boot_ms = time_boot_ms;
135 packet.x = x;
136 packet.y = y;
137 packet.z = z;
138 packet.vx = vx;
139 packet.vy = vy;
140 packet.vz = vz;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
147}
148
149/**
150 * @brief Encode a local_position_ned struct
151 *
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param local_position_ned C-struct to read the message contents from
156 */
157static inline uint16_t mavlink_msg_local_position_ned_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_local_position_ned_t* local_position_ned)
158{
159 return mavlink_msg_local_position_ned_pack(system_id, component_id, msg, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz);
160}
161
162/**
163 * @brief Encode a local_position_ned struct on a channel
164 *
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param local_position_ned C-struct to read the message contents from
170 */
171static inline uint16_t mavlink_msg_local_position_ned_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_local_position_ned_t* local_position_ned)
172{
173 return mavlink_msg_local_position_ned_pack_chan(system_id, component_id, chan, msg, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz);
174}
175
176/**
177 * @brief Send a local_position_ned message
178 * @param chan MAVLink channel to send the message
179 *
180 * @param time_boot_ms Timestamp (milliseconds since system boot)
181 * @param x X Position
182 * @param y Y Position
183 * @param z Z Position
184 * @param vx X Speed
185 * @param vy Y Speed
186 * @param vz Z Speed
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_local_position_ned_send(mavlink_channel_t chan, uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN];
194 _mav_put_uint32_t(buf, 0, time_boot_ms);
195 _mav_put_float(buf, 4, x);
196 _mav_put_float(buf, 8, y);
197 _mav_put_float(buf, 12, z);
198 _mav_put_float(buf, 16, vx);
199 _mav_put_float(buf, 20, vy);
200 _mav_put_float(buf, 24, vz);
201
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
203#else
204 mavlink_local_position_ned_t packet;
205 packet.time_boot_ms = time_boot_ms;
206 packet.x = x;
207 packet.y = y;
208 packet.z = z;
209 packet.vx = vx;
210 packet.vy = vy;
211 packet.vz = vz;
212
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, (const char *)&packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
214#endif
215}
216
217/**
218 * @brief Send a local_position_ned message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
221 */
222static inline void mavlink_msg_local_position_ned_send_struct(mavlink_channel_t chan, const mavlink_local_position_ned_t* local_position_ned)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_local_position_ned_send(chan, local_position_ned->time_boot_ms, local_position_ned->x, local_position_ned->y, local_position_ned->z, local_position_ned->vx, local_position_ned->vy, local_position_ned->vz);
226#else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, (const char *)local_position_ned, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
228#endif
229}
230
231#if MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN <= MAVLINK_MAX_PAYLOAD_LEN
232/*
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
238 */
239static inline void mavlink_msg_local_position_ned_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, float x, float y, float z, float vx, float vy, float vz)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_uint32_t(buf, 0, time_boot_ms);
244 _mav_put_float(buf, 4, x);
245 _mav_put_float(buf, 8, y);
246 _mav_put_float(buf, 12, z);
247 _mav_put_float(buf, 16, vx);
248 _mav_put_float(buf, 20, vy);
249 _mav_put_float(buf, 24, vz);
250
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, buf, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
252#else
253 mavlink_local_position_ned_t *packet = (mavlink_local_position_ned_t *)msgbuf;
254 packet->time_boot_ms = time_boot_ms;
255 packet->x = x;
256 packet->y = y;
257 packet->z = z;
258 packet->vx = vx;
259 packet->vy = vy;
260 packet->vz = vz;
261
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED, (const char *)packet, MAVLINK_MSG_ID_LOCAL_POSITION_NED_MIN_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN, MAVLINK_MSG_ID_LOCAL_POSITION_NED_CRC);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE LOCAL_POSITION_NED UNPACKING
270
271
272/**
273 * @brief Get field time_boot_ms from local_position_ned message
274 *
275 * @return Timestamp (milliseconds since system boot)
276 */
277static inline uint32_t mavlink_msg_local_position_ned_get_time_boot_ms(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_uint32_t(msg, 0);
280}
281
282/**
283 * @brief Get field x from local_position_ned message
284 *
285 * @return X Position
286 */
287static inline float mavlink_msg_local_position_ned_get_x(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_float(msg, 4);
290}
291
292/**
293 * @brief Get field y from local_position_ned message
294 *
295 * @return Y Position
296 */
297static inline float mavlink_msg_local_position_ned_get_y(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_float(msg, 8);
300}
301
302/**
303 * @brief Get field z from local_position_ned message
304 *
305 * @return Z Position
306 */
307static inline float mavlink_msg_local_position_ned_get_z(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_float(msg, 12);
310}
311
312/**
313 * @brief Get field vx from local_position_ned message
314 *
315 * @return X Speed
316 */
317static inline float mavlink_msg_local_position_ned_get_vx(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_float(msg, 16);
320}
321
322/**
323 * @brief Get field vy from local_position_ned message
324 *
325 * @return Y Speed
326 */
327static inline float mavlink_msg_local_position_ned_get_vy(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_float(msg, 20);
330}
331
332/**
333 * @brief Get field vz from local_position_ned message
334 *
335 * @return Z Speed
336 */
337static inline float mavlink_msg_local_position_ned_get_vz(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_float(msg, 24);
340}
341
342/**
343 * @brief Decode a local_position_ned message into a struct
344 *
345 * @param msg The message to decode
346 * @param local_position_ned C-struct to decode the message contents into
347 */
348static inline void mavlink_msg_local_position_ned_decode(const mavlink_message_t* msg, mavlink_local_position_ned_t* local_position_ned)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 local_position_ned->time_boot_ms = mavlink_msg_local_position_ned_get_time_boot_ms(msg);
352 local_position_ned->x = mavlink_msg_local_position_ned_get_x(msg);
353 local_position_ned->y = mavlink_msg_local_position_ned_get_y(msg);
354 local_position_ned->z = mavlink_msg_local_position_ned_get_z(msg);
355 local_position_ned->vx = mavlink_msg_local_position_ned_get_vx(msg);
356 local_position_ned->vy = mavlink_msg_local_position_ned_get_vy(msg);
357 local_position_ned->vz = mavlink_msg_local_position_ned_get_vz(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN? msg->len : MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN;
360 memset(local_position_ned, 0, MAVLINK_MSG_ID_LOCAL_POSITION_NED_LEN);
361 memcpy(local_position_ned, _MAV_PAYLOAD(msg), len);
362#endif
363}