Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_attitude_quaternion.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE ATTITUDE_QUATERNION PACKING
3
4#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION 31
5
6
8 uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
9 float q1; /*< Quaternion component 1, w (1 in null-rotation)*/
10 float q2; /*< Quaternion component 2, x (0 in null-rotation)*/
11 float q3; /*< Quaternion component 3, y (0 in null-rotation)*/
12 float q4; /*< Quaternion component 4, z (0 in null-rotation)*/
13 float rollspeed; /*< [rad/s] Roll angular speed*/
14 float pitchspeed; /*< [rad/s] Pitch angular speed*/
15 float yawspeed; /*< [rad/s] Yaw angular speed*/
16 float repr_offset_q[4]; /*< Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.*/
17} mavlink_attitude_quaternion_t;
18
19#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN 48
20#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN 32
21#define MAVLINK_MSG_ID_31_LEN 48
22#define MAVLINK_MSG_ID_31_MIN_LEN 32
23
24#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC 246
25#define MAVLINK_MSG_ID_31_CRC 246
26
27#define MAVLINK_MSG_ATTITUDE_QUATERNION_FIELD_REPR_OFFSET_Q_LEN 4
28
29#if MAVLINK_COMMAND_24BIT
30#define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION {
31 31,
32 "ATTITUDE_QUATERNION",
33 9,
34 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) },
35 { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) },
36 { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) },
37 { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) },
38 { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) },
39 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) },
40 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) },
41 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) },
42 { "repr_offset_q", NULL, MAVLINK_TYPE_FLOAT, 4, 32, offsetof(mavlink_attitude_quaternion_t, repr_offset_q) },
43 } \
44}
45#else
46#define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION {
47 "ATTITUDE_QUATERNION",
48 9,
49 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) },
50 { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) },
51 { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) },
52 { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) },
53 { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) },
54 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) },
55 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) },
56 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) },
57 { "repr_offset_q", NULL, MAVLINK_TYPE_FLOAT, 4, 32, offsetof(mavlink_attitude_quaternion_t, repr_offset_q) },
58 } \
59}
60#endif
61
62/**
63 * @brief Pack a attitude_quaternion message
64 * @param system_id ID of this system
65 * @param component_id ID of this component (e.g. 200 for IMU)
66 * @param msg The MAVLink message to compress the data into
67 *
68 * @param time_boot_ms [ms] Timestamp (time since system boot).
69 * @param q1 Quaternion component 1, w (1 in null-rotation)
70 * @param q2 Quaternion component 2, x (0 in null-rotation)
71 * @param q3 Quaternion component 3, y (0 in null-rotation)
72 * @param q4 Quaternion component 4, z (0 in null-rotation)
73 * @param rollspeed [rad/s] Roll angular speed
74 * @param pitchspeed [rad/s] Pitch angular speed
75 * @param yawspeed [rad/s] Yaw angular speed
76 * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
77 * @return length of the message in bytes (excluding serial stream start sign)
78 */
79static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
80 uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q)
81{
82#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
84 _mav_put_uint32_t(buf, 0, time_boot_ms);
85 _mav_put_float(buf, 4, q1);
86 _mav_put_float(buf, 8, q2);
87 _mav_put_float(buf, 12, q3);
88 _mav_put_float(buf, 16, q4);
89 _mav_put_float(buf, 20, rollspeed);
90 _mav_put_float(buf, 24, pitchspeed);
91 _mav_put_float(buf, 28, yawspeed);
92 _mav_put_float_array(buf, 32, repr_offset_q, 4);
93 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
94#else
95 mavlink_attitude_quaternion_t packet;
96 packet.time_boot_ms = time_boot_ms;
97 packet.q1 = q1;
98 packet.q2 = q2;
99 packet.q3 = q3;
100 packet.q4 = q4;
101 packet.rollspeed = rollspeed;
102 packet.pitchspeed = pitchspeed;
103 packet.yawspeed = yawspeed;
104 mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
105 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
106#endif
107
110}
111
112/**
113 * @brief Pack a attitude_quaternion message
114 * @param system_id ID of this system
115 * @param component_id ID of this component (e.g. 200 for IMU)
116 * @param status MAVLink status structure
117 * @param msg The MAVLink message to compress the data into
118 *
119 * @param time_boot_ms [ms] Timestamp (time since system boot).
120 * @param q1 Quaternion component 1, w (1 in null-rotation)
121 * @param q2 Quaternion component 2, x (0 in null-rotation)
122 * @param q3 Quaternion component 3, y (0 in null-rotation)
123 * @param q4 Quaternion component 4, z (0 in null-rotation)
124 * @param rollspeed [rad/s] Roll angular speed
125 * @param pitchspeed [rad/s] Pitch angular speed
126 * @param yawspeed [rad/s] Yaw angular speed
127 * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
128 * @return length of the message in bytes (excluding serial stream start sign)
129 */
130static inline uint16_t mavlink_msg_attitude_quaternion_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
131 uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q)
132{
133#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
135 _mav_put_uint32_t(buf, 0, time_boot_ms);
136 _mav_put_float(buf, 4, q1);
137 _mav_put_float(buf, 8, q2);
138 _mav_put_float(buf, 12, q3);
139 _mav_put_float(buf, 16, q4);
140 _mav_put_float(buf, 20, rollspeed);
141 _mav_put_float(buf, 24, pitchspeed);
142 _mav_put_float(buf, 28, yawspeed);
143 _mav_put_float_array(buf, 32, repr_offset_q, 4);
144 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
145#else
146 mavlink_attitude_quaternion_t packet;
147 packet.time_boot_ms = time_boot_ms;
148 packet.q1 = q1;
149 packet.q2 = q2;
150 packet.q3 = q3;
151 packet.q4 = q4;
152 packet.rollspeed = rollspeed;
153 packet.pitchspeed = pitchspeed;
154 packet.yawspeed = yawspeed;
155 mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
156 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
157#endif
158
160#if MAVLINK_CRC_EXTRA
161 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
162#else
163 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
164#endif
165}
166
167/**
168 * @brief Pack a attitude_quaternion message on a channel
169 * @param system_id ID of this system
170 * @param component_id ID of this component (e.g. 200 for IMU)
171 * @param chan The MAVLink channel this message will be sent over
172 * @param msg The MAVLink message to compress the data into
173 * @param time_boot_ms [ms] Timestamp (time since system boot).
174 * @param q1 Quaternion component 1, w (1 in null-rotation)
175 * @param q2 Quaternion component 2, x (0 in null-rotation)
176 * @param q3 Quaternion component 3, y (0 in null-rotation)
177 * @param q4 Quaternion component 4, z (0 in null-rotation)
178 * @param rollspeed [rad/s] Roll angular speed
179 * @param pitchspeed [rad/s] Pitch angular speed
180 * @param yawspeed [rad/s] Yaw angular speed
181 * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
182 * @return length of the message in bytes (excluding serial stream start sign)
183 */
184static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
185 mavlink_message_t* msg,
186 uint32_t time_boot_ms,float q1,float q2,float q3,float q4,float rollspeed,float pitchspeed,float yawspeed,const float *repr_offset_q)
187{
188#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
190 _mav_put_uint32_t(buf, 0, time_boot_ms);
191 _mav_put_float(buf, 4, q1);
192 _mav_put_float(buf, 8, q2);
193 _mav_put_float(buf, 12, q3);
194 _mav_put_float(buf, 16, q4);
195 _mav_put_float(buf, 20, rollspeed);
196 _mav_put_float(buf, 24, pitchspeed);
197 _mav_put_float(buf, 28, yawspeed);
198 _mav_put_float_array(buf, 32, repr_offset_q, 4);
199 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
200#else
201 mavlink_attitude_quaternion_t packet;
202 packet.time_boot_ms = time_boot_ms;
203 packet.q1 = q1;
204 packet.q2 = q2;
205 packet.q3 = q3;
206 packet.q4 = q4;
207 packet.rollspeed = rollspeed;
208 packet.pitchspeed = pitchspeed;
209 packet.yawspeed = yawspeed;
210 mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
211 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
212#endif
213
215 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
216}
217
218/**
219 * @brief Encode a attitude_quaternion struct
220 *
221 * @param system_id ID of this system
222 * @param component_id ID of this component (e.g. 200 for IMU)
223 * @param msg The MAVLink message to compress the data into
224 * @param attitude_quaternion C-struct to read the message contents from
225 */
226static 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)
227{
228 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, attitude_quaternion->repr_offset_q);
229}
230
231/**
232 * @brief Encode a attitude_quaternion struct on a channel
233 *
234 * @param system_id ID of this system
235 * @param component_id ID of this component (e.g. 200 for IMU)
236 * @param chan The MAVLink channel this message will be sent over
237 * @param msg The MAVLink message to compress the data into
238 * @param attitude_quaternion C-struct to read the message contents from
239 */
240static 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)
241{
242 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, attitude_quaternion->repr_offset_q);
243}
244
245/**
246 * @brief Encode a attitude_quaternion struct with provided status structure
247 *
248 * @param system_id ID of this system
249 * @param component_id ID of this component (e.g. 200 for IMU)
250 * @param status MAVLink status structure
251 * @param msg The MAVLink message to compress the data into
252 * @param attitude_quaternion C-struct to read the message contents from
253 */
254static inline uint16_t mavlink_msg_attitude_quaternion_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion)
255{
256 return mavlink_msg_attitude_quaternion_pack_status(system_id, component_id, _status, 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, attitude_quaternion->repr_offset_q);
257}
258
259/**
260 * @brief Send a attitude_quaternion message
261 * @param chan MAVLink channel to send the message
262 *
263 * @param time_boot_ms [ms] Timestamp (time since system boot).
264 * @param q1 Quaternion component 1, w (1 in null-rotation)
265 * @param q2 Quaternion component 2, x (0 in null-rotation)
266 * @param q3 Quaternion component 3, y (0 in null-rotation)
267 * @param q4 Quaternion component 4, z (0 in null-rotation)
268 * @param rollspeed [rad/s] Roll angular speed
269 * @param pitchspeed [rad/s] Pitch angular speed
270 * @param yawspeed [rad/s] Yaw angular speed
271 * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
272 */
273#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
274
275static 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, const float *repr_offset_q)
276{
277#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
278 char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
279 _mav_put_uint32_t(buf, 0, time_boot_ms);
280 _mav_put_float(buf, 4, q1);
281 _mav_put_float(buf, 8, q2);
282 _mav_put_float(buf, 12, q3);
283 _mav_put_float(buf, 16, q4);
284 _mav_put_float(buf, 20, rollspeed);
285 _mav_put_float(buf, 24, pitchspeed);
286 _mav_put_float(buf, 28, yawspeed);
287 _mav_put_float_array(buf, 32, repr_offset_q, 4);
288 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
289#else
290 mavlink_attitude_quaternion_t packet;
291 packet.time_boot_ms = time_boot_ms;
292 packet.q1 = q1;
293 packet.q2 = q2;
294 packet.q3 = q3;
295 packet.q4 = q4;
296 packet.rollspeed = rollspeed;
297 packet.pitchspeed = pitchspeed;
298 packet.yawspeed = yawspeed;
299 mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
300 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)&packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
301#endif
302}
303
304/**
305 * @brief Send a attitude_quaternion message
306 * @param chan MAVLink channel to send the message
307 * @param struct The MAVLink struct to serialize
308 */
309static inline void mavlink_msg_attitude_quaternion_send_struct(mavlink_channel_t chan, const mavlink_attitude_quaternion_t* attitude_quaternion)
310{
311#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
312 mavlink_msg_attitude_quaternion_send(chan, 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, attitude_quaternion->repr_offset_q);
313#else
314 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)attitude_quaternion, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
315#endif
316}
317
318#if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
319/*
320 This variant of _send() can be used to save stack space by reusing
321 memory from the receive buffer. The caller provides a
322 mavlink_message_t which is the size of a full mavlink message. This
323 is usually the receive buffer for the channel, and allows a reply to an
324 incoming message with minimum stack space usage.
325 */
326static 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, const float *repr_offset_q)
327{
328#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
329 char *buf = (char *)msgbuf;
330 _mav_put_uint32_t(buf, 0, time_boot_ms);
331 _mav_put_float(buf, 4, q1);
332 _mav_put_float(buf, 8, q2);
333 _mav_put_float(buf, 12, q3);
334 _mav_put_float(buf, 16, q4);
335 _mav_put_float(buf, 20, rollspeed);
336 _mav_put_float(buf, 24, pitchspeed);
337 _mav_put_float(buf, 28, yawspeed);
338 _mav_put_float_array(buf, 32, repr_offset_q, 4);
339 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
340#else
341 mavlink_attitude_quaternion_t *packet = (mavlink_attitude_quaternion_t *)msgbuf;
342 packet->time_boot_ms = time_boot_ms;
343 packet->q1 = q1;
344 packet->q2 = q2;
345 packet->q3 = q3;
346 packet->q4 = q4;
347 packet->rollspeed = rollspeed;
348 packet->pitchspeed = pitchspeed;
349 packet->yawspeed = yawspeed;
350 mav_array_memcpy(packet->repr_offset_q, repr_offset_q, sizeof(float)*4);
351 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
352#endif
353}
354#endif
355
356#endif
357
358// MESSAGE ATTITUDE_QUATERNION UNPACKING
359
360
361/**
362 * @brief Get field time_boot_ms from attitude_quaternion message
363 *
364 * @return [ms] Timestamp (time since system boot).
365 */
366static inline uint32_t mavlink_msg_attitude_quaternion_get_time_boot_ms(const mavlink_message_t* msg)
367{
368 return _MAV_RETURN_uint32_t(msg, 0);
369}
370
371/**
372 * @brief Get field q1 from attitude_quaternion message
373 *
374 * @return Quaternion component 1, w (1 in null-rotation)
375 */
376static inline float mavlink_msg_attitude_quaternion_get_q1(const mavlink_message_t* msg)
377{
378 return _MAV_RETURN_float(msg, 4);
379}
380
381/**
382 * @brief Get field q2 from attitude_quaternion message
383 *
384 * @return Quaternion component 2, x (0 in null-rotation)
385 */
386static inline float mavlink_msg_attitude_quaternion_get_q2(const mavlink_message_t* msg)
387{
388 return _MAV_RETURN_float(msg, 8);
389}
390
391/**
392 * @brief Get field q3 from attitude_quaternion message
393 *
394 * @return Quaternion component 3, y (0 in null-rotation)
395 */
396static inline float mavlink_msg_attitude_quaternion_get_q3(const mavlink_message_t* msg)
397{
398 return _MAV_RETURN_float(msg, 12);
399}
400
401/**
402 * @brief Get field q4 from attitude_quaternion message
403 *
404 * @return Quaternion component 4, z (0 in null-rotation)
405 */
406static inline float mavlink_msg_attitude_quaternion_get_q4(const mavlink_message_t* msg)
407{
408 return _MAV_RETURN_float(msg, 16);
409}
410
411/**
412 * @brief Get field rollspeed from attitude_quaternion message
413 *
414 * @return [rad/s] Roll angular speed
415 */
416static inline float mavlink_msg_attitude_quaternion_get_rollspeed(const mavlink_message_t* msg)
417{
418 return _MAV_RETURN_float(msg, 20);
419}
420
421/**
422 * @brief Get field pitchspeed from attitude_quaternion message
423 *
424 * @return [rad/s] Pitch angular speed
425 */
426static inline float mavlink_msg_attitude_quaternion_get_pitchspeed(const mavlink_message_t* msg)
427{
428 return _MAV_RETURN_float(msg, 24);
429}
430
431/**
432 * @brief Get field yawspeed from attitude_quaternion message
433 *
434 * @return [rad/s] Yaw angular speed
435 */
436static inline float mavlink_msg_attitude_quaternion_get_yawspeed(const mavlink_message_t* msg)
437{
438 return _MAV_RETURN_float(msg, 28);
439}
440
441/**
442 * @brief Get field repr_offset_q from attitude_quaternion message
443 *
444 * @return Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
445 */
446static inline uint16_t mavlink_msg_attitude_quaternion_get_repr_offset_q(const mavlink_message_t* msg, float *repr_offset_q)
447{
448 return _MAV_RETURN_float_array(msg, repr_offset_q, 4, 32);
449}
450
451/**
452 * @brief Decode a attitude_quaternion message into a struct
453 *
454 * @param msg The message to decode
455 * @param attitude_quaternion C-struct to decode the message contents into
456 */
457static inline void mavlink_msg_attitude_quaternion_decode(const mavlink_message_t* msg, mavlink_attitude_quaternion_t* attitude_quaternion)
458{
459#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
460 attitude_quaternion->time_boot_ms = mavlink_msg_attitude_quaternion_get_time_boot_ms(msg);
461 attitude_quaternion->q1 = mavlink_msg_attitude_quaternion_get_q1(msg);
462 attitude_quaternion->q2 = mavlink_msg_attitude_quaternion_get_q2(msg);
463 attitude_quaternion->q3 = mavlink_msg_attitude_quaternion_get_q3(msg);
464 attitude_quaternion->q4 = mavlink_msg_attitude_quaternion_get_q4(msg);
465 attitude_quaternion->rollspeed = mavlink_msg_attitude_quaternion_get_rollspeed(msg);
466 attitude_quaternion->pitchspeed = mavlink_msg_attitude_quaternion_get_pitchspeed(msg);
467 attitude_quaternion->yawspeed = mavlink_msg_attitude_quaternion_get_yawspeed(msg);
468 mavlink_msg_attitude_quaternion_get_repr_offset_q(msg, attitude_quaternion->repr_offset_q);
469#else
470 uint8_t len = msg->len < MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN? msg->len : MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN;
471 memset(attitude_quaternion, 0, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
472 memcpy(attitude_quaternion, _MAV_PAYLOAD(msg), len);
473#endif
474}