1 // MESSAGE ATTITUDE_QUATERNION PACKING
3 #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION 31
5 typedef struct __mavlink_attitude_quaternion_t
7 uint32_t time_boot_ms
; ///< Timestamp (milliseconds since system boot)
8 float q1
; ///< Quaternion component 1, w (1 in null-rotation)
9 float q2
; ///< Quaternion component 2, x (0 in null-rotation)
10 float q3
; ///< Quaternion component 3, y (0 in null-rotation)
11 float q4
; ///< Quaternion component 4, z (0 in null-rotation)
12 float rollspeed
; ///< Roll angular speed (rad/s)
13 float pitchspeed
; ///< Pitch angular speed (rad/s)
14 float yawspeed
; ///< Yaw angular speed (rad/s)
15 } mavlink_attitude_quaternion_t
;
17 #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN 32
18 #define MAVLINK_MSG_ID_31_LEN 32
20 #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC 246
21 #define MAVLINK_MSG_ID_31_CRC 246
25 #define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \
26 "ATTITUDE_QUATERNION", \
28 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \
29 { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \
30 { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \
31 { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \
32 { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \
33 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \
34 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \
35 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \
41 * @brief Pack a attitude_quaternion message
42 * @param system_id ID of this system
43 * @param component_id ID of this component (e.g. 200 for IMU)
44 * @param msg The MAVLink message to compress the data into
46 * @param time_boot_ms Timestamp (milliseconds since system boot)
47 * @param q1 Quaternion component 1, w (1 in null-rotation)
48 * @param q2 Quaternion component 2, x (0 in null-rotation)
49 * @param q3 Quaternion component 3, y (0 in null-rotation)
50 * @param q4 Quaternion component 4, z (0 in null-rotation)
51 * @param rollspeed Roll angular speed (rad/s)
52 * @param pitchspeed Pitch angular speed (rad/s)
53 * @param yawspeed Yaw angular speed (rad/s)
54 * @return length of the message in bytes (excluding serial stream start sign)
56 static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
57 uint32_t time_boot_ms
, float q1
, float q2
, float q3
, float q4
, float rollspeed
, float pitchspeed
, float yawspeed
)
59 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
60 char buf
[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
];
61 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
62 _mav_put_float(buf
, 4, q1
);
63 _mav_put_float(buf
, 8, q2
);
64 _mav_put_float(buf
, 12, q3
);
65 _mav_put_float(buf
, 16, q4
);
66 _mav_put_float(buf
, 20, rollspeed
);
67 _mav_put_float(buf
, 24, pitchspeed
);
68 _mav_put_float(buf
, 28, yawspeed
);
70 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
72 mavlink_attitude_quaternion_t packet
;
73 packet
.time_boot_ms
= time_boot_ms
;
78 packet
.rollspeed
= rollspeed
;
79 packet
.pitchspeed
= pitchspeed
;
80 packet
.yawspeed
= yawspeed
;
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
85 msg
->msgid
= MAVLINK_MSG_ID_ATTITUDE_QUATERNION
;
87 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
89 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
94 * @brief Pack a attitude_quaternion message on a channel
95 * @param system_id ID of this system
96 * @param component_id ID of this component (e.g. 200 for IMU)
97 * @param chan The MAVLink channel this message will be sent over
98 * @param msg The MAVLink message to compress the data into
99 * @param time_boot_ms Timestamp (milliseconds since system boot)
100 * @param q1 Quaternion component 1, w (1 in null-rotation)
101 * @param q2 Quaternion component 2, x (0 in null-rotation)
102 * @param q3 Quaternion component 3, y (0 in null-rotation)
103 * @param q4 Quaternion component 4, z (0 in null-rotation)
104 * @param rollspeed Roll angular speed (rad/s)
105 * @param pitchspeed Pitch angular speed (rad/s)
106 * @param yawspeed Yaw angular speed (rad/s)
107 * @return length of the message in bytes (excluding serial stream start sign)
109 static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
110 mavlink_message_t
* msg
,
111 uint32_t time_boot_ms
,float q1
,float q2
,float q3
,float q4
,float rollspeed
,float pitchspeed
,float yawspeed
)
113 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114 char buf
[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
];
115 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
116 _mav_put_float(buf
, 4, q1
);
117 _mav_put_float(buf
, 8, q2
);
118 _mav_put_float(buf
, 12, q3
);
119 _mav_put_float(buf
, 16, q4
);
120 _mav_put_float(buf
, 20, rollspeed
);
121 _mav_put_float(buf
, 24, pitchspeed
);
122 _mav_put_float(buf
, 28, yawspeed
);
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
126 mavlink_attitude_quaternion_t packet
;
127 packet
.time_boot_ms
= time_boot_ms
;
132 packet
.rollspeed
= rollspeed
;
133 packet
.pitchspeed
= pitchspeed
;
134 packet
.yawspeed
= yawspeed
;
136 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
139 msg
->msgid
= MAVLINK_MSG_ID_ATTITUDE_QUATERNION
;
140 #if MAVLINK_CRC_EXTRA
141 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
143 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
148 * @brief Encode a attitude_quaternion struct
150 * @param system_id ID of this system
151 * @param component_id ID of this component (e.g. 200 for IMU)
152 * @param msg The MAVLink message to compress the data into
153 * @param attitude_quaternion C-struct to read the message contents from
155 static inline uint16_t mavlink_msg_attitude_quaternion_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_attitude_quaternion_t
* attitude_quaternion
)
157 return mavlink_msg_attitude_quaternion_pack(system_id
, component_id
, msg
, attitude_quaternion
->time_boot_ms
, attitude_quaternion
->q1
, attitude_quaternion
->q2
, attitude_quaternion
->q3
, attitude_quaternion
->q4
, attitude_quaternion
->rollspeed
, attitude_quaternion
->pitchspeed
, attitude_quaternion
->yawspeed
);
161 * @brief Encode a attitude_quaternion struct on a channel
163 * @param system_id ID of this system
164 * @param component_id ID of this component (e.g. 200 for IMU)
165 * @param chan The MAVLink channel this message will be sent over
166 * @param msg The MAVLink message to compress the data into
167 * @param attitude_quaternion C-struct to read the message contents from
169 static inline uint16_t mavlink_msg_attitude_quaternion_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_attitude_quaternion_t
* attitude_quaternion
)
171 return mavlink_msg_attitude_quaternion_pack_chan(system_id
, component_id
, chan
, msg
, attitude_quaternion
->time_boot_ms
, attitude_quaternion
->q1
, attitude_quaternion
->q2
, attitude_quaternion
->q3
, attitude_quaternion
->q4
, attitude_quaternion
->rollspeed
, attitude_quaternion
->pitchspeed
, attitude_quaternion
->yawspeed
);
175 * @brief Send a attitude_quaternion message
176 * @param chan MAVLink channel to send the message
178 * @param time_boot_ms Timestamp (milliseconds since system boot)
179 * @param q1 Quaternion component 1, w (1 in null-rotation)
180 * @param q2 Quaternion component 2, x (0 in null-rotation)
181 * @param q3 Quaternion component 3, y (0 in null-rotation)
182 * @param q4 Quaternion component 4, z (0 in null-rotation)
183 * @param rollspeed Roll angular speed (rad/s)
184 * @param pitchspeed Pitch angular speed (rad/s)
185 * @param yawspeed Yaw angular speed (rad/s)
187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189 static inline void mavlink_msg_attitude_quaternion_send(mavlink_channel_t chan
, uint32_t time_boot_ms
, float q1
, float q2
, float q3
, float q4
, float rollspeed
, float pitchspeed
, float yawspeed
)
191 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
192 char buf
[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
];
193 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
194 _mav_put_float(buf
, 4, q1
);
195 _mav_put_float(buf
, 8, q2
);
196 _mav_put_float(buf
, 12, q3
);
197 _mav_put_float(buf
, 16, q4
);
198 _mav_put_float(buf
, 20, rollspeed
);
199 _mav_put_float(buf
, 24, pitchspeed
);
200 _mav_put_float(buf
, 28, yawspeed
);
202 #if MAVLINK_CRC_EXTRA
203 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
205 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
208 mavlink_attitude_quaternion_t packet
;
209 packet
.time_boot_ms
= time_boot_ms
;
214 packet
.rollspeed
= rollspeed
;
215 packet
.pitchspeed
= pitchspeed
;
216 packet
.yawspeed
= yawspeed
;
218 #if MAVLINK_CRC_EXTRA
219 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, (const char *)&packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
221 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, (const char *)&packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
226 #if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
228 This varient of _send() can be used to save stack space by re-using
229 memory from the receive buffer. The caller provides a
230 mavlink_message_t which is the size of a full mavlink message. This
231 is usually the receive buffer for the channel, and allows a reply to an
232 incoming message with minimum stack space usage.
234 static inline void mavlink_msg_attitude_quaternion_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint32_t time_boot_ms
, float q1
, float q2
, float q3
, float q4
, float rollspeed
, float pitchspeed
, float yawspeed
)
236 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 char *buf
= (char *)msgbuf
;
238 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
239 _mav_put_float(buf
, 4, q1
);
240 _mav_put_float(buf
, 8, q2
);
241 _mav_put_float(buf
, 12, q3
);
242 _mav_put_float(buf
, 16, q4
);
243 _mav_put_float(buf
, 20, rollspeed
);
244 _mav_put_float(buf
, 24, pitchspeed
);
245 _mav_put_float(buf
, 28, yawspeed
);
247 #if MAVLINK_CRC_EXTRA
248 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
250 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, buf
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
253 mavlink_attitude_quaternion_t
*packet
= (mavlink_attitude_quaternion_t
*)msgbuf
;
254 packet
->time_boot_ms
= time_boot_ms
;
259 packet
->rollspeed
= rollspeed
;
260 packet
->pitchspeed
= pitchspeed
;
261 packet
->yawspeed
= yawspeed
;
263 #if MAVLINK_CRC_EXTRA
264 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, (const char *)packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC
);
266 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION
, (const char *)packet
, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);
274 // MESSAGE ATTITUDE_QUATERNION UNPACKING
278 * @brief Get field time_boot_ms from attitude_quaternion message
280 * @return Timestamp (milliseconds since system boot)
282 static inline uint32_t mavlink_msg_attitude_quaternion_get_time_boot_ms(const mavlink_message_t
* msg
)
284 return _MAV_RETURN_uint32_t(msg
, 0);
288 * @brief Get field q1 from attitude_quaternion message
290 * @return Quaternion component 1, w (1 in null-rotation)
292 static inline float mavlink_msg_attitude_quaternion_get_q1(const mavlink_message_t
* msg
)
294 return _MAV_RETURN_float(msg
, 4);
298 * @brief Get field q2 from attitude_quaternion message
300 * @return Quaternion component 2, x (0 in null-rotation)
302 static inline float mavlink_msg_attitude_quaternion_get_q2(const mavlink_message_t
* msg
)
304 return _MAV_RETURN_float(msg
, 8);
308 * @brief Get field q3 from attitude_quaternion message
310 * @return Quaternion component 3, y (0 in null-rotation)
312 static inline float mavlink_msg_attitude_quaternion_get_q3(const mavlink_message_t
* msg
)
314 return _MAV_RETURN_float(msg
, 12);
318 * @brief Get field q4 from attitude_quaternion message
320 * @return Quaternion component 4, z (0 in null-rotation)
322 static inline float mavlink_msg_attitude_quaternion_get_q4(const mavlink_message_t
* msg
)
324 return _MAV_RETURN_float(msg
, 16);
328 * @brief Get field rollspeed from attitude_quaternion message
330 * @return Roll angular speed (rad/s)
332 static inline float mavlink_msg_attitude_quaternion_get_rollspeed(const mavlink_message_t
* msg
)
334 return _MAV_RETURN_float(msg
, 20);
338 * @brief Get field pitchspeed from attitude_quaternion message
340 * @return Pitch angular speed (rad/s)
342 static inline float mavlink_msg_attitude_quaternion_get_pitchspeed(const mavlink_message_t
* msg
)
344 return _MAV_RETURN_float(msg
, 24);
348 * @brief Get field yawspeed from attitude_quaternion message
350 * @return Yaw angular speed (rad/s)
352 static inline float mavlink_msg_attitude_quaternion_get_yawspeed(const mavlink_message_t
* msg
)
354 return _MAV_RETURN_float(msg
, 28);
358 * @brief Decode a attitude_quaternion message into a struct
360 * @param msg The message to decode
361 * @param attitude_quaternion C-struct to decode the message contents into
363 static inline void mavlink_msg_attitude_quaternion_decode(const mavlink_message_t
* msg
, mavlink_attitude_quaternion_t
* attitude_quaternion
)
365 #if MAVLINK_NEED_BYTE_SWAP
366 attitude_quaternion
->time_boot_ms
= mavlink_msg_attitude_quaternion_get_time_boot_ms(msg
);
367 attitude_quaternion
->q1
= mavlink_msg_attitude_quaternion_get_q1(msg
);
368 attitude_quaternion
->q2
= mavlink_msg_attitude_quaternion_get_q2(msg
);
369 attitude_quaternion
->q3
= mavlink_msg_attitude_quaternion_get_q3(msg
);
370 attitude_quaternion
->q4
= mavlink_msg_attitude_quaternion_get_q4(msg
);
371 attitude_quaternion
->rollspeed
= mavlink_msg_attitude_quaternion_get_rollspeed(msg
);
372 attitude_quaternion
->pitchspeed
= mavlink_msg_attitude_quaternion_get_pitchspeed(msg
);
373 attitude_quaternion
->yawspeed
= mavlink_msg_attitude_quaternion_get_yawspeed(msg
);
375 memcpy(attitude_quaternion
, _MAV_PAYLOAD(msg
), MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN
);