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

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

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

File size: 16.8 KB
Line 
1// MESSAGE ATTITUDE_TARGET PACKING
2
3#define MAVLINK_MSG_ID_ATTITUDE_TARGET 83
4
5typedef struct MAVLINK_PACKED __mavlink_attitude_target_t
6{
7 uint32_t time_boot_ms; /*< Timestamp in milliseconds since system boot*/
8 float q[4]; /*< Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)*/
9 float body_roll_rate; /*< Body roll rate in radians per second*/
10 float body_pitch_rate; /*< Body roll rate in radians per second*/
11 float body_yaw_rate; /*< Body roll rate in radians per second*/
12 float thrust; /*< Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)*/
13 uint8_t type_mask; /*< Mappings: If any of these bits are set, the corresponding input should be ignored: bit 1: body roll rate, bit 2: body pitch rate, bit 3: body yaw rate. bit 4-bit 7: reserved, bit 8: attitude*/
14} mavlink_attitude_target_t;
15
16#define MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN 37
17#define MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN 37
18#define MAVLINK_MSG_ID_83_LEN 37
19#define MAVLINK_MSG_ID_83_MIN_LEN 37
20
21#define MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC 22
22#define MAVLINK_MSG_ID_83_CRC 22
23
24#define MAVLINK_MSG_ATTITUDE_TARGET_FIELD_Q_LEN 4
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_ATTITUDE_TARGET { \
28 83, \
29 "ATTITUDE_TARGET", \
30 7, \
31 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_target_t, time_boot_ms) }, \
32 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 4, offsetof(mavlink_attitude_target_t, q) }, \
33 { "body_roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_target_t, body_roll_rate) }, \
34 { "body_pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_target_t, body_pitch_rate) }, \
35 { "body_yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_target_t, body_yaw_rate) }, \
36 { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_attitude_target_t, thrust) }, \
37 { "type_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_attitude_target_t, type_mask) }, \
38 } \
39}
40#else
41#define MAVLINK_MESSAGE_INFO_ATTITUDE_TARGET { \
42 "ATTITUDE_TARGET", \
43 7, \
44 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_target_t, time_boot_ms) }, \
45 { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 4, offsetof(mavlink_attitude_target_t, q) }, \
46 { "body_roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_target_t, body_roll_rate) }, \
47 { "body_pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_target_t, body_pitch_rate) }, \
48 { "body_yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_target_t, body_yaw_rate) }, \
49 { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_attitude_target_t, thrust) }, \
50 { "type_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_attitude_target_t, type_mask) }, \
51 } \
52}
53#endif
54
55/**
56 * @brief Pack a attitude_target message
57 * @param system_id ID of this system
58 * @param component_id ID of this component (e.g. 200 for IMU)
59 * @param msg The MAVLink message to compress the data into
60 *
61 * @param time_boot_ms Timestamp in milliseconds since system boot
62 * @param type_mask Mappings: If any of these bits are set, the corresponding input should be ignored: bit 1: body roll rate, bit 2: body pitch rate, bit 3: body yaw rate. bit 4-bit 7: reserved, bit 8: attitude
63 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
64 * @param body_roll_rate Body roll rate in radians per second
65 * @param body_pitch_rate Body roll rate in radians per second
66 * @param body_yaw_rate Body roll rate in radians per second
67 * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
68 * @return length of the message in bytes (excluding serial stream start sign)
69 */
70static inline uint16_t mavlink_msg_attitude_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
71 uint32_t time_boot_ms, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust)
72{
73#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
74 char buf[MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN];
75 _mav_put_uint32_t(buf, 0, time_boot_ms);
76 _mav_put_float(buf, 20, body_roll_rate);
77 _mav_put_float(buf, 24, body_pitch_rate);
78 _mav_put_float(buf, 28, body_yaw_rate);
79 _mav_put_float(buf, 32, thrust);
80 _mav_put_uint8_t(buf, 36, type_mask);
81 _mav_put_float_array(buf, 4, q, 4);
82 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN);
83#else
84 mavlink_attitude_target_t packet;
85 packet.time_boot_ms = time_boot_ms;
86 packet.body_roll_rate = body_roll_rate;
87 packet.body_pitch_rate = body_pitch_rate;
88 packet.body_yaw_rate = body_yaw_rate;
89 packet.thrust = thrust;
90 packet.type_mask = type_mask;
91 mav_array_memcpy(packet.q, q, sizeof(float)*4);
92 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN);
93#endif
94
95 msg->msgid = MAVLINK_MSG_ID_ATTITUDE_TARGET;
96 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
97}
98
99/**
100 * @brief Pack a attitude_target message on a channel
101 * @param system_id ID of this system
102 * @param component_id ID of this component (e.g. 200 for IMU)
103 * @param chan The MAVLink channel this message will be sent over
104 * @param msg The MAVLink message to compress the data into
105 * @param time_boot_ms Timestamp in milliseconds since system boot
106 * @param type_mask Mappings: If any of these bits are set, the corresponding input should be ignored: bit 1: body roll rate, bit 2: body pitch rate, bit 3: body yaw rate. bit 4-bit 7: reserved, bit 8: attitude
107 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
108 * @param body_roll_rate Body roll rate in radians per second
109 * @param body_pitch_rate Body roll rate in radians per second
110 * @param body_yaw_rate Body roll rate in radians per second
111 * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
112 * @return length of the message in bytes (excluding serial stream start sign)
113 */
114static inline uint16_t mavlink_msg_attitude_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
115 mavlink_message_t* msg,
116 uint32_t time_boot_ms,uint8_t type_mask,const float *q,float body_roll_rate,float body_pitch_rate,float body_yaw_rate,float thrust)
117{
118#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
119 char buf[MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN];
120 _mav_put_uint32_t(buf, 0, time_boot_ms);
121 _mav_put_float(buf, 20, body_roll_rate);
122 _mav_put_float(buf, 24, body_pitch_rate);
123 _mav_put_float(buf, 28, body_yaw_rate);
124 _mav_put_float(buf, 32, thrust);
125 _mav_put_uint8_t(buf, 36, type_mask);
126 _mav_put_float_array(buf, 4, q, 4);
127 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN);
128#else
129 mavlink_attitude_target_t packet;
130 packet.time_boot_ms = time_boot_ms;
131 packet.body_roll_rate = body_roll_rate;
132 packet.body_pitch_rate = body_pitch_rate;
133 packet.body_yaw_rate = body_yaw_rate;
134 packet.thrust = thrust;
135 packet.type_mask = type_mask;
136 mav_array_memcpy(packet.q, q, sizeof(float)*4);
137 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN);
138#endif
139
140 msg->msgid = MAVLINK_MSG_ID_ATTITUDE_TARGET;
141 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
142}
143
144/**
145 * @brief Encode a attitude_target struct
146 *
147 * @param system_id ID of this system
148 * @param component_id ID of this component (e.g. 200 for IMU)
149 * @param msg The MAVLink message to compress the data into
150 * @param attitude_target C-struct to read the message contents from
151 */
152static inline uint16_t mavlink_msg_attitude_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_attitude_target_t* attitude_target)
153{
154 return mavlink_msg_attitude_target_pack(system_id, component_id, msg, attitude_target->time_boot_ms, attitude_target->type_mask, attitude_target->q, attitude_target->body_roll_rate, attitude_target->body_pitch_rate, attitude_target->body_yaw_rate, attitude_target->thrust);
155}
156
157/**
158 * @brief Encode a attitude_target struct on a channel
159 *
160 * @param system_id ID of this system
161 * @param component_id ID of this component (e.g. 200 for IMU)
162 * @param chan The MAVLink channel this message will be sent over
163 * @param msg The MAVLink message to compress the data into
164 * @param attitude_target C-struct to read the message contents from
165 */
166static inline uint16_t mavlink_msg_attitude_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_attitude_target_t* attitude_target)
167{
168 return mavlink_msg_attitude_target_pack_chan(system_id, component_id, chan, msg, attitude_target->time_boot_ms, attitude_target->type_mask, attitude_target->q, attitude_target->body_roll_rate, attitude_target->body_pitch_rate, attitude_target->body_yaw_rate, attitude_target->thrust);
169}
170
171/**
172 * @brief Send a attitude_target message
173 * @param chan MAVLink channel to send the message
174 *
175 * @param time_boot_ms Timestamp in milliseconds since system boot
176 * @param type_mask Mappings: If any of these bits are set, the corresponding input should be ignored: bit 1: body roll rate, bit 2: body pitch rate, bit 3: body yaw rate. bit 4-bit 7: reserved, bit 8: attitude
177 * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
178 * @param body_roll_rate Body roll rate in radians per second
179 * @param body_pitch_rate Body roll rate in radians per second
180 * @param body_yaw_rate Body roll rate in radians per second
181 * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
182 */
183#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
184
185static inline void mavlink_msg_attitude_target_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust)
186{
187#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
188 char buf[MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN];
189 _mav_put_uint32_t(buf, 0, time_boot_ms);
190 _mav_put_float(buf, 20, body_roll_rate);
191 _mav_put_float(buf, 24, body_pitch_rate);
192 _mav_put_float(buf, 28, body_yaw_rate);
193 _mav_put_float(buf, 32, thrust);
194 _mav_put_uint8_t(buf, 36, type_mask);
195 _mav_put_float_array(buf, 4, q, 4);
196 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_TARGET, buf, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
197#else
198 mavlink_attitude_target_t packet;
199 packet.time_boot_ms = time_boot_ms;
200 packet.body_roll_rate = body_roll_rate;
201 packet.body_pitch_rate = body_pitch_rate;
202 packet.body_yaw_rate = body_yaw_rate;
203 packet.thrust = thrust;
204 packet.type_mask = type_mask;
205 mav_array_memcpy(packet.q, q, sizeof(float)*4);
206 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_TARGET, (const char *)&packet, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
207#endif
208}
209
210/**
211 * @brief Send a attitude_target message
212 * @param chan MAVLink channel to send the message
213 * @param struct The MAVLink struct to serialize
214 */
215static inline void mavlink_msg_attitude_target_send_struct(mavlink_channel_t chan, const mavlink_attitude_target_t* attitude_target)
216{
217#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
218 mavlink_msg_attitude_target_send(chan, attitude_target->time_boot_ms, attitude_target->type_mask, attitude_target->q, attitude_target->body_roll_rate, attitude_target->body_pitch_rate, attitude_target->body_yaw_rate, attitude_target->thrust);
219#else
220 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_TARGET, (const char *)attitude_target, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
221#endif
222}
223
224#if MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
225/*
226 This varient of _send() can be used to save stack space by re-using
227 memory from the receive buffer. The caller provides a
228 mavlink_message_t which is the size of a full mavlink message. This
229 is usually the receive buffer for the channel, and allows a reply to an
230 incoming message with minimum stack space usage.
231 */
232static inline void mavlink_msg_attitude_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust)
233{
234#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
235 char *buf = (char *)msgbuf;
236 _mav_put_uint32_t(buf, 0, time_boot_ms);
237 _mav_put_float(buf, 20, body_roll_rate);
238 _mav_put_float(buf, 24, body_pitch_rate);
239 _mav_put_float(buf, 28, body_yaw_rate);
240 _mav_put_float(buf, 32, thrust);
241 _mav_put_uint8_t(buf, 36, type_mask);
242 _mav_put_float_array(buf, 4, q, 4);
243 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_TARGET, buf, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
244#else
245 mavlink_attitude_target_t *packet = (mavlink_attitude_target_t *)msgbuf;
246 packet->time_boot_ms = time_boot_ms;
247 packet->body_roll_rate = body_roll_rate;
248 packet->body_pitch_rate = body_pitch_rate;
249 packet->body_yaw_rate = body_yaw_rate;
250 packet->thrust = thrust;
251 packet->type_mask = type_mask;
252 mav_array_memcpy(packet->q, q, sizeof(float)*4);
253 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_TARGET, (const char *)packet, MAVLINK_MSG_ID_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_ATTITUDE_TARGET_CRC);
254#endif
255}
256#endif
257
258#endif
259
260// MESSAGE ATTITUDE_TARGET UNPACKING
261
262
263/**
264 * @brief Get field time_boot_ms from attitude_target message
265 *
266 * @return Timestamp in milliseconds since system boot
267 */
268static inline uint32_t mavlink_msg_attitude_target_get_time_boot_ms(const mavlink_message_t* msg)
269{
270 return _MAV_RETURN_uint32_t(msg, 0);
271}
272
273/**
274 * @brief Get field type_mask from attitude_target message
275 *
276 * @return Mappings: If any of these bits are set, the corresponding input should be ignored: bit 1: body roll rate, bit 2: body pitch rate, bit 3: body yaw rate. bit 4-bit 7: reserved, bit 8: attitude
277 */
278static inline uint8_t mavlink_msg_attitude_target_get_type_mask(const mavlink_message_t* msg)
279{
280 return _MAV_RETURN_uint8_t(msg, 36);
281}
282
283/**
284 * @brief Get field q from attitude_target message
285 *
286 * @return Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
287 */
288static inline uint16_t mavlink_msg_attitude_target_get_q(const mavlink_message_t* msg, float *q)
289{
290 return _MAV_RETURN_float_array(msg, q, 4, 4);
291}
292
293/**
294 * @brief Get field body_roll_rate from attitude_target message
295 *
296 * @return Body roll rate in radians per second
297 */
298static inline float mavlink_msg_attitude_target_get_body_roll_rate(const mavlink_message_t* msg)
299{
300 return _MAV_RETURN_float(msg, 20);
301}
302
303/**
304 * @brief Get field body_pitch_rate from attitude_target message
305 *
306 * @return Body roll rate in radians per second
307 */
308static inline float mavlink_msg_attitude_target_get_body_pitch_rate(const mavlink_message_t* msg)
309{
310 return _MAV_RETURN_float(msg, 24);
311}
312
313/**
314 * @brief Get field body_yaw_rate from attitude_target message
315 *
316 * @return Body roll rate in radians per second
317 */
318static inline float mavlink_msg_attitude_target_get_body_yaw_rate(const mavlink_message_t* msg)
319{
320 return _MAV_RETURN_float(msg, 28);
321}
322
323/**
324 * @brief Get field thrust from attitude_target message
325 *
326 * @return Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
327 */
328static inline float mavlink_msg_attitude_target_get_thrust(const mavlink_message_t* msg)
329{
330 return _MAV_RETURN_float(msg, 32);
331}
332
333/**
334 * @brief Decode a attitude_target message into a struct
335 *
336 * @param msg The message to decode
337 * @param attitude_target C-struct to decode the message contents into
338 */
339static inline void mavlink_msg_attitude_target_decode(const mavlink_message_t* msg, mavlink_attitude_target_t* attitude_target)
340{
341#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
342 attitude_target->time_boot_ms = mavlink_msg_attitude_target_get_time_boot_ms(msg);
343 mavlink_msg_attitude_target_get_q(msg, attitude_target->q);
344 attitude_target->body_roll_rate = mavlink_msg_attitude_target_get_body_roll_rate(msg);
345 attitude_target->body_pitch_rate = mavlink_msg_attitude_target_get_body_pitch_rate(msg);
346 attitude_target->body_yaw_rate = mavlink_msg_attitude_target_get_body_yaw_rate(msg);
347 attitude_target->thrust = mavlink_msg_attitude_target_get_thrust(msg);
348 attitude_target->type_mask = mavlink_msg_attitude_target_get_type_mask(msg);
349#else
350 uint8_t len = msg->len < MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN? msg->len : MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN;
351 memset(attitude_target, 0, MAVLINK_MSG_ID_ATTITUDE_TARGET_LEN);
352 memcpy(attitude_target, _MAV_PAYLOAD(msg), len);
353#endif
354}
Note: See TracBrowser for help on using the repository browser.