Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_att_pos_mocap.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE ATT_POS_MOCAP PACKING
3
4#define MAVLINK_MSG_ID_ATT_POS_MOCAP 138
5
6
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 float q[4]; /*< Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)*/
10 float x; /*< [m] X position (NED)*/
11 float y; /*< [m] Y position (NED)*/
12 float z; /*< [m] Z position (NED)*/
13 float covariance[21]; /*< Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.*/
14} mavlink_att_pos_mocap_t;
15
16#define MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN 120
17#define MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN 36
18#define MAVLINK_MSG_ID_138_LEN 120
19#define MAVLINK_MSG_ID_138_MIN_LEN 36
20
21#define MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC 109
22#define MAVLINK_MSG_ID_138_CRC 109
23
24#define MAVLINK_MSG_ATT_POS_MOCAP_FIELD_Q_LEN 4
25#define MAVLINK_MSG_ATT_POS_MOCAP_FIELD_COVARIANCE_LEN 21
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_ATT_POS_MOCAP {
29 138,
30 "ATT_POS_MOCAP",
31 6,
32 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_att_pos_mocap_t, time_usec) },
33 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 8, offsetof(mavlink_att_pos_mocap_t, q) },
34 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_att_pos_mocap_t, x) },
35 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_att_pos_mocap_t, y) },
36 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_att_pos_mocap_t, z) },
37 { "covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 36, offsetof(mavlink_att_pos_mocap_t, covariance) },
38 } \
39}
40#else
41#define MAVLINK_MESSAGE_INFO_ATT_POS_MOCAP {
42 "ATT_POS_MOCAP",
43 6,
44 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_att_pos_mocap_t, time_usec) },
45 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 8, offsetof(mavlink_att_pos_mocap_t, q) },
46 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_att_pos_mocap_t, x) },
47 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_att_pos_mocap_t, y) },
48 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_att_pos_mocap_t, z) },
49 { "covariance", NULL, MAVLINK_TYPE_FLOAT, 21, 36, offsetof(mavlink_att_pos_mocap_t, covariance) },
50 } \
51}
52#endif
53
54/**
55 * @brief Pack a att_pos_mocap message
56 * @param system_id ID of this system
57 * @param component_id ID of this component (e.g. 200 for IMU)
58 * @param msg The MAVLink message to compress the data into
59 *
60 * @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.
61 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
62 * @param x [m] X position (NED)
63 * @param y [m] Y position (NED)
64 * @param z [m] Z position (NED)
65 * @param covariance Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
66 * @return length of the message in bytes (excluding serial stream start sign)
67 */
68static inline uint16_t mavlink_msg_att_pos_mocap_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
69 uint64_t time_usec, const float *q, float x, float y, float z, const float *covariance)
70{
71#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
73 _mav_put_uint64_t(buf, 0, time_usec);
74 _mav_put_float(buf, 24, x);
75 _mav_put_float(buf, 28, y);
76 _mav_put_float(buf, 32, z);
77 _mav_put_float_array(buf, 8, q, 4);
78 _mav_put_float_array(buf, 36, covariance, 21);
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
80#else
81 mavlink_att_pos_mocap_t packet;
82 packet.time_usec = time_usec;
83 packet.x = x;
84 packet.y = y;
85 packet.z = z;
86 mav_array_memcpy(packet.q, q, sizeof(float)*4);
87 mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21);
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
89#endif
90
92 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
93}
94
95/**
96 * @brief Pack a att_pos_mocap message
97 * @param system_id ID of this system
98 * @param component_id ID of this component (e.g. 200 for IMU)
99 * @param status MAVLink status structure
100 * @param msg The MAVLink message to compress the data into
101 *
102 * @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.
103 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
104 * @param x [m] X position (NED)
105 * @param y [m] Y position (NED)
106 * @param z [m] Z position (NED)
107 * @param covariance Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
108 * @return length of the message in bytes (excluding serial stream start sign)
109 */
110static inline uint16_t mavlink_msg_att_pos_mocap_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
111 uint64_t time_usec, const float *q, float x, float y, float z, const float *covariance)
112{
113#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 _mav_put_uint64_t(buf, 0, time_usec);
116 _mav_put_float(buf, 24, x);
117 _mav_put_float(buf, 28, y);
118 _mav_put_float(buf, 32, z);
119 _mav_put_float_array(buf, 8, q, 4);
120 _mav_put_float_array(buf, 36, covariance, 21);
121 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
122#else
123 mavlink_att_pos_mocap_t packet;
124 packet.time_usec = time_usec;
125 packet.x = x;
126 packet.y = y;
127 packet.z = z;
128 mav_array_memcpy(packet.q, q, sizeof(float)*4);
129 mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21);
130 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
131#endif
132
133 msg->msgid = MAVLINK_MSG_ID_ATT_POS_MOCAP;
134#if MAVLINK_CRC_EXTRA
135 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
136#else
137 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
138#endif
139}
140
141/**
142 * @brief Pack a att_pos_mocap message on a channel
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param chan The MAVLink channel this message will be sent over
146 * @param msg The MAVLink message to compress the data into
147 * @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.
148 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
149 * @param x [m] X position (NED)
150 * @param y [m] Y position (NED)
151 * @param z [m] Z position (NED)
152 * @param covariance Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
153 * @return length of the message in bytes (excluding serial stream start sign)
154 */
155static inline uint16_t mavlink_msg_att_pos_mocap_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
156 mavlink_message_t* msg,
157 uint64_t time_usec,const float *q,float x,float y,float z,const float *covariance)
158{
159#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
161 _mav_put_uint64_t(buf, 0, time_usec);
162 _mav_put_float(buf, 24, x);
163 _mav_put_float(buf, 28, y);
164 _mav_put_float(buf, 32, z);
165 _mav_put_float_array(buf, 8, q, 4);
166 _mav_put_float_array(buf, 36, covariance, 21);
167 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
168#else
169 mavlink_att_pos_mocap_t packet;
170 packet.time_usec = time_usec;
171 packet.x = x;
172 packet.y = y;
173 packet.z = z;
174 mav_array_memcpy(packet.q, q, sizeof(float)*4);
175 mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21);
176 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
177#endif
178
179 msg->msgid = MAVLINK_MSG_ID_ATT_POS_MOCAP;
180 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
181}
182
183/**
184 * @brief Encode a att_pos_mocap struct
185 *
186 * @param system_id ID of this system
187 * @param component_id ID of this component (e.g. 200 for IMU)
188 * @param msg The MAVLink message to compress the data into
189 * @param att_pos_mocap C-struct to read the message contents from
190 */
191static inline uint16_t mavlink_msg_att_pos_mocap_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_att_pos_mocap_t* att_pos_mocap)
192{
193 return mavlink_msg_att_pos_mocap_pack(system_id, component_id, msg, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance);
194}
195
196/**
197 * @brief Encode a att_pos_mocap struct on a channel
198 *
199 * @param system_id ID of this system
200 * @param component_id ID of this component (e.g. 200 for IMU)
201 * @param chan The MAVLink channel this message will be sent over
202 * @param msg The MAVLink message to compress the data into
203 * @param att_pos_mocap C-struct to read the message contents from
204 */
205static inline uint16_t mavlink_msg_att_pos_mocap_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_att_pos_mocap_t* att_pos_mocap)
206{
207 return mavlink_msg_att_pos_mocap_pack_chan(system_id, component_id, chan, msg, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance);
208}
209
210/**
211 * @brief Encode a att_pos_mocap struct with provided status structure
212 *
213 * @param system_id ID of this system
214 * @param component_id ID of this component (e.g. 200 for IMU)
215 * @param status MAVLink status structure
216 * @param msg The MAVLink message to compress the data into
217 * @param att_pos_mocap C-struct to read the message contents from
218 */
219static inline uint16_t mavlink_msg_att_pos_mocap_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_att_pos_mocap_t* att_pos_mocap)
220{
221 return mavlink_msg_att_pos_mocap_pack_status(system_id, component_id, _status, msg, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance);
222}
223
224/**
225 * @brief Send a att_pos_mocap message
226 * @param chan MAVLink channel to send the message
227 *
228 * @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.
229 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
230 * @param x [m] X position (NED)
231 * @param y [m] Y position (NED)
232 * @param z [m] Z position (NED)
233 * @param covariance Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
234 */
235#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
236
237static inline void mavlink_msg_att_pos_mocap_send(mavlink_channel_t chan, uint64_t time_usec, const float *q, float x, float y, float z, const float *covariance)
238{
239#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
240 char buf[MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN];
241 _mav_put_uint64_t(buf, 0, time_usec);
242 _mav_put_float(buf, 24, x);
243 _mav_put_float(buf, 28, y);
244 _mav_put_float(buf, 32, z);
245 _mav_put_float_array(buf, 8, q, 4);
246 _mav_put_float_array(buf, 36, covariance, 21);
247 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATT_POS_MOCAP, buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
248#else
249 mavlink_att_pos_mocap_t packet;
250 packet.time_usec = time_usec;
251 packet.x = x;
252 packet.y = y;
253 packet.z = z;
254 mav_array_memcpy(packet.q, q, sizeof(float)*4);
255 mav_array_memcpy(packet.covariance, covariance, sizeof(float)*21);
256 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATT_POS_MOCAP, (const char *)&packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
257#endif
258}
259
260/**
261 * @brief Send a att_pos_mocap message
262 * @param chan MAVLink channel to send the message
263 * @param struct The MAVLink struct to serialize
264 */
265static inline void mavlink_msg_att_pos_mocap_send_struct(mavlink_channel_t chan, const mavlink_att_pos_mocap_t* att_pos_mocap)
266{
267#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
268 mavlink_msg_att_pos_mocap_send(chan, att_pos_mocap->time_usec, att_pos_mocap->q, att_pos_mocap->x, att_pos_mocap->y, att_pos_mocap->z, att_pos_mocap->covariance);
269#else
270 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATT_POS_MOCAP, (const char *)att_pos_mocap, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
271#endif
272}
273
274#if MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN <= MAVLINK_MAX_PAYLOAD_LEN
275/*
276 This variant of _send() can be used to save stack space by reusing
277 memory from the receive buffer. The caller provides a
278 mavlink_message_t which is the size of a full mavlink message. This
279 is usually the receive buffer for the channel, and allows a reply to an
280 incoming message with minimum stack space usage.
281 */
282static inline void mavlink_msg_att_pos_mocap_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, const float *q, float x, float y, float z, const float *covariance)
283{
284#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
285 char *buf = (char *)msgbuf;
286 _mav_put_uint64_t(buf, 0, time_usec);
287 _mav_put_float(buf, 24, x);
288 _mav_put_float(buf, 28, y);
289 _mav_put_float(buf, 32, z);
290 _mav_put_float_array(buf, 8, q, 4);
291 _mav_put_float_array(buf, 36, covariance, 21);
292 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATT_POS_MOCAP, buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
293#else
294 mavlink_att_pos_mocap_t *packet = (mavlink_att_pos_mocap_t *)msgbuf;
295 packet->time_usec = time_usec;
296 packet->x = x;
297 packet->y = y;
298 packet->z = z;
299 mav_array_memcpy(packet->q, q, sizeof(float)*4);
300 mav_array_memcpy(packet->covariance, covariance, sizeof(float)*21);
301 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATT_POS_MOCAP, (const char *)packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN, MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC);
302#endif
303}
304#endif
305
306#endif
307
308// MESSAGE ATT_POS_MOCAP UNPACKING
309
310
311/**
312 * @brief Get field time_usec from att_pos_mocap message
313 *
314 * @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.
315 */
316static inline uint64_t mavlink_msg_att_pos_mocap_get_time_usec(const mavlink_message_t* msg)
317{
318 return _MAV_RETURN_uint64_t(msg, 0);
319}
320
321/**
322 * @brief Get field q from att_pos_mocap message
323 *
324 * @return Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
325 */
326static inline uint16_t mavlink_msg_att_pos_mocap_get_q(const mavlink_message_t* msg, float *q)
327{
328 return _MAV_RETURN_float_array(msg, q, 4, 8);
329}
330
331/**
332 * @brief Get field x from att_pos_mocap message
333 *
334 * @return [m] X position (NED)
335 */
336static inline float mavlink_msg_att_pos_mocap_get_x(const mavlink_message_t* msg)
337{
338 return _MAV_RETURN_float(msg, 24);
339}
340
341/**
342 * @brief Get field y from att_pos_mocap message
343 *
344 * @return [m] Y position (NED)
345 */
346static inline float mavlink_msg_att_pos_mocap_get_y(const mavlink_message_t* msg)
347{
348 return _MAV_RETURN_float(msg, 28);
349}
350
351/**
352 * @brief Get field z from att_pos_mocap message
353 *
354 * @return [m] Z position (NED)
355 */
356static inline float mavlink_msg_att_pos_mocap_get_z(const mavlink_message_t* msg)
357{
358 return _MAV_RETURN_float(msg, 32);
359}
360
361/**
362 * @brief Get field covariance from att_pos_mocap message
363 *
364 * @return Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
365 */
366static inline uint16_t mavlink_msg_att_pos_mocap_get_covariance(const mavlink_message_t* msg, float *covariance)
367{
368 return _MAV_RETURN_float_array(msg, covariance, 21, 36);
369}
370
371/**
372 * @brief Decode a att_pos_mocap message into a struct
373 *
374 * @param msg The message to decode
375 * @param att_pos_mocap C-struct to decode the message contents into
376 */
377static inline void mavlink_msg_att_pos_mocap_decode(const mavlink_message_t* msg, mavlink_att_pos_mocap_t* att_pos_mocap)
378{
379#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
380 att_pos_mocap->time_usec = mavlink_msg_att_pos_mocap_get_time_usec(msg);
381 mavlink_msg_att_pos_mocap_get_q(msg, att_pos_mocap->q);
382 att_pos_mocap->x = mavlink_msg_att_pos_mocap_get_x(msg);
383 att_pos_mocap->y = mavlink_msg_att_pos_mocap_get_y(msg);
384 att_pos_mocap->z = mavlink_msg_att_pos_mocap_get_z(msg);
385 mavlink_msg_att_pos_mocap_get_covariance(msg, att_pos_mocap->covariance);
386#else
387 uint8_t len = msg->len < MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN? msg->len : MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN;
388 memset(att_pos_mocap, 0, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
389 memcpy(att_pos_mocap, _MAV_PAYLOAD(msg), len);
390#endif
391}