source: flair-src/trunk/tools/Controller/Mavlink/src/include/common/mavlink_msg_landing_target.h @ 88

Last change on this file since 88 was 88, checked in by Sanahuja Guillaume, 5 years ago

m

File size: 16.7 KB
Line 
1// MESSAGE LANDING_TARGET PACKING
2
3#define MAVLINK_MSG_ID_LANDING_TARGET 149
4
5typedef struct MAVLINK_PACKED __mavlink_landing_target_t
6{
7 uint64_t time_usec; /*< Timestamp (micros since boot or Unix epoch)*/
8 float angle_x; /*< X-axis angular offset (in radians) of the target from the center of the image*/
9 float angle_y; /*< Y-axis angular offset (in radians) of the target from the center of the image*/
10 float distance; /*< Distance to the target from the vehicle in meters*/
11 float size_x; /*< Size in radians of target along x-axis*/
12 float size_y; /*< Size in radians of target along y-axis*/
13 uint8_t target_num; /*< The ID of the target if multiple targets are present*/
14 uint8_t frame; /*< MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.*/
15} mavlink_landing_target_t;
16
17#define MAVLINK_MSG_ID_LANDING_TARGET_LEN 30
18#define MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN 30
19#define MAVLINK_MSG_ID_149_LEN 30
20#define MAVLINK_MSG_ID_149_MIN_LEN 30
21
22#define MAVLINK_MSG_ID_LANDING_TARGET_CRC 200
23#define MAVLINK_MSG_ID_149_CRC 200
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_LANDING_TARGET { \
29        149, \
30        "LANDING_TARGET", \
31        8, \
32        {  { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_landing_target_t, time_usec) }, \
33         { "angle_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_landing_target_t, angle_x) }, \
34         { "angle_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_landing_target_t, angle_y) }, \
35         { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_landing_target_t, distance) }, \
36         { "size_x", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_landing_target_t, size_x) }, \
37         { "size_y", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_landing_target_t, size_y) }, \
38         { "target_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_landing_target_t, target_num) }, \
39         { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_landing_target_t, frame) }, \
40         } \
41}
42#else
43#define MAVLINK_MESSAGE_INFO_LANDING_TARGET { \
44        "LANDING_TARGET", \
45        8, \
46        {  { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_landing_target_t, time_usec) }, \
47         { "angle_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_landing_target_t, angle_x) }, \
48         { "angle_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_landing_target_t, angle_y) }, \
49         { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_landing_target_t, distance) }, \
50         { "size_x", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_landing_target_t, size_x) }, \
51         { "size_y", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_landing_target_t, size_y) }, \
52         { "target_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_landing_target_t, target_num) }, \
53         { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_landing_target_t, frame) }, \
54         } \
55}
56#endif
57
58/**
59 * @brief Pack a landing_target 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_usec Timestamp (micros since boot or Unix epoch)
65 * @param target_num The ID of the target if multiple targets are present
66 * @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
67 * @param angle_x X-axis angular offset (in radians) of the target from the center of the image
68 * @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
69 * @param distance Distance to the target from the vehicle in meters
70 * @param size_x Size in radians of target along x-axis
71 * @param size_y Size in radians of target along y-axis
72 * @return length of the message in bytes (excluding serial stream start sign)
73 */
74static inline uint16_t mavlink_msg_landing_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
75                                                       uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y)
76{
77#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
78        char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
79        _mav_put_uint64_t(buf, 0, time_usec);
80        _mav_put_float(buf, 8, angle_x);
81        _mav_put_float(buf, 12, angle_y);
82        _mav_put_float(buf, 16, distance);
83        _mav_put_float(buf, 20, size_x);
84        _mav_put_float(buf, 24, size_y);
85        _mav_put_uint8_t(buf, 28, target_num);
86        _mav_put_uint8_t(buf, 29, frame);
87
88        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
89#else
90        mavlink_landing_target_t packet;
91        packet.time_usec = time_usec;
92        packet.angle_x = angle_x;
93        packet.angle_y = angle_y;
94        packet.distance = distance;
95        packet.size_x = size_x;
96        packet.size_y = size_y;
97        packet.target_num = target_num;
98        packet.frame = frame;
99
100        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
101#endif
102
103        msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
104    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
105}
106
107/**
108 * @brief Pack a landing_target 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_usec Timestamp (micros since boot or Unix epoch)
114 * @param target_num The ID of the target if multiple targets are present
115 * @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
116 * @param angle_x X-axis angular offset (in radians) of the target from the center of the image
117 * @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
118 * @param distance Distance to the target from the vehicle in meters
119 * @param size_x Size in radians of target along x-axis
120 * @param size_y Size in radians of target along y-axis
121 * @return length of the message in bytes (excluding serial stream start sign)
122 */
123static inline uint16_t mavlink_msg_landing_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
124                                                           mavlink_message_t* msg,
125                                                           uint64_t time_usec,uint8_t target_num,uint8_t frame,float angle_x,float angle_y,float distance,float size_x,float size_y)
126{
127#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
128        char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
129        _mav_put_uint64_t(buf, 0, time_usec);
130        _mav_put_float(buf, 8, angle_x);
131        _mav_put_float(buf, 12, angle_y);
132        _mav_put_float(buf, 16, distance);
133        _mav_put_float(buf, 20, size_x);
134        _mav_put_float(buf, 24, size_y);
135        _mav_put_uint8_t(buf, 28, target_num);
136        _mav_put_uint8_t(buf, 29, frame);
137
138        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
139#else
140        mavlink_landing_target_t packet;
141        packet.time_usec = time_usec;
142        packet.angle_x = angle_x;
143        packet.angle_y = angle_y;
144        packet.distance = distance;
145        packet.size_x = size_x;
146        packet.size_y = size_y;
147        packet.target_num = target_num;
148        packet.frame = frame;
149
150        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
151#endif
152
153        msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
154    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
155}
156
157/**
158 * @brief Encode a landing_target 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 landing_target C-struct to read the message contents from
164 */
165static inline uint16_t mavlink_msg_landing_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
166{
167        return mavlink_msg_landing_target_pack(system_id, component_id, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y);
168}
169
170/**
171 * @brief Encode a landing_target 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 landing_target C-struct to read the message contents from
178 */
179static inline uint16_t mavlink_msg_landing_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
180{
181        return mavlink_msg_landing_target_pack_chan(system_id, component_id, chan, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y);
182}
183
184/**
185 * @brief Send a landing_target message
186 * @param chan MAVLink channel to send the message
187 *
188 * @param time_usec Timestamp (micros since boot or Unix epoch)
189 * @param target_num The ID of the target if multiple targets are present
190 * @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
191 * @param angle_x X-axis angular offset (in radians) of the target from the center of the image
192 * @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
193 * @param distance Distance to the target from the vehicle in meters
194 * @param size_x Size in radians of target along x-axis
195 * @param size_y Size in radians of target along y-axis
196 */
197#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
198
199static inline void mavlink_msg_landing_target_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y)
200{
201#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
202        char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
203        _mav_put_uint64_t(buf, 0, time_usec);
204        _mav_put_float(buf, 8, angle_x);
205        _mav_put_float(buf, 12, angle_y);
206        _mav_put_float(buf, 16, distance);
207        _mav_put_float(buf, 20, size_x);
208        _mav_put_float(buf, 24, size_y);
209        _mav_put_uint8_t(buf, 28, target_num);
210        _mav_put_uint8_t(buf, 29, frame);
211
212    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
213#else
214        mavlink_landing_target_t packet;
215        packet.time_usec = time_usec;
216        packet.angle_x = angle_x;
217        packet.angle_y = angle_y;
218        packet.distance = distance;
219        packet.size_x = size_x;
220        packet.size_y = size_y;
221        packet.target_num = target_num;
222        packet.frame = frame;
223
224    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)&packet, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
225#endif
226}
227
228/**
229 * @brief Send a landing_target message
230 * @param chan MAVLink channel to send the message
231 * @param struct The MAVLink struct to serialize
232 */
233static inline void mavlink_msg_landing_target_send_struct(mavlink_channel_t chan, const mavlink_landing_target_t* landing_target)
234{
235#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
236    mavlink_msg_landing_target_send(chan, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y);
237#else
238    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)landing_target, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
239#endif
240}
241
242#if MAVLINK_MSG_ID_LANDING_TARGET_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_landing_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y)
251{
252#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
253        char *buf = (char *)msgbuf;
254        _mav_put_uint64_t(buf, 0, time_usec);
255        _mav_put_float(buf, 8, angle_x);
256        _mav_put_float(buf, 12, angle_y);
257        _mav_put_float(buf, 16, distance);
258        _mav_put_float(buf, 20, size_x);
259        _mav_put_float(buf, 24, size_y);
260        _mav_put_uint8_t(buf, 28, target_num);
261        _mav_put_uint8_t(buf, 29, frame);
262
263    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
264#else
265        mavlink_landing_target_t *packet = (mavlink_landing_target_t *)msgbuf;
266        packet->time_usec = time_usec;
267        packet->angle_x = angle_x;
268        packet->angle_y = angle_y;
269        packet->distance = distance;
270        packet->size_x = size_x;
271        packet->size_y = size_y;
272        packet->target_num = target_num;
273        packet->frame = frame;
274
275    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)packet, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
276#endif
277}
278#endif
279
280#endif
281
282// MESSAGE LANDING_TARGET UNPACKING
283
284
285/**
286 * @brief Get field time_usec from landing_target message
287 *
288 * @return Timestamp (micros since boot or Unix epoch)
289 */
290static inline uint64_t mavlink_msg_landing_target_get_time_usec(const mavlink_message_t* msg)
291{
292        return _MAV_RETURN_uint64_t(msg,  0);
293}
294
295/**
296 * @brief Get field target_num from landing_target message
297 *
298 * @return The ID of the target if multiple targets are present
299 */
300static inline uint8_t mavlink_msg_landing_target_get_target_num(const mavlink_message_t* msg)
301{
302        return _MAV_RETURN_uint8_t(msg,  28);
303}
304
305/**
306 * @brief Get field frame from landing_target message
307 *
308 * @return MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
309 */
310static inline uint8_t mavlink_msg_landing_target_get_frame(const mavlink_message_t* msg)
311{
312        return _MAV_RETURN_uint8_t(msg,  29);
313}
314
315/**
316 * @brief Get field angle_x from landing_target message
317 *
318 * @return X-axis angular offset (in radians) of the target from the center of the image
319 */
320static inline float mavlink_msg_landing_target_get_angle_x(const mavlink_message_t* msg)
321{
322        return _MAV_RETURN_float(msg,  8);
323}
324
325/**
326 * @brief Get field angle_y from landing_target message
327 *
328 * @return Y-axis angular offset (in radians) of the target from the center of the image
329 */
330static inline float mavlink_msg_landing_target_get_angle_y(const mavlink_message_t* msg)
331{
332        return _MAV_RETURN_float(msg,  12);
333}
334
335/**
336 * @brief Get field distance from landing_target message
337 *
338 * @return Distance to the target from the vehicle in meters
339 */
340static inline float mavlink_msg_landing_target_get_distance(const mavlink_message_t* msg)
341{
342        return _MAV_RETURN_float(msg,  16);
343}
344
345/**
346 * @brief Get field size_x from landing_target message
347 *
348 * @return Size in radians of target along x-axis
349 */
350static inline float mavlink_msg_landing_target_get_size_x(const mavlink_message_t* msg)
351{
352        return _MAV_RETURN_float(msg,  20);
353}
354
355/**
356 * @brief Get field size_y from landing_target message
357 *
358 * @return Size in radians of target along y-axis
359 */
360static inline float mavlink_msg_landing_target_get_size_y(const mavlink_message_t* msg)
361{
362        return _MAV_RETURN_float(msg,  24);
363}
364
365/**
366 * @brief Decode a landing_target message into a struct
367 *
368 * @param msg The message to decode
369 * @param landing_target C-struct to decode the message contents into
370 */
371static inline void mavlink_msg_landing_target_decode(const mavlink_message_t* msg, mavlink_landing_target_t* landing_target)
372{
373#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
374        landing_target->time_usec = mavlink_msg_landing_target_get_time_usec(msg);
375        landing_target->angle_x = mavlink_msg_landing_target_get_angle_x(msg);
376        landing_target->angle_y = mavlink_msg_landing_target_get_angle_y(msg);
377        landing_target->distance = mavlink_msg_landing_target_get_distance(msg);
378        landing_target->size_x = mavlink_msg_landing_target_get_size_x(msg);
379        landing_target->size_y = mavlink_msg_landing_target_get_size_y(msg);
380        landing_target->target_num = mavlink_msg_landing_target_get_target_num(msg);
381        landing_target->frame = mavlink_msg_landing_target_get_frame(msg);
382#else
383        uint8_t len = msg->len < MAVLINK_MSG_ID_LANDING_TARGET_LEN? msg->len : MAVLINK_MSG_ID_LANDING_TARGET_LEN;
384        memset(landing_target, 0, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
385        memcpy(landing_target, _MAV_PAYLOAD(msg), len);
386#endif
387}
Note: See TracBrowser for help on using the repository browser.