source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_attitude_quaternion.h @ 75

Last change on this file since 75 was 75, checked in by Thomas Fuhrmann, 5 years ago

Change the version of mavlink generated messages and rename it to include

File size: 16.3 KB
Line 
1// MESSAGE ATTITUDE_QUATERNION PACKING
2
3#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION 31
4
5typedef struct MAVLINK_PACKED __mavlink_attitude_quaternion_t
6{
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;
16
17#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN 32
18#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN 32
19#define MAVLINK_MSG_ID_31_LEN 32
20#define MAVLINK_MSG_ID_31_MIN_LEN 32
21
22#define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC 246
23#define MAVLINK_MSG_ID_31_CRC 246
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \
29        31, \
30        "ATTITUDE_QUATERNION", \
31        8, \
32        {  { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \
33         { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \
34         { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \
35         { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \
36         { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \
37         { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \
38         { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \
39         { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \
40         } \
41}
42#else
43#define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \
44        "ATTITUDE_QUATERNION", \
45        8, \
46        {  { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \
47         { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \
48         { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \
49         { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \
50         { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \
51         { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \
52         { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \
53         { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \
54         } \
55}
56#endif
57
58/**
59 * @brief Pack a attitude_quaternion message
60 * @param system_id ID of this system
61 * @param component_id ID of this component (e.g. 200 for IMU)
62 * @param msg The MAVLink message to compress the data into
63 *
64 * @param time_boot_ms Timestamp (milliseconds since system boot)
65 * @param q1 Quaternion component 1, w (1 in null-rotation)
66 * @param q2 Quaternion component 2, x (0 in null-rotation)
67 * @param q3 Quaternion component 3, y (0 in null-rotation)
68 * @param q4 Quaternion component 4, z (0 in null-rotation)
69 * @param rollspeed Roll angular speed (rad/s)
70 * @param pitchspeed Pitch angular speed (rad/s)
71 * @param yawspeed Yaw angular speed (rad/s)
72 * @return length of the message in bytes (excluding serial stream start sign)
73 */
74static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
75                                                       uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed)
76{
77#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
78        char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
79        _mav_put_uint32_t(buf, 0, time_boot_ms);
80        _mav_put_float(buf, 4, q1);
81        _mav_put_float(buf, 8, q2);
82        _mav_put_float(buf, 12, q3);
83        _mav_put_float(buf, 16, q4);
84        _mav_put_float(buf, 20, rollspeed);
85        _mav_put_float(buf, 24, pitchspeed);
86        _mav_put_float(buf, 28, yawspeed);
87
88        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
89#else
90        mavlink_attitude_quaternion_t packet;
91        packet.time_boot_ms = time_boot_ms;
92        packet.q1 = q1;
93        packet.q2 = q2;
94        packet.q3 = q3;
95        packet.q4 = q4;
96        packet.rollspeed = rollspeed;
97        packet.pitchspeed = pitchspeed;
98        packet.yawspeed = yawspeed;
99
100        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
101#endif
102
103        msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION;
104    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
105}
106
107/**
108 * @brief Pack a attitude_quaternion message on a channel
109 * @param system_id ID of this system
110 * @param component_id ID of this component (e.g. 200 for IMU)
111 * @param chan The MAVLink channel this message will be sent over
112 * @param msg The MAVLink message to compress the data into
113 * @param time_boot_ms Timestamp (milliseconds since system boot)
114 * @param q1 Quaternion component 1, w (1 in null-rotation)
115 * @param q2 Quaternion component 2, x (0 in null-rotation)
116 * @param q3 Quaternion component 3, y (0 in null-rotation)
117 * @param q4 Quaternion component 4, z (0 in null-rotation)
118 * @param rollspeed Roll angular speed (rad/s)
119 * @param pitchspeed Pitch angular speed (rad/s)
120 * @param yawspeed Yaw angular speed (rad/s)
121 * @return length of the message in bytes (excluding serial stream start sign)
122 */
123static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
124                                                           mavlink_message_t* msg,
125                                                           uint32_t time_boot_ms,float q1,float q2,float q3,float q4,float rollspeed,float pitchspeed,float yawspeed)
126{
127#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
128        char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
129        _mav_put_uint32_t(buf, 0, time_boot_ms);
130        _mav_put_float(buf, 4, q1);
131        _mav_put_float(buf, 8, q2);
132        _mav_put_float(buf, 12, q3);
133        _mav_put_float(buf, 16, q4);
134        _mav_put_float(buf, 20, rollspeed);
135        _mav_put_float(buf, 24, pitchspeed);
136        _mav_put_float(buf, 28, yawspeed);
137
138        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
139#else
140        mavlink_attitude_quaternion_t packet;
141        packet.time_boot_ms = time_boot_ms;
142        packet.q1 = q1;
143        packet.q2 = q2;
144        packet.q3 = q3;
145        packet.q4 = q4;
146        packet.rollspeed = rollspeed;
147        packet.pitchspeed = pitchspeed;
148        packet.yawspeed = yawspeed;
149
150        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
151#endif
152
153        msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION;
154    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);
155}
156
157/**
158 * @brief Encode a attitude_quaternion struct
159 *
160 * @param system_id ID of this system
161 * @param component_id ID of this component (e.g. 200 for IMU)
162 * @param msg The MAVLink message to compress the data into
163 * @param attitude_quaternion C-struct to read the message contents from
164 */
165static 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)
166{
167        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);
168}
169
170/**
171 * @brief Encode a attitude_quaternion struct on a channel
172 *
173 * @param system_id ID of this system
174 * @param component_id ID of this component (e.g. 200 for IMU)
175 * @param chan The MAVLink channel this message will be sent over
176 * @param msg The MAVLink message to compress the data into
177 * @param attitude_quaternion C-struct to read the message contents from
178 */
179static 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)
180{
181        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);
182}
183
184/**
185 * @brief Send a attitude_quaternion message
186 * @param chan MAVLink channel to send the message
187 *
188 * @param time_boot_ms Timestamp (milliseconds since system boot)
189 * @param q1 Quaternion component 1, w (1 in null-rotation)
190 * @param q2 Quaternion component 2, x (0 in null-rotation)
191 * @param q3 Quaternion component 3, y (0 in null-rotation)
192 * @param q4 Quaternion component 4, z (0 in null-rotation)
193 * @param rollspeed Roll angular speed (rad/s)
194 * @param pitchspeed Pitch angular speed (rad/s)
195 * @param yawspeed Yaw angular speed (rad/s)
196 */
197#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
198
199static 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)
200{
201#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
202        char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
203        _mav_put_uint32_t(buf, 0, time_boot_ms);
204        _mav_put_float(buf, 4, q1);
205        _mav_put_float(buf, 8, q2);
206        _mav_put_float(buf, 12, q3);
207        _mav_put_float(buf, 16, q4);
208        _mav_put_float(buf, 20, rollspeed);
209        _mav_put_float(buf, 24, pitchspeed);
210        _mav_put_float(buf, 28, yawspeed);
211
212    _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);
213#else
214        mavlink_attitude_quaternion_t packet;
215        packet.time_boot_ms = time_boot_ms;
216        packet.q1 = q1;
217        packet.q2 = q2;
218        packet.q3 = q3;
219        packet.q4 = q4;
220        packet.rollspeed = rollspeed;
221        packet.pitchspeed = pitchspeed;
222        packet.yawspeed = yawspeed;
223
224    _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);
225#endif
226}
227
228/**
229 * @brief Send a attitude_quaternion message
230 * @param chan MAVLink channel to send the message
231 * @param struct The MAVLink struct to serialize
232 */
233static inline void mavlink_msg_attitude_quaternion_send_struct(mavlink_channel_t chan, const mavlink_attitude_quaternion_t* attitude_quaternion)
234{
235#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
236    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);
237#else
238    _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);
239#endif
240}
241
242#if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
243/*
244  This varient of _send() can be used to save stack space by re-using
245  memory from the receive buffer.  The caller provides a
246  mavlink_message_t which is the size of a full mavlink message. This
247  is usually the receive buffer for the channel, and allows a reply to an
248  incoming message with minimum stack space usage.
249 */
250static 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)
251{
252#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
253        char *buf = (char *)msgbuf;
254        _mav_put_uint32_t(buf, 0, time_boot_ms);
255        _mav_put_float(buf, 4, q1);
256        _mav_put_float(buf, 8, q2);
257        _mav_put_float(buf, 12, q3);
258        _mav_put_float(buf, 16, q4);
259        _mav_put_float(buf, 20, rollspeed);
260        _mav_put_float(buf, 24, pitchspeed);
261        _mav_put_float(buf, 28, yawspeed);
262
263    _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);
264#else
265        mavlink_attitude_quaternion_t *packet = (mavlink_attitude_quaternion_t *)msgbuf;
266        packet->time_boot_ms = time_boot_ms;
267        packet->q1 = q1;
268        packet->q2 = q2;
269        packet->q3 = q3;
270        packet->q4 = q4;
271        packet->rollspeed = rollspeed;
272        packet->pitchspeed = pitchspeed;
273        packet->yawspeed = yawspeed;
274
275    _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);
276#endif
277}
278#endif
279
280#endif
281
282// MESSAGE ATTITUDE_QUATERNION UNPACKING
283
284
285/**
286 * @brief Get field time_boot_ms from attitude_quaternion message
287 *
288 * @return Timestamp (milliseconds since system boot)
289 */
290static inline uint32_t mavlink_msg_attitude_quaternion_get_time_boot_ms(const mavlink_message_t* msg)
291{
292        return _MAV_RETURN_uint32_t(msg,  0);
293}
294
295/**
296 * @brief Get field q1 from attitude_quaternion message
297 *
298 * @return Quaternion component 1, w (1 in null-rotation)
299 */
300static inline float mavlink_msg_attitude_quaternion_get_q1(const mavlink_message_t* msg)
301{
302        return _MAV_RETURN_float(msg,  4);
303}
304
305/**
306 * @brief Get field q2 from attitude_quaternion message
307 *
308 * @return Quaternion component 2, x (0 in null-rotation)
309 */
310static inline float mavlink_msg_attitude_quaternion_get_q2(const mavlink_message_t* msg)
311{
312        return _MAV_RETURN_float(msg,  8);
313}
314
315/**
316 * @brief Get field q3 from attitude_quaternion message
317 *
318 * @return Quaternion component 3, y (0 in null-rotation)
319 */
320static inline float mavlink_msg_attitude_quaternion_get_q3(const mavlink_message_t* msg)
321{
322        return _MAV_RETURN_float(msg,  12);
323}
324
325/**
326 * @brief Get field q4 from attitude_quaternion message
327 *
328 * @return Quaternion component 4, z (0 in null-rotation)
329 */
330static inline float mavlink_msg_attitude_quaternion_get_q4(const mavlink_message_t* msg)
331{
332        return _MAV_RETURN_float(msg,  16);
333}
334
335/**
336 * @brief Get field rollspeed from attitude_quaternion message
337 *
338 * @return Roll angular speed (rad/s)
339 */
340static inline float mavlink_msg_attitude_quaternion_get_rollspeed(const mavlink_message_t* msg)
341{
342        return _MAV_RETURN_float(msg,  20);
343}
344
345/**
346 * @brief Get field pitchspeed from attitude_quaternion message
347 *
348 * @return Pitch angular speed (rad/s)
349 */
350static inline float mavlink_msg_attitude_quaternion_get_pitchspeed(const mavlink_message_t* msg)
351{
352        return _MAV_RETURN_float(msg,  24);
353}
354
355/**
356 * @brief Get field yawspeed from attitude_quaternion message
357 *
358 * @return Yaw angular speed (rad/s)
359 */
360static inline float mavlink_msg_attitude_quaternion_get_yawspeed(const mavlink_message_t* msg)
361{
362        return _MAV_RETURN_float(msg,  28);
363}
364
365/**
366 * @brief Decode a attitude_quaternion message into a struct
367 *
368 * @param msg The message to decode
369 * @param attitude_quaternion C-struct to decode the message contents into
370 */
371static inline void mavlink_msg_attitude_quaternion_decode(const mavlink_message_t* msg, mavlink_attitude_quaternion_t* attitude_quaternion)
372{
373#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
374        attitude_quaternion->time_boot_ms = mavlink_msg_attitude_quaternion_get_time_boot_ms(msg);
375        attitude_quaternion->q1 = mavlink_msg_attitude_quaternion_get_q1(msg);
376        attitude_quaternion->q2 = mavlink_msg_attitude_quaternion_get_q2(msg);
377        attitude_quaternion->q3 = mavlink_msg_attitude_quaternion_get_q3(msg);
378        attitude_quaternion->q4 = mavlink_msg_attitude_quaternion_get_q4(msg);
379        attitude_quaternion->rollspeed = mavlink_msg_attitude_quaternion_get_rollspeed(msg);
380        attitude_quaternion->pitchspeed = mavlink_msg_attitude_quaternion_get_pitchspeed(msg);
381        attitude_quaternion->yawspeed = mavlink_msg_attitude_quaternion_get_yawspeed(msg);
382#else
383        uint8_t len = msg->len < MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN? msg->len : MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN;
384        memset(attitude_quaternion, 0, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
385        memcpy(attitude_quaternion, _MAV_PAYLOAD(msg), len);
386#endif
387}
Note: See TracBrowser for help on using the repository browser.