RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_obstacle_distance.h
1#pragma once
2// MESSAGE OBSTACLE_DISTANCE PACKING
3
4#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE 330
5
6MAVPACKED(
7typedef struct __mavlink_obstacle_distance_t {
8 uint64_t time_usec; /*< Timestamp (microseconds since system boot or since UNIX epoch)*/
9 uint8_t estimator_type; /*< Class id of the distance sensor type.*/
10 uint8_t distances[12]; /*< Distance of obstacles in front of the sensor starting on the left side. A value of 0 means no obstacle. In a array element, each unit corresponds to 1m.*/
11 uint8_t increment; /*< Angular width in degrees of each array element.*/
12}) mavlink_obstacle_distance_t;
13
14#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN 22
15#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN 22
16#define MAVLINK_MSG_ID_330_LEN 22
17#define MAVLINK_MSG_ID_330_MIN_LEN 22
18
19#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC 201
20#define MAVLINK_MSG_ID_330_CRC 201
21
22#define MAVLINK_MSG_OBSTACLE_DISTANCE_FIELD_DISTANCES_LEN 12
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE { \
26 330, \
27 "OBSTACLE_DISTANCE", \
28 4, \
29 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_obstacle_distance_t, time_usec) }, \
30 { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_obstacle_distance_t, estimator_type) }, \
31 { "distances", NULL, MAVLINK_TYPE_UINT8_T, 12, 9, offsetof(mavlink_obstacle_distance_t, distances) }, \
32 { "increment", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_obstacle_distance_t, increment) }, \
33 } \
34}
35#else
36#define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE { \
37 "OBSTACLE_DISTANCE", \
38 4, \
39 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_obstacle_distance_t, time_usec) }, \
40 { "estimator_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_obstacle_distance_t, estimator_type) }, \
41 { "distances", NULL, MAVLINK_TYPE_UINT8_T, 12, 9, offsetof(mavlink_obstacle_distance_t, distances) }, \
42 { "increment", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_obstacle_distance_t, increment) }, \
43 } \
44}
45#endif
46
59static inline uint16_t mavlink_msg_obstacle_distance_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint64_t time_usec, uint8_t estimator_type, const uint8_t *distances, uint8_t increment)
61{
62#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN];
64 _mav_put_uint64_t(buf, 0, time_usec);
65 _mav_put_uint8_t(buf, 8, estimator_type);
66 _mav_put_uint8_t(buf, 21, increment);
67 _mav_put_uint8_t_array(buf, 9, distances, 12);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
69#else
70 mavlink_obstacle_distance_t packet;
71 packet.time_usec = time_usec;
72 packet.estimator_type = estimator_type;
73 packet.increment = increment;
74 mav_array_memcpy(packet.distances, distances, sizeof(uint8_t)*12);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
76#endif
77
78 msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE;
79 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
80}
81
94static inline uint16_t mavlink_msg_obstacle_distance_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
95 mavlink_message_t* msg,
96 uint64_t time_usec,uint8_t estimator_type,const uint8_t *distances,uint8_t increment)
97{
98#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN];
100 _mav_put_uint64_t(buf, 0, time_usec);
101 _mav_put_uint8_t(buf, 8, estimator_type);
102 _mav_put_uint8_t(buf, 21, increment);
103 _mav_put_uint8_t_array(buf, 9, distances, 12);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
105#else
106 mavlink_obstacle_distance_t packet;
107 packet.time_usec = time_usec;
108 packet.estimator_type = estimator_type;
109 packet.increment = increment;
110 mav_array_memcpy(packet.distances, distances, sizeof(uint8_t)*12);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
112#endif
113
114 msg->msgid = MAVLINK_MSG_ID_OBSTACLE_DISTANCE;
115 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
116}
117
126static inline uint16_t mavlink_msg_obstacle_distance_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_obstacle_distance_t* obstacle_distance)
127{
128 return mavlink_msg_obstacle_distance_pack(system_id, component_id, msg, obstacle_distance->time_usec, obstacle_distance->estimator_type, obstacle_distance->distances, obstacle_distance->increment);
129}
130
140static inline uint16_t mavlink_msg_obstacle_distance_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_obstacle_distance_t* obstacle_distance)
141{
142 return mavlink_msg_obstacle_distance_pack_chan(system_id, component_id, chan, msg, obstacle_distance->time_usec, obstacle_distance->estimator_type, obstacle_distance->distances, obstacle_distance->increment);
143}
144
154#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
155
156static inline void mavlink_msg_obstacle_distance_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t estimator_type, const uint8_t *distances, uint8_t increment)
157{
158#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN];
160 _mav_put_uint64_t(buf, 0, time_usec);
161 _mav_put_uint8_t(buf, 8, estimator_type);
162 _mav_put_uint8_t(buf, 21, increment);
163 _mav_put_uint8_t_array(buf, 9, distances, 12);
164 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE, buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
165#else
166 mavlink_obstacle_distance_t packet;
167 packet.time_usec = time_usec;
168 packet.estimator_type = estimator_type;
169 packet.increment = increment;
170 mav_array_memcpy(packet.distances, distances, sizeof(uint8_t)*12);
171 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE, (const char *)&packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
172#endif
173}
174
180static inline void mavlink_msg_obstacle_distance_send_struct(mavlink_channel_t chan, const mavlink_obstacle_distance_t* obstacle_distance)
181{
182#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 mavlink_msg_obstacle_distance_send(chan, obstacle_distance->time_usec, obstacle_distance->estimator_type, obstacle_distance->distances, obstacle_distance->increment);
184#else
185 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE, (const char *)obstacle_distance, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
186#endif
187}
188
189#if MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
190/*
191 This varient of _send() can be used to save stack space by re-using
192 memory from the receive buffer. The caller provides a
193 mavlink_message_t which is the size of a full mavlink message. This
194 is usually the receive buffer for the channel, and allows a reply to an
195 incoming message with minimum stack space usage.
196 */
197static inline void mavlink_msg_obstacle_distance_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t estimator_type, const uint8_t *distances, uint8_t increment)
198{
199#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char *buf = (char *)msgbuf;
201 _mav_put_uint64_t(buf, 0, time_usec);
202 _mav_put_uint8_t(buf, 8, estimator_type);
203 _mav_put_uint8_t(buf, 21, increment);
204 _mav_put_uint8_t_array(buf, 9, distances, 12);
205 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE, buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
206#else
207 mavlink_obstacle_distance_t *packet = (mavlink_obstacle_distance_t *)msgbuf;
208 packet->time_usec = time_usec;
209 packet->estimator_type = estimator_type;
210 packet->increment = increment;
211 mav_array_memcpy(packet->distances, distances, sizeof(uint8_t)*12);
212 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBSTACLE_DISTANCE, (const char *)packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
213#endif
214}
215#endif
216
217#endif
218
219// MESSAGE OBSTACLE_DISTANCE UNPACKING
220
221
227static inline uint64_t mavlink_msg_obstacle_distance_get_time_usec(const mavlink_message_t* msg)
228{
229 return _MAV_RETURN_uint64_t(msg, 0);
230}
231
237static inline uint8_t mavlink_msg_obstacle_distance_get_estimator_type(const mavlink_message_t* msg)
238{
239 return _MAV_RETURN_uint8_t(msg, 8);
240}
241
247static inline uint16_t mavlink_msg_obstacle_distance_get_distances(const mavlink_message_t* msg, uint8_t *distances)
248{
249 return _MAV_RETURN_uint8_t_array(msg, distances, 12, 9);
250}
251
257static inline uint8_t mavlink_msg_obstacle_distance_get_increment(const mavlink_message_t* msg)
258{
259 return _MAV_RETURN_uint8_t(msg, 21);
260}
261
268static inline void mavlink_msg_obstacle_distance_decode(const mavlink_message_t* msg, mavlink_obstacle_distance_t* obstacle_distance)
269{
270#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
271 obstacle_distance->time_usec = mavlink_msg_obstacle_distance_get_time_usec(msg);
272 obstacle_distance->estimator_type = mavlink_msg_obstacle_distance_get_estimator_type(msg);
273 mavlink_msg_obstacle_distance_get_distances(msg, obstacle_distance->distances);
274 obstacle_distance->increment = mavlink_msg_obstacle_distance_get_increment(msg);
275#else
276 uint8_t len = msg->len < MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN? msg->len : MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN;
277 memset(obstacle_distance, 0, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
278 memcpy(obstacle_distance, _MAV_PAYLOAD(msg), len);
279#endif
280}