Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_raw_imu.h
Go to the documentation of this file.
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; /*< [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 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 uint8_t id; /*< Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)*/
19 int16_t temperature; /*< [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).*/
20}) mavlink_raw_imu_t;
21
22#define MAVLINK_MSG_ID_RAW_IMU_LEN 29
23#define MAVLINK_MSG_ID_RAW_IMU_MIN_LEN 26
24#define MAVLINK_MSG_ID_27_LEN 29
25#define MAVLINK_MSG_ID_27_MIN_LEN 26
26
27#define MAVLINK_MSG_ID_RAW_IMU_CRC 144
28#define MAVLINK_MSG_ID_27_CRC 144
29
30
31
32#if MAVLINK_COMMAND_24BIT
33#define MAVLINK_MESSAGE_INFO_RAW_IMU {
34 27,
35 "RAW_IMU",
36 12,
37 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_imu_t, time_usec) },
38 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_imu_t, xacc) },
39 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_imu_t, yacc) },
40 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_imu_t, zacc) },
41 { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_imu_t, xgyro) },
42 { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_raw_imu_t, ygyro) },
43 { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_raw_imu_t, zgyro) },
44 { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_raw_imu_t, xmag) },
45 { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_raw_imu_t, ymag) },
46 { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_raw_imu_t, zmag) },
47 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_raw_imu_t, id) },
48 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 27, offsetof(mavlink_raw_imu_t, temperature) },
49 } \
50}
51#else
52#define MAVLINK_MESSAGE_INFO_RAW_IMU {
53 "RAW_IMU",
54 12,
55 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_raw_imu_t, time_usec) },
56 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_raw_imu_t, xacc) },
57 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_raw_imu_t, yacc) },
58 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_raw_imu_t, zacc) },
59 { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_raw_imu_t, xgyro) },
60 { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_raw_imu_t, ygyro) },
61 { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_raw_imu_t, zgyro) },
62 { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_raw_imu_t, xmag) },
63 { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_raw_imu_t, ymag) },
64 { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_raw_imu_t, zmag) },
65 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_raw_imu_t, id) },
66 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 27, offsetof(mavlink_raw_imu_t, temperature) },
67 } \
68}
69#endif
70
71/**
72 * @brief Pack a raw_imu message
73 * @param system_id ID of this system
74 * @param component_id ID of this component (e.g. 200 for IMU)
75 * @param msg The MAVLink message to compress the data into
76 *
77 * @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.
78 * @param xacc X acceleration (raw)
79 * @param yacc Y acceleration (raw)
80 * @param zacc Z acceleration (raw)
81 * @param xgyro Angular speed around X axis (raw)
82 * @param ygyro Angular speed around Y axis (raw)
83 * @param zgyro Angular speed around Z axis (raw)
84 * @param xmag X Magnetic field (raw)
85 * @param ymag Y Magnetic field (raw)
86 * @param zmag Z Magnetic field (raw)
87 * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
88 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
89 * @return length of the message in bytes (excluding serial stream start sign)
90 */
91static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
92 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, uint8_t id, int16_t temperature)
93{
94#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
96 _mav_put_uint64_t(buf, 0, time_usec);
97 _mav_put_int16_t(buf, 8, xacc);
98 _mav_put_int16_t(buf, 10, yacc);
99 _mav_put_int16_t(buf, 12, zacc);
100 _mav_put_int16_t(buf, 14, xgyro);
101 _mav_put_int16_t(buf, 16, ygyro);
102 _mav_put_int16_t(buf, 18, zgyro);
103 _mav_put_int16_t(buf, 20, xmag);
104 _mav_put_int16_t(buf, 22, ymag);
105 _mav_put_int16_t(buf, 24, zmag);
106 _mav_put_uint8_t(buf, 26, id);
107 _mav_put_int16_t(buf, 27, temperature);
108
109 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
110#else
111 mavlink_raw_imu_t packet;
112 packet.time_usec = time_usec;
113 packet.xacc = xacc;
114 packet.yacc = yacc;
115 packet.zacc = zacc;
116 packet.xgyro = xgyro;
117 packet.ygyro = ygyro;
118 packet.zgyro = zgyro;
119 packet.xmag = xmag;
120 packet.ymag = ymag;
121 packet.zmag = zmag;
122 packet.id = id;
123 packet.temperature = temperature;
124
125 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
126#endif
127
128 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
129 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);
130}
131
132/**
133 * @brief Pack a raw_imu message
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param status MAVLink status structure
137 * @param msg The MAVLink message to compress the data into
138 *
139 * @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.
140 * @param xacc X acceleration (raw)
141 * @param yacc Y acceleration (raw)
142 * @param zacc Z acceleration (raw)
143 * @param xgyro Angular speed around X axis (raw)
144 * @param ygyro Angular speed around Y axis (raw)
145 * @param zgyro Angular speed around Z axis (raw)
146 * @param xmag X Magnetic field (raw)
147 * @param ymag Y Magnetic field (raw)
148 * @param zmag Z Magnetic field (raw)
149 * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
150 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
151 * @return length of the message in bytes (excluding serial stream start sign)
152 */
153static inline uint16_t mavlink_msg_raw_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
154 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, uint8_t id, int16_t temperature)
155{
156#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
158 _mav_put_uint64_t(buf, 0, time_usec);
159 _mav_put_int16_t(buf, 8, xacc);
160 _mav_put_int16_t(buf, 10, yacc);
161 _mav_put_int16_t(buf, 12, zacc);
162 _mav_put_int16_t(buf, 14, xgyro);
163 _mav_put_int16_t(buf, 16, ygyro);
164 _mav_put_int16_t(buf, 18, zgyro);
165 _mav_put_int16_t(buf, 20, xmag);
166 _mav_put_int16_t(buf, 22, ymag);
167 _mav_put_int16_t(buf, 24, zmag);
168 _mav_put_uint8_t(buf, 26, id);
169 _mav_put_int16_t(buf, 27, temperature);
170
171 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
172#else
173 mavlink_raw_imu_t packet;
174 packet.time_usec = time_usec;
175 packet.xacc = xacc;
176 packet.yacc = yacc;
177 packet.zacc = zacc;
178 packet.xgyro = xgyro;
179 packet.ygyro = ygyro;
180 packet.zgyro = zgyro;
181 packet.xmag = xmag;
182 packet.ymag = ymag;
183 packet.zmag = zmag;
184 packet.id = id;
185 packet.temperature = temperature;
186
187 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
188#endif
189
190 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
191#if MAVLINK_CRC_EXTRA
192 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN, MAVLINK_MSG_ID_RAW_IMU_CRC);
193#else
194 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_RAW_IMU_MIN_LEN, MAVLINK_MSG_ID_RAW_IMU_LEN);
195#endif
196}
197
198/**
199 * @brief Pack a raw_imu message on a channel
200 * @param system_id ID of this system
201 * @param component_id ID of this component (e.g. 200 for IMU)
202 * @param chan The MAVLink channel this message will be sent over
203 * @param msg The MAVLink message to compress the data into
204 * @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.
205 * @param xacc X acceleration (raw)
206 * @param yacc Y acceleration (raw)
207 * @param zacc Z acceleration (raw)
208 * @param xgyro Angular speed around X axis (raw)
209 * @param ygyro Angular speed around Y axis (raw)
210 * @param zgyro Angular speed around Z axis (raw)
211 * @param xmag X Magnetic field (raw)
212 * @param ymag Y Magnetic field (raw)
213 * @param zmag Z Magnetic field (raw)
214 * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
215 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
216 * @return length of the message in bytes (excluding serial stream start sign)
217 */
218static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
219 mavlink_message_t* msg,
220 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,uint8_t id,int16_t temperature)
221{
222#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
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 _mav_put_uint8_t(buf, 26, id);
235 _mav_put_int16_t(buf, 27, temperature);
236
237 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_RAW_IMU_LEN);
238#else
239 mavlink_raw_imu_t packet;
240 packet.time_usec = time_usec;
241 packet.xacc = xacc;
242 packet.yacc = yacc;
243 packet.zacc = zacc;
244 packet.xgyro = xgyro;
245 packet.ygyro = ygyro;
246 packet.zgyro = zgyro;
247 packet.xmag = xmag;
248 packet.ymag = ymag;
249 packet.zmag = zmag;
250 packet.id = id;
251 packet.temperature = temperature;
252
253 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
254#endif
255
256 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
257 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);
258}
259
260/**
261 * @brief Encode a raw_imu struct
262 *
263 * @param system_id ID of this system
264 * @param component_id ID of this component (e.g. 200 for IMU)
265 * @param msg The MAVLink message to compress the data into
266 * @param raw_imu C-struct to read the message contents from
267 */
268static 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)
269{
270 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, raw_imu->id, raw_imu->temperature);
271}
272
273/**
274 * @brief Encode a raw_imu struct on a channel
275 *
276 * @param system_id ID of this system
277 * @param component_id ID of this component (e.g. 200 for IMU)
278 * @param chan The MAVLink channel this message will be sent over
279 * @param msg The MAVLink message to compress the data into
280 * @param raw_imu C-struct to read the message contents from
281 */
282static 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)
283{
284 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, raw_imu->id, raw_imu->temperature);
285}
286
287/**
288 * @brief Encode a raw_imu struct with provided status structure
289 *
290 * @param system_id ID of this system
291 * @param component_id ID of this component (e.g. 200 for IMU)
292 * @param status MAVLink status structure
293 * @param msg The MAVLink message to compress the data into
294 * @param raw_imu C-struct to read the message contents from
295 */
296static inline uint16_t mavlink_msg_raw_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_raw_imu_t* raw_imu)
297{
298 return mavlink_msg_raw_imu_pack_status(system_id, component_id, _status, 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, raw_imu->id, raw_imu->temperature);
299}
300
301/**
302 * @brief Send a raw_imu message
303 * @param chan MAVLink channel to send the message
304 *
305 * @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.
306 * @param xacc X acceleration (raw)
307 * @param yacc Y acceleration (raw)
308 * @param zacc Z acceleration (raw)
309 * @param xgyro Angular speed around X axis (raw)
310 * @param ygyro Angular speed around Y axis (raw)
311 * @param zgyro Angular speed around Z axis (raw)
312 * @param xmag X Magnetic field (raw)
313 * @param ymag Y Magnetic field (raw)
314 * @param zmag Z Magnetic field (raw)
315 * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
316 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
317 */
318#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
319
320static 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, uint8_t id, int16_t temperature)
321{
322#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
323 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
324 _mav_put_uint64_t(buf, 0, time_usec);
325 _mav_put_int16_t(buf, 8, xacc);
326 _mav_put_int16_t(buf, 10, yacc);
327 _mav_put_int16_t(buf, 12, zacc);
328 _mav_put_int16_t(buf, 14, xgyro);
329 _mav_put_int16_t(buf, 16, ygyro);
330 _mav_put_int16_t(buf, 18, zgyro);
331 _mav_put_int16_t(buf, 20, xmag);
332 _mav_put_int16_t(buf, 22, ymag);
333 _mav_put_int16_t(buf, 24, zmag);
334 _mav_put_uint8_t(buf, 26, id);
335 _mav_put_int16_t(buf, 27, temperature);
336
337 _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);
338#else
339 mavlink_raw_imu_t packet;
340 packet.time_usec = time_usec;
341 packet.xacc = xacc;
342 packet.yacc = yacc;
343 packet.zacc = zacc;
344 packet.xgyro = xgyro;
345 packet.ygyro = ygyro;
346 packet.zgyro = zgyro;
347 packet.xmag = xmag;
348 packet.ymag = ymag;
349 packet.zmag = zmag;
350 packet.id = id;
351 packet.temperature = temperature;
352
353 _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);
354#endif
355}
356
357/**
358 * @brief Send a raw_imu message
359 * @param chan MAVLink channel to send the message
360 * @param struct The MAVLink struct to serialize
361 */
362static inline void mavlink_msg_raw_imu_send_struct(mavlink_channel_t chan, const mavlink_raw_imu_t* raw_imu)
363{
364#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
365 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, raw_imu->id, raw_imu->temperature);
366#else
367 _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);
368#endif
369}
370
371#if MAVLINK_MSG_ID_RAW_IMU_LEN <= MAVLINK_MAX_PAYLOAD_LEN
372/*
373 This variant of _send() can be used to save stack space by reusing
374 memory from the receive buffer. The caller provides a
375 mavlink_message_t which is the size of a full mavlink message. This
376 is usually the receive buffer for the channel, and allows a reply to an
377 incoming message with minimum stack space usage.
378 */
379static 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, uint8_t id, int16_t temperature)
380{
381#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
382 char *buf = (char *)msgbuf;
383 _mav_put_uint64_t(buf, 0, time_usec);
384 _mav_put_int16_t(buf, 8, xacc);
385 _mav_put_int16_t(buf, 10, yacc);
386 _mav_put_int16_t(buf, 12, zacc);
387 _mav_put_int16_t(buf, 14, xgyro);
388 _mav_put_int16_t(buf, 16, ygyro);
389 _mav_put_int16_t(buf, 18, zgyro);
390 _mav_put_int16_t(buf, 20, xmag);
391 _mav_put_int16_t(buf, 22, ymag);
392 _mav_put_int16_t(buf, 24, zmag);
393 _mav_put_uint8_t(buf, 26, id);
394 _mav_put_int16_t(buf, 27, temperature);
395
396 _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);
397#else
398 mavlink_raw_imu_t *packet = (mavlink_raw_imu_t *)msgbuf;
399 packet->time_usec = time_usec;
400 packet->xacc = xacc;
401 packet->yacc = yacc;
402 packet->zacc = zacc;
403 packet->xgyro = xgyro;
404 packet->ygyro = ygyro;
405 packet->zgyro = zgyro;
406 packet->xmag = xmag;
407 packet->ymag = ymag;
408 packet->zmag = zmag;
409 packet->id = id;
410 packet->temperature = temperature;
411
412 _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);
413#endif
414}
415#endif
416
417#endif
418
419// MESSAGE RAW_IMU UNPACKING
420
421
422/**
423 * @brief Get field time_usec from raw_imu message
424 *
425 * @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.
426 */
427static inline uint64_t mavlink_msg_raw_imu_get_time_usec(const mavlink_message_t* msg)
428{
429 return _MAV_RETURN_uint64_t(msg, 0);
430}
431
432/**
433 * @brief Get field xacc from raw_imu message
434 *
435 * @return X acceleration (raw)
436 */
437static inline int16_t mavlink_msg_raw_imu_get_xacc(const mavlink_message_t* msg)
438{
439 return _MAV_RETURN_int16_t(msg, 8);
440}
441
442/**
443 * @brief Get field yacc from raw_imu message
444 *
445 * @return Y acceleration (raw)
446 */
447static inline int16_t mavlink_msg_raw_imu_get_yacc(const mavlink_message_t* msg)
448{
449 return _MAV_RETURN_int16_t(msg, 10);
450}
451
452/**
453 * @brief Get field zacc from raw_imu message
454 *
455 * @return Z acceleration (raw)
456 */
457static inline int16_t mavlink_msg_raw_imu_get_zacc(const mavlink_message_t* msg)
458{
459 return _MAV_RETURN_int16_t(msg, 12);
460}
461
462/**
463 * @brief Get field xgyro from raw_imu message
464 *
465 * @return Angular speed around X axis (raw)
466 */
467static inline int16_t mavlink_msg_raw_imu_get_xgyro(const mavlink_message_t* msg)
468{
469 return _MAV_RETURN_int16_t(msg, 14);
470}
471
472/**
473 * @brief Get field ygyro from raw_imu message
474 *
475 * @return Angular speed around Y axis (raw)
476 */
477static inline int16_t mavlink_msg_raw_imu_get_ygyro(const mavlink_message_t* msg)
478{
479 return _MAV_RETURN_int16_t(msg, 16);
480}
481
482/**
483 * @brief Get field zgyro from raw_imu message
484 *
485 * @return Angular speed around Z axis (raw)
486 */
487static inline int16_t mavlink_msg_raw_imu_get_zgyro(const mavlink_message_t* msg)
488{
489 return _MAV_RETURN_int16_t(msg, 18);
490}
491
492/**
493 * @brief Get field xmag from raw_imu message
494 *
495 * @return X Magnetic field (raw)
496 */
497static inline int16_t mavlink_msg_raw_imu_get_xmag(const mavlink_message_t* msg)
498{
499 return _MAV_RETURN_int16_t(msg, 20);
500}
501
502/**
503 * @brief Get field ymag from raw_imu message
504 *
505 * @return Y Magnetic field (raw)
506 */
507static inline int16_t mavlink_msg_raw_imu_get_ymag(const mavlink_message_t* msg)
508{
509 return _MAV_RETURN_int16_t(msg, 22);
510}
511
512/**
513 * @brief Get field zmag from raw_imu message
514 *
515 * @return Z Magnetic field (raw)
516 */
517static inline int16_t mavlink_msg_raw_imu_get_zmag(const mavlink_message_t* msg)
518{
519 return _MAV_RETURN_int16_t(msg, 24);
520}
521
522/**
523 * @brief Get field id from raw_imu message
524 *
525 * @return Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
526 */
527static inline uint8_t mavlink_msg_raw_imu_get_id(const mavlink_message_t* msg)
528{
529 return _MAV_RETURN_uint8_t(msg, 26);
530}
531
532/**
533 * @brief Get field temperature from raw_imu message
534 *
535 * @return [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
536 */
537static inline int16_t mavlink_msg_raw_imu_get_temperature(const mavlink_message_t* msg)
538{
539 return _MAV_RETURN_int16_t(msg, 27);
540}
541
542/**
543 * @brief Decode a raw_imu message into a struct
544 *
545 * @param msg The message to decode
546 * @param raw_imu C-struct to decode the message contents into
547 */
548static inline void mavlink_msg_raw_imu_decode(const mavlink_message_t* msg, mavlink_raw_imu_t* raw_imu)
549{
550#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
551 raw_imu->time_usec = mavlink_msg_raw_imu_get_time_usec(msg);
552 raw_imu->xacc = mavlink_msg_raw_imu_get_xacc(msg);
553 raw_imu->yacc = mavlink_msg_raw_imu_get_yacc(msg);
554 raw_imu->zacc = mavlink_msg_raw_imu_get_zacc(msg);
555 raw_imu->xgyro = mavlink_msg_raw_imu_get_xgyro(msg);
556 raw_imu->ygyro = mavlink_msg_raw_imu_get_ygyro(msg);
557 raw_imu->zgyro = mavlink_msg_raw_imu_get_zgyro(msg);
558 raw_imu->xmag = mavlink_msg_raw_imu_get_xmag(msg);
559 raw_imu->ymag = mavlink_msg_raw_imu_get_ymag(msg);
560 raw_imu->zmag = mavlink_msg_raw_imu_get_zmag(msg);
561 raw_imu->id = mavlink_msg_raw_imu_get_id(msg);
562 raw_imu->temperature = mavlink_msg_raw_imu_get_temperature(msg);
563#else
564 uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_IMU_LEN? msg->len : MAVLINK_MSG_ID_RAW_IMU_LEN;
565 memset(raw_imu, 0, MAVLINK_MSG_ID_RAW_IMU_LEN);
566 memcpy(raw_imu, _MAV_PAYLOAD(msg), len);
567#endif
568}