1 // MESSAGE SCALED_IMU2 PACKING
3 #define MAVLINK_MSG_ID_SCALED_IMU2 116
5 typedef struct __mavlink_scaled_imu2_t
7 uint32_t time_boot_ms
; ///< Timestamp (milliseconds since system boot)
8 int16_t xacc
; ///< X acceleration (mg)
9 int16_t yacc
; ///< Y acceleration (mg)
10 int16_t zacc
; ///< Z acceleration (mg)
11 int16_t xgyro
; ///< Angular speed around X axis (millirad /sec)
12 int16_t ygyro
; ///< Angular speed around Y axis (millirad /sec)
13 int16_t zgyro
; ///< Angular speed around Z axis (millirad /sec)
14 int16_t xmag
; ///< X Magnetic field (milli tesla)
15 int16_t ymag
; ///< Y Magnetic field (milli tesla)
16 int16_t zmag
; ///< Z Magnetic field (milli tesla)
17 } mavlink_scaled_imu2_t
;
19 #define MAVLINK_MSG_ID_SCALED_IMU2_LEN 22
20 #define MAVLINK_MSG_ID_116_LEN 22
22 #define MAVLINK_MSG_ID_SCALED_IMU2_CRC 76
23 #define MAVLINK_MSG_ID_116_CRC 76
27 #define MAVLINK_MESSAGE_INFO_SCALED_IMU2 { \
30 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_scaled_imu2_t, time_boot_ms) }, \
31 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_scaled_imu2_t, xacc) }, \
32 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_scaled_imu2_t, yacc) }, \
33 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_scaled_imu2_t, zacc) }, \
34 { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_scaled_imu2_t, xgyro) }, \
35 { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_scaled_imu2_t, ygyro) }, \
36 { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_scaled_imu2_t, zgyro) }, \
37 { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_scaled_imu2_t, xmag) }, \
38 { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_scaled_imu2_t, ymag) }, \
39 { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_scaled_imu2_t, zmag) }, \
45 * @brief Pack a scaled_imu2 message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
50 * @param time_boot_ms Timestamp (milliseconds since system boot)
51 * @param xacc X acceleration (mg)
52 * @param yacc Y acceleration (mg)
53 * @param zacc Z acceleration (mg)
54 * @param xgyro Angular speed around X axis (millirad /sec)
55 * @param ygyro Angular speed around Y axis (millirad /sec)
56 * @param zgyro Angular speed around Z axis (millirad /sec)
57 * @param xmag X Magnetic field (milli tesla)
58 * @param ymag Y Magnetic field (milli tesla)
59 * @param zmag Z Magnetic field (milli tesla)
60 * @return length of the message in bytes (excluding serial stream start sign)
62 static inline uint16_t mavlink_msg_scaled_imu2_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
63 uint32_t time_boot_ms
, 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
)
65 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf
[MAVLINK_MSG_ID_SCALED_IMU2_LEN
];
67 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
68 _mav_put_int16_t(buf
, 4, xacc
);
69 _mav_put_int16_t(buf
, 6, yacc
);
70 _mav_put_int16_t(buf
, 8, zacc
);
71 _mav_put_int16_t(buf
, 10, xgyro
);
72 _mav_put_int16_t(buf
, 12, ygyro
);
73 _mav_put_int16_t(buf
, 14, zgyro
);
74 _mav_put_int16_t(buf
, 16, xmag
);
75 _mav_put_int16_t(buf
, 18, ymag
);
76 _mav_put_int16_t(buf
, 20, zmag
);
78 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
80 mavlink_scaled_imu2_t packet
;
81 packet
.time_boot_ms
= time_boot_ms
;
92 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
95 msg
->msgid
= MAVLINK_MSG_ID_SCALED_IMU2
;
97 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
99 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
104 * @brief Pack a scaled_imu2 message on a channel
105 * @param system_id ID of this system
106 * @param component_id ID of this component (e.g. 200 for IMU)
107 * @param chan The MAVLink channel this message will be sent over
108 * @param msg The MAVLink message to compress the data into
109 * @param time_boot_ms Timestamp (milliseconds since system boot)
110 * @param xacc X acceleration (mg)
111 * @param yacc Y acceleration (mg)
112 * @param zacc Z acceleration (mg)
113 * @param xgyro Angular speed around X axis (millirad /sec)
114 * @param ygyro Angular speed around Y axis (millirad /sec)
115 * @param zgyro Angular speed around Z axis (millirad /sec)
116 * @param xmag X Magnetic field (milli tesla)
117 * @param ymag Y Magnetic field (milli tesla)
118 * @param zmag Z Magnetic field (milli tesla)
119 * @return length of the message in bytes (excluding serial stream start sign)
121 static inline uint16_t mavlink_msg_scaled_imu2_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
122 mavlink_message_t
* msg
,
123 uint32_t time_boot_ms
,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
)
125 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
126 char buf
[MAVLINK_MSG_ID_SCALED_IMU2_LEN
];
127 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
128 _mav_put_int16_t(buf
, 4, xacc
);
129 _mav_put_int16_t(buf
, 6, yacc
);
130 _mav_put_int16_t(buf
, 8, zacc
);
131 _mav_put_int16_t(buf
, 10, xgyro
);
132 _mav_put_int16_t(buf
, 12, ygyro
);
133 _mav_put_int16_t(buf
, 14, zgyro
);
134 _mav_put_int16_t(buf
, 16, xmag
);
135 _mav_put_int16_t(buf
, 18, ymag
);
136 _mav_put_int16_t(buf
, 20, zmag
);
138 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
140 mavlink_scaled_imu2_t packet
;
141 packet
.time_boot_ms
= time_boot_ms
;
145 packet
.xgyro
= xgyro
;
146 packet
.ygyro
= ygyro
;
147 packet
.zgyro
= zgyro
;
152 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
155 msg
->msgid
= MAVLINK_MSG_ID_SCALED_IMU2
;
156 #if MAVLINK_CRC_EXTRA
157 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
159 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
164 * @brief Encode a scaled_imu2 struct
166 * @param system_id ID of this system
167 * @param component_id ID of this component (e.g. 200 for IMU)
168 * @param msg The MAVLink message to compress the data into
169 * @param scaled_imu2 C-struct to read the message contents from
171 static inline uint16_t mavlink_msg_scaled_imu2_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_scaled_imu2_t
* scaled_imu2
)
173 return mavlink_msg_scaled_imu2_pack(system_id
, component_id
, msg
, scaled_imu2
->time_boot_ms
, scaled_imu2
->xacc
, scaled_imu2
->yacc
, scaled_imu2
->zacc
, scaled_imu2
->xgyro
, scaled_imu2
->ygyro
, scaled_imu2
->zgyro
, scaled_imu2
->xmag
, scaled_imu2
->ymag
, scaled_imu2
->zmag
);
177 * @brief Encode a scaled_imu2 struct on a channel
179 * @param system_id ID of this system
180 * @param component_id ID of this component (e.g. 200 for IMU)
181 * @param chan The MAVLink channel this message will be sent over
182 * @param msg The MAVLink message to compress the data into
183 * @param scaled_imu2 C-struct to read the message contents from
185 static inline uint16_t mavlink_msg_scaled_imu2_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_scaled_imu2_t
* scaled_imu2
)
187 return mavlink_msg_scaled_imu2_pack_chan(system_id
, component_id
, chan
, msg
, scaled_imu2
->time_boot_ms
, scaled_imu2
->xacc
, scaled_imu2
->yacc
, scaled_imu2
->zacc
, scaled_imu2
->xgyro
, scaled_imu2
->ygyro
, scaled_imu2
->zgyro
, scaled_imu2
->xmag
, scaled_imu2
->ymag
, scaled_imu2
->zmag
);
191 * @brief Send a scaled_imu2 message
192 * @param chan MAVLink channel to send the message
194 * @param time_boot_ms Timestamp (milliseconds since system boot)
195 * @param xacc X acceleration (mg)
196 * @param yacc Y acceleration (mg)
197 * @param zacc Z acceleration (mg)
198 * @param xgyro Angular speed around X axis (millirad /sec)
199 * @param ygyro Angular speed around Y axis (millirad /sec)
200 * @param zgyro Angular speed around Z axis (millirad /sec)
201 * @param xmag X Magnetic field (milli tesla)
202 * @param ymag Y Magnetic field (milli tesla)
203 * @param zmag Z Magnetic field (milli tesla)
205 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
207 static inline void mavlink_msg_scaled_imu2_send(mavlink_channel_t chan
, uint32_t time_boot_ms
, 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
)
209 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
210 char buf
[MAVLINK_MSG_ID_SCALED_IMU2_LEN
];
211 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
212 _mav_put_int16_t(buf
, 4, xacc
);
213 _mav_put_int16_t(buf
, 6, yacc
);
214 _mav_put_int16_t(buf
, 8, zacc
);
215 _mav_put_int16_t(buf
, 10, xgyro
);
216 _mav_put_int16_t(buf
, 12, ygyro
);
217 _mav_put_int16_t(buf
, 14, zgyro
);
218 _mav_put_int16_t(buf
, 16, xmag
);
219 _mav_put_int16_t(buf
, 18, ymag
);
220 _mav_put_int16_t(buf
, 20, zmag
);
222 #if MAVLINK_CRC_EXTRA
223 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
225 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
228 mavlink_scaled_imu2_t packet
;
229 packet
.time_boot_ms
= time_boot_ms
;
233 packet
.xgyro
= xgyro
;
234 packet
.ygyro
= ygyro
;
235 packet
.zgyro
= zgyro
;
240 #if MAVLINK_CRC_EXTRA
241 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, (const char *)&packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
243 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, (const char *)&packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
248 #if MAVLINK_MSG_ID_SCALED_IMU2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
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.
256 static inline void mavlink_msg_scaled_imu2_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint32_t time_boot_ms
, 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
)
258 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
259 char *buf
= (char *)msgbuf
;
260 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
261 _mav_put_int16_t(buf
, 4, xacc
);
262 _mav_put_int16_t(buf
, 6, yacc
);
263 _mav_put_int16_t(buf
, 8, zacc
);
264 _mav_put_int16_t(buf
, 10, xgyro
);
265 _mav_put_int16_t(buf
, 12, ygyro
);
266 _mav_put_int16_t(buf
, 14, zgyro
);
267 _mav_put_int16_t(buf
, 16, xmag
);
268 _mav_put_int16_t(buf
, 18, ymag
);
269 _mav_put_int16_t(buf
, 20, zmag
);
271 #if MAVLINK_CRC_EXTRA
272 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
274 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, buf
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
277 mavlink_scaled_imu2_t
*packet
= (mavlink_scaled_imu2_t
*)msgbuf
;
278 packet
->time_boot_ms
= time_boot_ms
;
282 packet
->xgyro
= xgyro
;
283 packet
->ygyro
= ygyro
;
284 packet
->zgyro
= zgyro
;
289 #if MAVLINK_CRC_EXTRA
290 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, (const char *)packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
, MAVLINK_MSG_ID_SCALED_IMU2_CRC
);
292 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SCALED_IMU2
, (const char *)packet
, MAVLINK_MSG_ID_SCALED_IMU2_LEN
);
300 // MESSAGE SCALED_IMU2 UNPACKING
304 * @brief Get field time_boot_ms from scaled_imu2 message
306 * @return Timestamp (milliseconds since system boot)
308 static inline uint32_t mavlink_msg_scaled_imu2_get_time_boot_ms(const mavlink_message_t
* msg
)
310 return _MAV_RETURN_uint32_t(msg
, 0);
314 * @brief Get field xacc from scaled_imu2 message
316 * @return X acceleration (mg)
318 static inline int16_t mavlink_msg_scaled_imu2_get_xacc(const mavlink_message_t
* msg
)
320 return _MAV_RETURN_int16_t(msg
, 4);
324 * @brief Get field yacc from scaled_imu2 message
326 * @return Y acceleration (mg)
328 static inline int16_t mavlink_msg_scaled_imu2_get_yacc(const mavlink_message_t
* msg
)
330 return _MAV_RETURN_int16_t(msg
, 6);
334 * @brief Get field zacc from scaled_imu2 message
336 * @return Z acceleration (mg)
338 static inline int16_t mavlink_msg_scaled_imu2_get_zacc(const mavlink_message_t
* msg
)
340 return _MAV_RETURN_int16_t(msg
, 8);
344 * @brief Get field xgyro from scaled_imu2 message
346 * @return Angular speed around X axis (millirad /sec)
348 static inline int16_t mavlink_msg_scaled_imu2_get_xgyro(const mavlink_message_t
* msg
)
350 return _MAV_RETURN_int16_t(msg
, 10);
354 * @brief Get field ygyro from scaled_imu2 message
356 * @return Angular speed around Y axis (millirad /sec)
358 static inline int16_t mavlink_msg_scaled_imu2_get_ygyro(const mavlink_message_t
* msg
)
360 return _MAV_RETURN_int16_t(msg
, 12);
364 * @brief Get field zgyro from scaled_imu2 message
366 * @return Angular speed around Z axis (millirad /sec)
368 static inline int16_t mavlink_msg_scaled_imu2_get_zgyro(const mavlink_message_t
* msg
)
370 return _MAV_RETURN_int16_t(msg
, 14);
374 * @brief Get field xmag from scaled_imu2 message
376 * @return X Magnetic field (milli tesla)
378 static inline int16_t mavlink_msg_scaled_imu2_get_xmag(const mavlink_message_t
* msg
)
380 return _MAV_RETURN_int16_t(msg
, 16);
384 * @brief Get field ymag from scaled_imu2 message
386 * @return Y Magnetic field (milli tesla)
388 static inline int16_t mavlink_msg_scaled_imu2_get_ymag(const mavlink_message_t
* msg
)
390 return _MAV_RETURN_int16_t(msg
, 18);
394 * @brief Get field zmag from scaled_imu2 message
396 * @return Z Magnetic field (milli tesla)
398 static inline int16_t mavlink_msg_scaled_imu2_get_zmag(const mavlink_message_t
* msg
)
400 return _MAV_RETURN_int16_t(msg
, 20);
404 * @brief Decode a scaled_imu2 message into a struct
406 * @param msg The message to decode
407 * @param scaled_imu2 C-struct to decode the message contents into
409 static inline void mavlink_msg_scaled_imu2_decode(const mavlink_message_t
* msg
, mavlink_scaled_imu2_t
* scaled_imu2
)
411 #if MAVLINK_NEED_BYTE_SWAP
412 scaled_imu2
->time_boot_ms
= mavlink_msg_scaled_imu2_get_time_boot_ms(msg
);
413 scaled_imu2
->xacc
= mavlink_msg_scaled_imu2_get_xacc(msg
);
414 scaled_imu2
->yacc
= mavlink_msg_scaled_imu2_get_yacc(msg
);
415 scaled_imu2
->zacc
= mavlink_msg_scaled_imu2_get_zacc(msg
);
416 scaled_imu2
->xgyro
= mavlink_msg_scaled_imu2_get_xgyro(msg
);
417 scaled_imu2
->ygyro
= mavlink_msg_scaled_imu2_get_ygyro(msg
);
418 scaled_imu2
->zgyro
= mavlink_msg_scaled_imu2_get_zgyro(msg
);
419 scaled_imu2
->xmag
= mavlink_msg_scaled_imu2_get_xmag(msg
);
420 scaled_imu2
->ymag
= mavlink_msg_scaled_imu2_get_ymag(msg
);
421 scaled_imu2
->zmag
= mavlink_msg_scaled_imu2_get_zmag(msg
);
423 memcpy(scaled_imu2
, _MAV_PAYLOAD(msg
), MAVLINK_MSG_ID_SCALED_IMU2_LEN
);