RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_raw_imu.h
1#pragma once
2// MESSAGE RAW_IMU PACKING
3
4#define MAVLINK_MSG_ID_RAW_IMU 27
5
6MAVPACKED(
7typedef struct __mavlink_raw_imu_t {
8 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
9 int16_t xacc; /*< X acceleration (raw)*/
10 int16_t yacc; /*< Y acceleration (raw)*/
11 int16_t zacc; /*< Z acceleration (raw)*/
12 int16_t xgyro; /*< Angular speed around X axis (raw)*/
13 int16_t ygyro; /*< Angular speed around Y axis (raw)*/
14 int16_t zgyro; /*< Angular speed around Z axis (raw)*/
15 int16_t xmag; /*< X Magnetic field (raw)*/
16 int16_t ymag; /*< Y Magnetic field (raw)*/
17 int16_t zmag; /*< Z Magnetic field (raw)*/
18}) mavlink_raw_imu_t;
19
20#define MAVLINK_MSG_ID_RAW_IMU_LEN 26
21#define MAVLINK_MSG_ID_RAW_IMU_MIN_LEN 26
22#define MAVLINK_MSG_ID_27_LEN 26
23#define MAVLINK_MSG_ID_27_MIN_LEN 26
24
25#define MAVLINK_MSG_ID_RAW_IMU_CRC 144
26#define MAVLINK_MSG_ID_27_CRC 144
27
28
29
30#if MAVLINK_COMMAND_24BIT
31#define MAVLINK_MESSAGE_INFO_RAW_IMU { \
32 27, \
33 "RAW_IMU", \
34 10, \
35 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_imu_t, time_usec) }, \
36 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_imu_t, xacc) }, \
37 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_imu_t, yacc) }, \
38 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_imu_t, zacc) }, \
39 { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_imu_t, xgyro) }, \
40 { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_raw_imu_t, ygyro) }, \
41 { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_raw_imu_t, zgyro) }, \
42 { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_raw_imu_t, xmag) }, \
43 { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_raw_imu_t, ymag) }, \
44 { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_raw_imu_t, zmag) }, \
45 } \
46}
47#else
48#define MAVLINK_MESSAGE_INFO_RAW_IMU { \
49 "RAW_IMU", \
50 10, \
51 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_imu_t, time_usec) }, \
52 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_imu_t, xacc) }, \
53 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_imu_t, yacc) }, \
54 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_imu_t, zacc) }, \
55 { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_imu_t, xgyro) }, \
56 { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_raw_imu_t, ygyro) }, \
57 { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_raw_imu_t, zgyro) }, \
58 { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_raw_imu_t, xmag) }, \
59 { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_raw_imu_t, ymag) }, \
60 { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_raw_imu_t, zmag) }, \
61 } \
62}
63#endif
64
83static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
84 uint64_t time_usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag)
85{
86#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
87 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
88 _mav_put_uint64_t(buf, 0, time_usec);
89 _mav_put_int16_t(buf, 8, xacc);
90 _mav_put_int16_t(buf, 10, yacc);
91 _mav_put_int16_t(buf, 12, zacc);
92 _mav_put_int16_t(buf, 14, xgyro);
93 _mav_put_int16_t(buf, 16, ygyro);
94 _mav_put_int16_t(buf, 18, zgyro);
95 _mav_put_int16_t(buf, 20, xmag);
96 _mav_put_int16_t(buf, 22, ymag);
97 _mav_put_int16_t(buf, 24, zmag);
98
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
100#else
101 mavlink_raw_imu_t packet;
102 packet.time_usec = time_usec;
103 packet.xacc = xacc;
104 packet.yacc = yacc;
105 packet.zacc = zacc;
106 packet.xgyro = xgyro;
107 packet.ygyro = ygyro;
108 packet.zgyro = zgyro;
109 packet.xmag = xmag;
110 packet.ymag = ymag;
111 packet.zmag = zmag;
112
113 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
114#endif
115
116 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
117 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
118}
119
138static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
139 mavlink_message_t* msg,
140 uint64_t time_usec,int16_t xacc,int16_t yacc,int16_t zacc,int16_t xgyro,int16_t ygyro,int16_t zgyro,int16_t xmag,int16_t ymag,int16_t zmag)
141{
142#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
143 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
144 _mav_put_uint64_t(buf, 0, time_usec);
145 _mav_put_int16_t(buf, 8, xacc);
146 _mav_put_int16_t(buf, 10, yacc);
147 _mav_put_int16_t(buf, 12, zacc);
148 _mav_put_int16_t(buf, 14, xgyro);
149 _mav_put_int16_t(buf, 16, ygyro);
150 _mav_put_int16_t(buf, 18, zgyro);
151 _mav_put_int16_t(buf, 20, xmag);
152 _mav_put_int16_t(buf, 22, ymag);
153 _mav_put_int16_t(buf, 24, zmag);
154
155 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
156#else
157 mavlink_raw_imu_t packet;
158 packet.time_usec = time_usec;
159 packet.xacc = xacc;
160 packet.yacc = yacc;
161 packet.zacc = zacc;
162 packet.xgyro = xgyro;
163 packet.ygyro = ygyro;
164 packet.zgyro = zgyro;
165 packet.xmag = xmag;
166 packet.ymag = ymag;
167 packet.zmag = zmag;
168
169 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
170#endif
171
172 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
173 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
174}
175
184static inline uint16_t mavlink_msg_raw_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_raw_imu_t* raw_imu)
185{
186 return mavlink_msg_raw_imu_pack(system_id, component_id, msg, raw_imu->time_usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag);
187}
188
198static inline uint16_t mavlink_msg_raw_imu_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_raw_imu_t* raw_imu)
199{
200 return mavlink_msg_raw_imu_pack_chan(system_id, component_id, chan, msg, raw_imu->time_usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag);
201}
202
218#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
219
220static inline void mavlink_msg_raw_imu_send(mavlink_channel_t chan, uint64_t time_usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag)
221{
222#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
223 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
224 _mav_put_uint64_t(buf, 0, time_usec);
225 _mav_put_int16_t(buf, 8, xacc);
226 _mav_put_int16_t(buf, 10, yacc);
227 _mav_put_int16_t(buf, 12, zacc);
228 _mav_put_int16_t(buf, 14, xgyro);
229 _mav_put_int16_t(buf, 16, ygyro);
230 _mav_put_int16_t(buf, 18, zgyro);
231 _mav_put_int16_t(buf, 20, xmag);
232 _mav_put_int16_t(buf, 22, ymag);
233 _mav_put_int16_t(buf, 24, zmag);
234
235 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
236#else
237 mavlink_raw_imu_t packet;
238 packet.time_usec = time_usec;
239 packet.xacc = xacc;
240 packet.yacc = yacc;
241 packet.zacc = zacc;
242 packet.xgyro = xgyro;
243 packet.ygyro = ygyro;
244 packet.zgyro = zgyro;
245 packet.xmag = xmag;
246 packet.ymag = ymag;
247 packet.zmag = zmag;
248
249 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)&packet, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
250#endif
251}
252
258static inline void mavlink_msg_raw_imu_send_struct(mavlink_channel_t chan, const mavlink_raw_imu_t* raw_imu)
259{
260#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
261 mavlink_msg_raw_imu_send(chan, raw_imu->time_usec, raw_imu->xacc, raw_imu->yacc, raw_imu->zacc, raw_imu->xgyro, raw_imu->ygyro, raw_imu->zgyro, raw_imu->xmag, raw_imu->ymag, raw_imu->zmag);
262#else
263 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)raw_imu, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
264#endif
265}
266
267#if MAVLINK_MSG_ID_RAW_IMU_LEN <= MAVLINK_MAX_PAYLOAD_LEN
268/*
269 This varient of _send() can be used to save stack space by re-using
270 memory from the receive buffer. The caller provides a
271 mavlink_message_t which is the size of a full mavlink message. This
272 is usually the receive buffer for the channel, and allows a reply to an
273 incoming message with minimum stack space usage.
274 */
275static inline void mavlink_msg_raw_imu_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag)
276{
277#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
278 char *buf = (char *)msgbuf;
279 _mav_put_uint64_t(buf, 0, time_usec);
280 _mav_put_int16_t(buf, 8, xacc);
281 _mav_put_int16_t(buf, 10, yacc);
282 _mav_put_int16_t(buf, 12, zacc);
283 _mav_put_int16_t(buf, 14, xgyro);
284 _mav_put_int16_t(buf, 16, ygyro);
285 _mav_put_int16_t(buf, 18, zgyro);
286 _mav_put_int16_t(buf, 20, xmag);
287 _mav_put_int16_t(buf, 22, ymag);
288 _mav_put_int16_t(buf, 24, zmag);
289
290 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
291#else
292 mavlink_raw_imu_t *packet = (mavlink_raw_imu_t *)msgbuf;
293 packet->time_usec = time_usec;
294 packet->xacc = xacc;
295 packet->yacc = yacc;
296 packet->zacc = zacc;
297 packet->xgyro = xgyro;
298 packet->ygyro = ygyro;
299 packet->zgyro = zgyro;
300 packet->xmag = xmag;
301 packet->ymag = ymag;
302 packet->zmag = zmag;
303
304 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)packet, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
305#endif
306}
307#endif
308
309#endif
310
311// MESSAGE RAW_IMU UNPACKING
312
313
319static inline uint64_t mavlink_msg_raw_imu_get_time_usec(const mavlink_message_t* msg)
320{
321 return _MAV_RETURN_uint64_t(msg, 0);
322}
323
329static inline int16_t mavlink_msg_raw_imu_get_xacc(const mavlink_message_t* msg)
330{
331 return _MAV_RETURN_int16_t(msg, 8);
332}
333
339static inline int16_t mavlink_msg_raw_imu_get_yacc(const mavlink_message_t* msg)
340{
341 return _MAV_RETURN_int16_t(msg, 10);
342}
343
349static inline int16_t mavlink_msg_raw_imu_get_zacc(const mavlink_message_t* msg)
350{
351 return _MAV_RETURN_int16_t(msg, 12);
352}
353
359static inline int16_t mavlink_msg_raw_imu_get_xgyro(const mavlink_message_t* msg)
360{
361 return _MAV_RETURN_int16_t(msg, 14);
362}
363
369static inline int16_t mavlink_msg_raw_imu_get_ygyro(const mavlink_message_t* msg)
370{
371 return _MAV_RETURN_int16_t(msg, 16);
372}
373
379static inline int16_t mavlink_msg_raw_imu_get_zgyro(const mavlink_message_t* msg)
380{
381 return _MAV_RETURN_int16_t(msg, 18);
382}
383
389static inline int16_t mavlink_msg_raw_imu_get_xmag(const mavlink_message_t* msg)
390{
391 return _MAV_RETURN_int16_t(msg, 20);
392}
393
399static inline int16_t mavlink_msg_raw_imu_get_ymag(const mavlink_message_t* msg)
400{
401 return _MAV_RETURN_int16_t(msg, 22);
402}
403
409static inline int16_t mavlink_msg_raw_imu_get_zmag(const mavlink_message_t* msg)
410{
411 return _MAV_RETURN_int16_t(msg, 24);
412}
413
420static inline void mavlink_msg_raw_imu_decode(const mavlink_message_t* msg, mavlink_raw_imu_t* raw_imu)
421{
422#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
423 raw_imu->time_usec = mavlink_msg_raw_imu_get_time_usec(msg);
424 raw_imu->xacc = mavlink_msg_raw_imu_get_xacc(msg);
425 raw_imu->yacc = mavlink_msg_raw_imu_get_yacc(msg);
426 raw_imu->zacc = mavlink_msg_raw_imu_get_zacc(msg);
427 raw_imu->xgyro = mavlink_msg_raw_imu_get_xgyro(msg);
428 raw_imu->ygyro = mavlink_msg_raw_imu_get_ygyro(msg);
429 raw_imu->zgyro = mavlink_msg_raw_imu_get_zgyro(msg);
430 raw_imu->xmag = mavlink_msg_raw_imu_get_xmag(msg);
431 raw_imu->ymag = mavlink_msg_raw_imu_get_ymag(msg);
432 raw_imu->zmag = mavlink_msg_raw_imu_get_zmag(msg);
433#else
434 uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_IMU_LEN? msg->len : MAVLINK_MSG_ID_RAW_IMU_LEN;
435 memset(raw_imu, 0, MAVLINK_MSG_ID_RAW_IMU_LEN);
436 memcpy(raw_imu, _MAV_PAYLOAD(msg), len);
437#endif
438}