mavlink_msg_raw_imu.h
Go to the documentation of this file.
1 // MESSAGE RAW_IMU PACKING
2 
3 #define MAVLINK_MSG_ID_RAW_IMU 27
4 
5 typedef struct __mavlink_raw_imu_t
6 {
7  uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
8  int16_t xacc; /*< X acceleration (raw)*/
9  int16_t yacc; /*< Y acceleration (raw)*/
10  int16_t zacc; /*< Z acceleration (raw)*/
11  int16_t xgyro; /*< Angular speed around X axis (raw)*/
12  int16_t ygyro; /*< Angular speed around Y axis (raw)*/
13  int16_t zgyro; /*< Angular speed around Z axis (raw)*/
14  int16_t xmag; /*< X Magnetic field (raw)*/
15  int16_t ymag; /*< Y Magnetic field (raw)*/
16  int16_t zmag; /*< Z Magnetic field (raw)*/
18 
19 #define MAVLINK_MSG_ID_RAW_IMU_LEN 26
20 #define MAVLINK_MSG_ID_27_LEN 26
21 
22 #define MAVLINK_MSG_ID_RAW_IMU_CRC 144
23 #define MAVLINK_MSG_ID_27_CRC 144
24 
25 
26 
27 #define MAVLINK_MESSAGE_INFO_RAW_IMU { \
28  "RAW_IMU", \
29  10, \
30  { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_imu_t, time_usec) }, \
31  { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_imu_t, xacc) }, \
32  { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_imu_t, yacc) }, \
33  { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_imu_t, zacc) }, \
34  { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_imu_t, xgyro) }, \
35  { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_raw_imu_t, ygyro) }, \
36  { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_raw_imu_t, zgyro) }, \
37  { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_raw_imu_t, xmag) }, \
38  { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_raw_imu_t, ymag) }, \
39  { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_raw_imu_t, zmag) }, \
40  } \
41 }
42 
43 
62 static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63  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)
64 {
65 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67  _mav_put_uint64_t(buf, 0, time_usec);
68  _mav_put_int16_t(buf, 8, xacc);
69  _mav_put_int16_t(buf, 10, yacc);
70  _mav_put_int16_t(buf, 12, zacc);
71  _mav_put_int16_t(buf, 14, xgyro);
72  _mav_put_int16_t(buf, 16, ygyro);
73  _mav_put_int16_t(buf, 18, zgyro);
74  _mav_put_int16_t(buf, 20, xmag);
75  _mav_put_int16_t(buf, 22, ymag);
76  _mav_put_int16_t(buf, 24, zmag);
77 
79 #else
80  mavlink_raw_imu_t packet;
81  packet.time_usec = time_usec;
82  packet.xacc = xacc;
83  packet.yacc = yacc;
84  packet.zacc = zacc;
85  packet.xgyro = xgyro;
86  packet.ygyro = ygyro;
87  packet.zgyro = zgyro;
88  packet.xmag = xmag;
89  packet.ymag = ymag;
90  packet.zmag = zmag;
91 
93 #endif
94 
95  msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
96 #if MAVLINK_CRC_EXTRA
98 #else
99  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_RAW_IMU_LEN);
100 #endif
101 }
102 
121 static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
122  mavlink_message_t* msg,
123  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)
124 {
125 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
126  char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
127  _mav_put_uint64_t(buf, 0, time_usec);
128  _mav_put_int16_t(buf, 8, xacc);
129  _mav_put_int16_t(buf, 10, yacc);
130  _mav_put_int16_t(buf, 12, zacc);
131  _mav_put_int16_t(buf, 14, xgyro);
132  _mav_put_int16_t(buf, 16, ygyro);
133  _mav_put_int16_t(buf, 18, zgyro);
134  _mav_put_int16_t(buf, 20, xmag);
135  _mav_put_int16_t(buf, 22, ymag);
136  _mav_put_int16_t(buf, 24, zmag);
137 
139 #else
140  mavlink_raw_imu_t packet;
141  packet.time_usec = time_usec;
142  packet.xacc = xacc;
143  packet.yacc = yacc;
144  packet.zacc = zacc;
145  packet.xgyro = xgyro;
146  packet.ygyro = ygyro;
147  packet.zgyro = zgyro;
148  packet.xmag = xmag;
149  packet.ymag = ymag;
150  packet.zmag = zmag;
151 
152  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
153 #endif
154 
155  msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
156 #if MAVLINK_CRC_EXTRA
157  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
158 #else
159  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_RAW_IMU_LEN);
160 #endif
161 }
162 
171 static 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)
172 {
173  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);
174 }
175 
185 static 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)
186 {
187  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);
188 }
189 
205 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
206 
207 static 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)
208 {
209 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
210  char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
211  _mav_put_uint64_t(buf, 0, time_usec);
212  _mav_put_int16_t(buf, 8, xacc);
213  _mav_put_int16_t(buf, 10, yacc);
214  _mav_put_int16_t(buf, 12, zacc);
215  _mav_put_int16_t(buf, 14, xgyro);
216  _mav_put_int16_t(buf, 16, ygyro);
217  _mav_put_int16_t(buf, 18, zgyro);
218  _mav_put_int16_t(buf, 20, xmag);
219  _mav_put_int16_t(buf, 22, ymag);
220  _mav_put_int16_t(buf, 24, zmag);
221 
222 #if MAVLINK_CRC_EXTRA
223  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
224 #else
225  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
226 #endif
227 #else
228  mavlink_raw_imu_t packet;
229  packet.time_usec = time_usec;
230  packet.xacc = xacc;
231  packet.yacc = yacc;
232  packet.zacc = zacc;
233  packet.xgyro = xgyro;
234  packet.ygyro = ygyro;
235  packet.zgyro = zgyro;
236  packet.xmag = xmag;
237  packet.ymag = ymag;
238  packet.zmag = zmag;
239 
240 #if MAVLINK_CRC_EXTRA
241  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)&packet, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
242 #else
243  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)&packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
244 #endif
245 #endif
246 }
247 
248 #if MAVLINK_MSG_ID_RAW_IMU_LEN <= MAVLINK_MAX_PAYLOAD_LEN
249 /*
250  This varient of _send() can be used to save stack space by re-using
251  memory from the receive buffer. The caller provides a
252  mavlink_message_t which is the size of a full mavlink message. This
253  is usually the receive buffer for the channel, and allows a reply to an
254  incoming message with minimum stack space usage.
255  */
256 static 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)
257 {
258 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
259  char *buf = (char *)msgbuf;
260  _mav_put_uint64_t(buf, 0, time_usec);
261  _mav_put_int16_t(buf, 8, xacc);
262  _mav_put_int16_t(buf, 10, yacc);
263  _mav_put_int16_t(buf, 12, zacc);
264  _mav_put_int16_t(buf, 14, xgyro);
265  _mav_put_int16_t(buf, 16, ygyro);
266  _mav_put_int16_t(buf, 18, zgyro);
267  _mav_put_int16_t(buf, 20, xmag);
268  _mav_put_int16_t(buf, 22, ymag);
269  _mav_put_int16_t(buf, 24, zmag);
270 
271 #if MAVLINK_CRC_EXTRA
272  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
273 #else
274  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
275 #endif
276 #else
277  mavlink_raw_imu_t *packet = (mavlink_raw_imu_t *)msgbuf;
278  packet->time_usec = time_usec;
279  packet->xacc = xacc;
280  packet->yacc = yacc;
281  packet->zacc = zacc;
282  packet->xgyro = xgyro;
283  packet->ygyro = ygyro;
284  packet->zgyro = zgyro;
285  packet->xmag = xmag;
286  packet->ymag = ymag;
287  packet->zmag = zmag;
288 
289 #if MAVLINK_CRC_EXTRA
290  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)packet, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
291 #else
292  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RAW_IMU, (const char *)packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
293 #endif
294 #endif
295 }
296 #endif
297 
298 #endif
299 
300 // MESSAGE RAW_IMU UNPACKING
301 
302 
308 static inline uint64_t mavlink_msg_raw_imu_get_time_usec(const mavlink_message_t* msg)
309 {
310  return _MAV_RETURN_uint64_t(msg, 0);
311 }
312 
318 static inline int16_t mavlink_msg_raw_imu_get_xacc(const mavlink_message_t* msg)
319 {
320  return _MAV_RETURN_int16_t(msg, 8);
321 }
322 
328 static inline int16_t mavlink_msg_raw_imu_get_yacc(const mavlink_message_t* msg)
329 {
330  return _MAV_RETURN_int16_t(msg, 10);
331 }
332 
338 static inline int16_t mavlink_msg_raw_imu_get_zacc(const mavlink_message_t* msg)
339 {
340  return _MAV_RETURN_int16_t(msg, 12);
341 }
342 
348 static inline int16_t mavlink_msg_raw_imu_get_xgyro(const mavlink_message_t* msg)
349 {
350  return _MAV_RETURN_int16_t(msg, 14);
351 }
352 
358 static inline int16_t mavlink_msg_raw_imu_get_ygyro(const mavlink_message_t* msg)
359 {
360  return _MAV_RETURN_int16_t(msg, 16);
361 }
362 
368 static inline int16_t mavlink_msg_raw_imu_get_zgyro(const mavlink_message_t* msg)
369 {
370  return _MAV_RETURN_int16_t(msg, 18);
371 }
372 
378 static inline int16_t mavlink_msg_raw_imu_get_xmag(const mavlink_message_t* msg)
379 {
380  return _MAV_RETURN_int16_t(msg, 20);
381 }
382 
388 static inline int16_t mavlink_msg_raw_imu_get_ymag(const mavlink_message_t* msg)
389 {
390  return _MAV_RETURN_int16_t(msg, 22);
391 }
392 
398 static inline int16_t mavlink_msg_raw_imu_get_zmag(const mavlink_message_t* msg)
399 {
400  return _MAV_RETURN_int16_t(msg, 24);
401 }
402 
409 static inline void mavlink_msg_raw_imu_decode(const mavlink_message_t* msg, mavlink_raw_imu_t* raw_imu)
410 {
411 #if MAVLINK_NEED_BYTE_SWAP
413  raw_imu->xacc = mavlink_msg_raw_imu_get_xacc(msg);
414  raw_imu->yacc = mavlink_msg_raw_imu_get_yacc(msg);
415  raw_imu->zacc = mavlink_msg_raw_imu_get_zacc(msg);
416  raw_imu->xgyro = mavlink_msg_raw_imu_get_xgyro(msg);
417  raw_imu->ygyro = mavlink_msg_raw_imu_get_ygyro(msg);
418  raw_imu->zgyro = mavlink_msg_raw_imu_get_zgyro(msg);
419  raw_imu->xmag = mavlink_msg_raw_imu_get_xmag(msg);
420  raw_imu->ymag = mavlink_msg_raw_imu_get_ymag(msg);
421  raw_imu->zmag = mavlink_msg_raw_imu_get_zmag(msg);
422 #else
423  memcpy(raw_imu, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_RAW_IMU_LEN);
424 #endif
425 }
#define _mav_put_uint64_t(buf, wire_offset, b)
Definition: protocol.h:149
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:146


rosflight
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:09:26