source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/mavlink_generated_messages/common/mavlink_msg_att_pos_mocap.h@ 46

Last change on this file since 46 was 46, checked in by Thomas Fuhrmann, 8 years ago

Add the mavlink branch

File size: 11.9 KB
Line 
1// MESSAGE ATT_POS_MOCAP PACKING
2
3#define MAVLINK_MSG_ID_ATT_POS_MOCAP 138
4
5MAVPACKED(
6typedef struct __mavlink_att_pos_mocap_t {
7 uint64_t time_usec; /*< Timestamp (micros since boot or Unix epoch)*/
8 float q[4]; /*< Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)*/
9 float x; /*< X position in meters (NED)*/
10 float y; /*< Y position in meters (NED)*/
11 float z; /*< Z position in meters (NED)*/
12}) mavlink_att_pos_mocap_t;
13
14#define MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN 36
15#define MAVLINK_MSG_ID_ATT_POS_MOCAP_MIN_LEN 36
16#define MAVLINK_MSG_ID_138_LEN 36
17#define MAVLINK_MSG_ID_138_MIN_LEN 36
18
19#define MAVLINK_MSG_ID_ATT_POS_MOCAP_CRC 109
20#define MAVLINK_MSG_ID_138_CRC 109
21
22#define MAVLINK_MSG_ATT_POS_MOCAP_FIELD_Q_LEN 4
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_ATT_POS_MOCAP { \
26 138, \
27 "ATT_POS_MOCAP", \
28 5, \
29 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_att_pos_mocap_t, time_usec) }, \
30 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 8, offsetof(mavlink_att_pos_mocap_t, q) }, \
31 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_att_pos_mocap_t, x) }, \
32 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_att_pos_mocap_t, y) }, \
33 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_att_pos_mocap_t, z) }, \
34 } \
35}
36#else
37#define MAVLINK_MESSAGE_INFO_ATT_POS_MOCAP { \
38 "ATT_POS_MOCAP", \
39 5, \
40 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_att_pos_mocap_t, time_usec) }, \
41 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 8, offsetof(mavlink_att_pos_mocap_t, q) }, \
42 { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_att_pos_mocap_t, x) }, \
43 { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_att_pos_mocap_t, y) }, \
44 { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_att_pos_mocap_t, z) }, \
45 } \
46}
47#endif
48
49/**
50 * @brief Pack a att_pos_mocap message
51 * @param system_id ID of this system
52 * @param component_id ID of this component (e.g. 200 for IMU)
53 * @param msg The MAVLink message to compress the data into
54 *
55 * @param time_usec Timestamp (micros since boot or Unix epoch)
56 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
57 * @param x X position in meters (NED)
58 * @param y Y position in meters (NED)
59 * @param z Z position in meters (NED)
60 * @return length of the message in bytes (excluding serial stream start sign)
61 */
62static inline uint16_t mavlink_msg_att_pos_mocap_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
63 uint64_t time_usec, const float *q, float x, float y, float z)
64{
65#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN];
67 _mav_put_uint64_t(buf, 0, time_usec);
68 _mav_put_float(buf, 24, x);
69 _mav_put_float(buf, 28, y);
70 _mav_put_float(buf, 32, z);
71 _mav_put_float_array(buf, 8, q, 4);
72 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
73#else
74 mavlink_att_pos_mocap_t packet;
75 packet.time_usec = time_usec;
76 packet.x = x;
77 packet.y = y;
78 packet.z = z;
79 mav_array_memcpy(packet.q, q, sizeof(float)*4);
80 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
81#endif
82
83 msg->msgid = MAVLINK_MSG_ID_ATT_POS_MOCAP;
84 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);
85}
86
87/**
88 * @brief Pack a att_pos_mocap message on a channel
89 * @param system_id ID of this system
90 * @param component_id ID of this component (e.g. 200 for IMU)
91 * @param chan The MAVLink channel this message will be sent over
92 * @param msg The MAVLink message to compress the data into
93 * @param time_usec Timestamp (micros since boot or Unix epoch)
94 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
95 * @param x X position in meters (NED)
96 * @param y Y position in meters (NED)
97 * @param z Z position in meters (NED)
98 * @return length of the message in bytes (excluding serial stream start sign)
99 */
100static inline uint16_t mavlink_msg_att_pos_mocap_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
101 mavlink_message_t* msg,
102 uint64_t time_usec,const float *q,float x,float y,float z)
103{
104#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
105 char buf[MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN];
106 _mav_put_uint64_t(buf, 0, time_usec);
107 _mav_put_float(buf, 24, x);
108 _mav_put_float(buf, 28, y);
109 _mav_put_float(buf, 32, z);
110 _mav_put_float_array(buf, 8, q, 4);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
112#else
113 mavlink_att_pos_mocap_t packet;
114 packet.time_usec = time_usec;
115 packet.x = x;
116 packet.y = y;
117 packet.z = z;
118 mav_array_memcpy(packet.q, q, sizeof(float)*4);
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
120#endif
121
122 msg->msgid = MAVLINK_MSG_ID_ATT_POS_MOCAP;
123 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);
124}
125
126/**
127 * @brief Encode a att_pos_mocap struct
128 *
129 * @param system_id ID of this system
130 * @param component_id ID of this component (e.g. 200 for IMU)
131 * @param msg The MAVLink message to compress the data into
132 * @param att_pos_mocap C-struct to read the message contents from
133 */
134static 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)
135{
136 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);
137}
138
139/**
140 * @brief Encode a att_pos_mocap struct on a channel
141 *
142 * @param system_id ID of this system
143 * @param component_id ID of this component (e.g. 200 for IMU)
144 * @param chan The MAVLink channel this message will be sent over
145 * @param msg The MAVLink message to compress the data into
146 * @param att_pos_mocap C-struct to read the message contents from
147 */
148static 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)
149{
150 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);
151}
152
153/**
154 * @brief Send a att_pos_mocap message
155 * @param chan MAVLink channel to send the message
156 *
157 * @param time_usec Timestamp (micros since boot or Unix epoch)
158 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
159 * @param x X position in meters (NED)
160 * @param y Y position in meters (NED)
161 * @param z Z position in meters (NED)
162 */
163#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
164
165static 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)
166{
167#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
168 char buf[MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN];
169 _mav_put_uint64_t(buf, 0, time_usec);
170 _mav_put_float(buf, 24, x);
171 _mav_put_float(buf, 28, y);
172 _mav_put_float(buf, 32, z);
173 _mav_put_float_array(buf, 8, q, 4);
174 _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);
175#else
176 mavlink_att_pos_mocap_t packet;
177 packet.time_usec = time_usec;
178 packet.x = x;
179 packet.y = y;
180 packet.z = z;
181 mav_array_memcpy(packet.q, q, sizeof(float)*4);
182 _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);
183#endif
184}
185
186/**
187 * @brief Send a att_pos_mocap message
188 * @param chan MAVLink channel to send the message
189 * @param struct The MAVLink struct to serialize
190 */
191static inline void mavlink_msg_att_pos_mocap_send_struct(mavlink_channel_t chan, const mavlink_att_pos_mocap_t* att_pos_mocap)
192{
193#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 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);
195#else
196 _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);
197#endif
198}
199
200#if MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN <= MAVLINK_MAX_PAYLOAD_LEN
201/*
202 This varient of _send() can be used to save stack space by re-using
203 memory from the receive buffer. The caller provides a
204 mavlink_message_t which is the size of a full mavlink message. This
205 is usually the receive buffer for the channel, and allows a reply to an
206 incoming message with minimum stack space usage.
207 */
208static 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)
209{
210#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
211 char *buf = (char *)msgbuf;
212 _mav_put_uint64_t(buf, 0, time_usec);
213 _mav_put_float(buf, 24, x);
214 _mav_put_float(buf, 28, y);
215 _mav_put_float(buf, 32, z);
216 _mav_put_float_array(buf, 8, q, 4);
217 _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);
218#else
219 mavlink_att_pos_mocap_t *packet = (mavlink_att_pos_mocap_t *)msgbuf;
220 packet->time_usec = time_usec;
221 packet->x = x;
222 packet->y = y;
223 packet->z = z;
224 mav_array_memcpy(packet->q, q, sizeof(float)*4);
225 _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);
226#endif
227}
228#endif
229
230#endif
231
232// MESSAGE ATT_POS_MOCAP UNPACKING
233
234
235/**
236 * @brief Get field time_usec from att_pos_mocap message
237 *
238 * @return Timestamp (micros since boot or Unix epoch)
239 */
240static inline uint64_t mavlink_msg_att_pos_mocap_get_time_usec(const mavlink_message_t* msg)
241{
242 return _MAV_RETURN_uint64_t(msg, 0);
243}
244
245/**
246 * @brief Get field q from att_pos_mocap message
247 *
248 * @return Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
249 */
250static inline uint16_t mavlink_msg_att_pos_mocap_get_q(const mavlink_message_t* msg, float *q)
251{
252 return _MAV_RETURN_float_array(msg, q, 4, 8);
253}
254
255/**
256 * @brief Get field x from att_pos_mocap message
257 *
258 * @return X position in meters (NED)
259 */
260static inline float mavlink_msg_att_pos_mocap_get_x(const mavlink_message_t* msg)
261{
262 return _MAV_RETURN_float(msg, 24);
263}
264
265/**
266 * @brief Get field y from att_pos_mocap message
267 *
268 * @return Y position in meters (NED)
269 */
270static inline float mavlink_msg_att_pos_mocap_get_y(const mavlink_message_t* msg)
271{
272 return _MAV_RETURN_float(msg, 28);
273}
274
275/**
276 * @brief Get field z from att_pos_mocap message
277 *
278 * @return Z position in meters (NED)
279 */
280static inline float mavlink_msg_att_pos_mocap_get_z(const mavlink_message_t* msg)
281{
282 return _MAV_RETURN_float(msg, 32);
283}
284
285/**
286 * @brief Decode a att_pos_mocap message into a struct
287 *
288 * @param msg The message to decode
289 * @param att_pos_mocap C-struct to decode the message contents into
290 */
291static inline void mavlink_msg_att_pos_mocap_decode(const mavlink_message_t* msg, mavlink_att_pos_mocap_t* att_pos_mocap)
292{
293#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
294 att_pos_mocap->time_usec = mavlink_msg_att_pos_mocap_get_time_usec(msg);
295 mavlink_msg_att_pos_mocap_get_q(msg, att_pos_mocap->q);
296 att_pos_mocap->x = mavlink_msg_att_pos_mocap_get_x(msg);
297 att_pos_mocap->y = mavlink_msg_att_pos_mocap_get_y(msg);
298 att_pos_mocap->z = mavlink_msg_att_pos_mocap_get_z(msg);
299#else
300 uint8_t len = msg->len < MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN? msg->len : MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN;
301 memset(att_pos_mocap, 0, MAVLINK_MSG_ID_ATT_POS_MOCAP_LEN);
302 memcpy(att_pos_mocap, _MAV_PAYLOAD(msg), len);
303#endif
304}
Note: See TracBrowser for help on using the repository browser.