before merging master
[inav.git] / lib / main / MAVLink / common / mavlink_msg_raw_imu.h
blobeeb4eacb2e36f36466e05f9f302289560a47f7b9
1 #pragma once
2 // MESSAGE RAW_IMU PACKING
4 #define MAVLINK_MSG_ID_RAW_IMU 27
6 MAVPACKED(
7 typedef 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;
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
27 #define MAVLINK_MSG_ID_RAW_IMU_CRC 144
28 #define MAVLINK_MSG_ID_27_CRC 144
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 } \
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 } \
69 #endif
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
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)
91 static 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)
94 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
95 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
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);
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;
125 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
126 #endif
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);
133 * @brief Pack a raw_imu message on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @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.
139 * @param xacc X acceleration (raw)
140 * @param yacc Y acceleration (raw)
141 * @param zacc Z acceleration (raw)
142 * @param xgyro Angular speed around X axis (raw)
143 * @param ygyro Angular speed around Y axis (raw)
144 * @param zgyro Angular speed around Z axis (raw)
145 * @param xmag X Magnetic field (raw)
146 * @param ymag Y Magnetic field (raw)
147 * @param zmag Z Magnetic field (raw)
148 * @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)
149 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
150 * @return length of the message in bytes (excluding serial stream start sign)
152 static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
153 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)
156 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
157 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
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);
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;
187 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_RAW_IMU_LEN);
188 #endif
190 msg->msgid = MAVLINK_MSG_ID_RAW_IMU;
191 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);
195 * @brief Encode a raw_imu struct
197 * @param system_id ID of this system
198 * @param component_id ID of this component (e.g. 200 for IMU)
199 * @param msg The MAVLink message to compress the data into
200 * @param raw_imu C-struct to read the message contents from
202 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)
204 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);
208 * @brief Encode a raw_imu struct on a channel
210 * @param system_id ID of this system
211 * @param component_id ID of this component (e.g. 200 for IMU)
212 * @param chan The MAVLink channel this message will be sent over
213 * @param msg The MAVLink message to compress the data into
214 * @param raw_imu C-struct to read the message contents from
216 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)
218 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);
222 * @brief Send a raw_imu message
223 * @param chan MAVLink channel to send the message
225 * @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.
226 * @param xacc X acceleration (raw)
227 * @param yacc Y acceleration (raw)
228 * @param zacc Z acceleration (raw)
229 * @param xgyro Angular speed around X axis (raw)
230 * @param ygyro Angular speed around Y axis (raw)
231 * @param zgyro Angular speed around Z axis (raw)
232 * @param xmag X Magnetic field (raw)
233 * @param ymag Y Magnetic field (raw)
234 * @param zmag Z Magnetic field (raw)
235 * @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)
236 * @param temperature [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
238 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
240 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, uint8_t id, int16_t temperature)
242 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
243 char buf[MAVLINK_MSG_ID_RAW_IMU_LEN];
244 _mav_put_uint64_t(buf, 0, time_usec);
245 _mav_put_int16_t(buf, 8, xacc);
246 _mav_put_int16_t(buf, 10, yacc);
247 _mav_put_int16_t(buf, 12, zacc);
248 _mav_put_int16_t(buf, 14, xgyro);
249 _mav_put_int16_t(buf, 16, ygyro);
250 _mav_put_int16_t(buf, 18, zgyro);
251 _mav_put_int16_t(buf, 20, xmag);
252 _mav_put_int16_t(buf, 22, ymag);
253 _mav_put_int16_t(buf, 24, zmag);
254 _mav_put_uint8_t(buf, 26, id);
255 _mav_put_int16_t(buf, 27, temperature);
257 _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);
258 #else
259 mavlink_raw_imu_t packet;
260 packet.time_usec = time_usec;
261 packet.xacc = xacc;
262 packet.yacc = yacc;
263 packet.zacc = zacc;
264 packet.xgyro = xgyro;
265 packet.ygyro = ygyro;
266 packet.zgyro = zgyro;
267 packet.xmag = xmag;
268 packet.ymag = ymag;
269 packet.zmag = zmag;
270 packet.id = id;
271 packet.temperature = temperature;
273 _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);
274 #endif
278 * @brief Send a raw_imu message
279 * @param chan MAVLink channel to send the message
280 * @param struct The MAVLink struct to serialize
282 static inline void mavlink_msg_raw_imu_send_struct(mavlink_channel_t chan, const mavlink_raw_imu_t* raw_imu)
284 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
285 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);
286 #else
287 _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);
288 #endif
291 #if MAVLINK_MSG_ID_RAW_IMU_LEN <= MAVLINK_MAX_PAYLOAD_LEN
293 This varient of _send() can be used to save stack space by re-using
294 memory from the receive buffer. The caller provides a
295 mavlink_message_t which is the size of a full mavlink message. This
296 is usually the receive buffer for the channel, and allows a reply to an
297 incoming message with minimum stack space usage.
299 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, uint8_t id, int16_t temperature)
301 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
302 char *buf = (char *)msgbuf;
303 _mav_put_uint64_t(buf, 0, time_usec);
304 _mav_put_int16_t(buf, 8, xacc);
305 _mav_put_int16_t(buf, 10, yacc);
306 _mav_put_int16_t(buf, 12, zacc);
307 _mav_put_int16_t(buf, 14, xgyro);
308 _mav_put_int16_t(buf, 16, ygyro);
309 _mav_put_int16_t(buf, 18, zgyro);
310 _mav_put_int16_t(buf, 20, xmag);
311 _mav_put_int16_t(buf, 22, ymag);
312 _mav_put_int16_t(buf, 24, zmag);
313 _mav_put_uint8_t(buf, 26, id);
314 _mav_put_int16_t(buf, 27, temperature);
316 _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);
317 #else
318 mavlink_raw_imu_t *packet = (mavlink_raw_imu_t *)msgbuf;
319 packet->time_usec = time_usec;
320 packet->xacc = xacc;
321 packet->yacc = yacc;
322 packet->zacc = zacc;
323 packet->xgyro = xgyro;
324 packet->ygyro = ygyro;
325 packet->zgyro = zgyro;
326 packet->xmag = xmag;
327 packet->ymag = ymag;
328 packet->zmag = zmag;
329 packet->id = id;
330 packet->temperature = temperature;
332 _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);
333 #endif
335 #endif
337 #endif
339 // MESSAGE RAW_IMU UNPACKING
343 * @brief Get field time_usec from raw_imu message
345 * @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.
347 static inline uint64_t mavlink_msg_raw_imu_get_time_usec(const mavlink_message_t* msg)
349 return _MAV_RETURN_uint64_t(msg, 0);
353 * @brief Get field xacc from raw_imu message
355 * @return X acceleration (raw)
357 static inline int16_t mavlink_msg_raw_imu_get_xacc(const mavlink_message_t* msg)
359 return _MAV_RETURN_int16_t(msg, 8);
363 * @brief Get field yacc from raw_imu message
365 * @return Y acceleration (raw)
367 static inline int16_t mavlink_msg_raw_imu_get_yacc(const mavlink_message_t* msg)
369 return _MAV_RETURN_int16_t(msg, 10);
373 * @brief Get field zacc from raw_imu message
375 * @return Z acceleration (raw)
377 static inline int16_t mavlink_msg_raw_imu_get_zacc(const mavlink_message_t* msg)
379 return _MAV_RETURN_int16_t(msg, 12);
383 * @brief Get field xgyro from raw_imu message
385 * @return Angular speed around X axis (raw)
387 static inline int16_t mavlink_msg_raw_imu_get_xgyro(const mavlink_message_t* msg)
389 return _MAV_RETURN_int16_t(msg, 14);
393 * @brief Get field ygyro from raw_imu message
395 * @return Angular speed around Y axis (raw)
397 static inline int16_t mavlink_msg_raw_imu_get_ygyro(const mavlink_message_t* msg)
399 return _MAV_RETURN_int16_t(msg, 16);
403 * @brief Get field zgyro from raw_imu message
405 * @return Angular speed around Z axis (raw)
407 static inline int16_t mavlink_msg_raw_imu_get_zgyro(const mavlink_message_t* msg)
409 return _MAV_RETURN_int16_t(msg, 18);
413 * @brief Get field xmag from raw_imu message
415 * @return X Magnetic field (raw)
417 static inline int16_t mavlink_msg_raw_imu_get_xmag(const mavlink_message_t* msg)
419 return _MAV_RETURN_int16_t(msg, 20);
423 * @brief Get field ymag from raw_imu message
425 * @return Y Magnetic field (raw)
427 static inline int16_t mavlink_msg_raw_imu_get_ymag(const mavlink_message_t* msg)
429 return _MAV_RETURN_int16_t(msg, 22);
433 * @brief Get field zmag from raw_imu message
435 * @return Z Magnetic field (raw)
437 static inline int16_t mavlink_msg_raw_imu_get_zmag(const mavlink_message_t* msg)
439 return _MAV_RETURN_int16_t(msg, 24);
443 * @brief Get field id from raw_imu message
445 * @return Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
447 static inline uint8_t mavlink_msg_raw_imu_get_id(const mavlink_message_t* msg)
449 return _MAV_RETURN_uint8_t(msg, 26);
453 * @brief Get field temperature from raw_imu message
455 * @return [cdegC] Temperature, 0: IMU does not provide temperature values. If the IMU is at 0C it must send 1 (0.01C).
457 static inline int16_t mavlink_msg_raw_imu_get_temperature(const mavlink_message_t* msg)
459 return _MAV_RETURN_int16_t(msg, 27);
463 * @brief Decode a raw_imu message into a struct
465 * @param msg The message to decode
466 * @param raw_imu C-struct to decode the message contents into
468 static inline void mavlink_msg_raw_imu_decode(const mavlink_message_t* msg, mavlink_raw_imu_t* raw_imu)
470 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
471 raw_imu->time_usec = mavlink_msg_raw_imu_get_time_usec(msg);
472 raw_imu->xacc = mavlink_msg_raw_imu_get_xacc(msg);
473 raw_imu->yacc = mavlink_msg_raw_imu_get_yacc(msg);
474 raw_imu->zacc = mavlink_msg_raw_imu_get_zacc(msg);
475 raw_imu->xgyro = mavlink_msg_raw_imu_get_xgyro(msg);
476 raw_imu->ygyro = mavlink_msg_raw_imu_get_ygyro(msg);
477 raw_imu->zgyro = mavlink_msg_raw_imu_get_zgyro(msg);
478 raw_imu->xmag = mavlink_msg_raw_imu_get_xmag(msg);
479 raw_imu->ymag = mavlink_msg_raw_imu_get_ymag(msg);
480 raw_imu->zmag = mavlink_msg_raw_imu_get_zmag(msg);
481 raw_imu->id = mavlink_msg_raw_imu_get_id(msg);
482 raw_imu->temperature = mavlink_msg_raw_imu_get_temperature(msg);
483 #else
484 uint8_t len = msg->len < MAVLINK_MSG_ID_RAW_IMU_LEN? msg->len : MAVLINK_MSG_ID_RAW_IMU_LEN;
485 memset(raw_imu, 0, MAVLINK_MSG_ID_RAW_IMU_LEN);
486 memcpy(raw_imu, _MAV_PAYLOAD(msg), len);
487 #endif