Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_obstacle_distance.h
Go to the documentation of this file.
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; /*< [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 uint16_t distances[72]; /*< [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.*/
10 uint16_t min_distance; /*< [cm] Minimum distance the sensor can measure.*/
11 uint16_t max_distance; /*< [cm] Maximum distance the sensor can measure.*/
12 uint8_t sensor_type; /*< Class id of the distance sensor type.*/
13 uint8_t increment; /*< [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.*/
14 float increment_f; /*< [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.*/
15 float angle_offset; /*< [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.*/
16 uint8_t frame; /*< Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.*/
17}) mavlink_obstacle_distance_t;
18
19#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN 167
20#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN 158
21#define MAVLINK_MSG_ID_330_LEN 167
22#define MAVLINK_MSG_ID_330_MIN_LEN 158
23
24#define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC 23
25#define MAVLINK_MSG_ID_330_CRC 23
26
27#define MAVLINK_MSG_OBSTACLE_DISTANCE_FIELD_DISTANCES_LEN 72
28
29#if MAVLINK_COMMAND_24BIT
30#define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE {
31 330,
32 "OBSTACLE_DISTANCE",
33 9,
34 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_obstacle_distance_t, time_usec) },
35 { "sensor_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 156, offsetof(mavlink_obstacle_distance_t, sensor_type) },
36 { "distances", NULL, MAVLINK_TYPE_UINT16_T, 72, 8, offsetof(mavlink_obstacle_distance_t, distances) },
37 { "increment", NULL, MAVLINK_TYPE_UINT8_T, 0, 157, offsetof(mavlink_obstacle_distance_t, increment) },
38 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 152, offsetof(mavlink_obstacle_distance_t, min_distance) },
39 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 154, offsetof(mavlink_obstacle_distance_t, max_distance) },
40 { "increment_f", NULL, MAVLINK_TYPE_FLOAT, 0, 158, offsetof(mavlink_obstacle_distance_t, increment_f) },
41 { "angle_offset", NULL, MAVLINK_TYPE_FLOAT, 0, 162, offsetof(mavlink_obstacle_distance_t, angle_offset) },
42 { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 166, offsetof(mavlink_obstacle_distance_t, frame) },
43 } \
44}
45#else
46#define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE {
47 "OBSTACLE_DISTANCE",
48 9,
49 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_obstacle_distance_t, time_usec) },
50 { "sensor_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 156, offsetof(mavlink_obstacle_distance_t, sensor_type) },
51 { "distances", NULL, MAVLINK_TYPE_UINT16_T, 72, 8, offsetof(mavlink_obstacle_distance_t, distances) },
52 { "increment", NULL, MAVLINK_TYPE_UINT8_T, 0, 157, offsetof(mavlink_obstacle_distance_t, increment) },
53 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 152, offsetof(mavlink_obstacle_distance_t, min_distance) },
54 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 154, offsetof(mavlink_obstacle_distance_t, max_distance) },
55 { "increment_f", NULL, MAVLINK_TYPE_FLOAT, 0, 158, offsetof(mavlink_obstacle_distance_t, increment_f) },
56 { "angle_offset", NULL, MAVLINK_TYPE_FLOAT, 0, 162, offsetof(mavlink_obstacle_distance_t, angle_offset) },
57 { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 166, offsetof(mavlink_obstacle_distance_t, frame) },
58 } \
59}
60#endif
61
62/**
63 * @brief Pack a obstacle_distance message
64 * @param system_id ID of this system
65 * @param component_id ID of this component (e.g. 200 for IMU)
66 * @param msg The MAVLink message to compress the data into
67 *
68 * @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.
69 * @param sensor_type Class id of the distance sensor type.
70 * @param distances [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.
71 * @param increment [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
72 * @param min_distance [cm] Minimum distance the sensor can measure.
73 * @param max_distance [cm] Maximum distance the sensor can measure.
74 * @param increment_f [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.
75 * @param angle_offset [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.
76 * @param frame Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.
77 * @return length of the message in bytes (excluding serial stream start sign)
78 */
79static inline uint16_t mavlink_msg_obstacle_distance_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
80 uint64_t time_usec, uint8_t sensor_type, const uint16_t *distances, uint8_t increment, uint16_t min_distance, uint16_t max_distance, float increment_f, float angle_offset, uint8_t frame)
81{
82#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
84 _mav_put_uint64_t(buf, 0, time_usec);
85 _mav_put_uint16_t(buf, 152, min_distance);
86 _mav_put_uint16_t(buf, 154, max_distance);
87 _mav_put_uint8_t(buf, 156, sensor_type);
88 _mav_put_uint8_t(buf, 157, increment);
89 _mav_put_float(buf, 158, increment_f);
90 _mav_put_float(buf, 162, angle_offset);
91 _mav_put_uint8_t(buf, 166, frame);
92 _mav_put_uint16_t_array(buf, 8, distances, 72);
93 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
94#else
95 mavlink_obstacle_distance_t packet;
96 packet.time_usec = time_usec;
97 packet.min_distance = min_distance;
98 packet.max_distance = max_distance;
99 packet.sensor_type = sensor_type;
100 packet.increment = increment;
101 packet.increment_f = increment_f;
102 packet.angle_offset = angle_offset;
103 packet.frame = frame;
104 mav_array_memcpy(packet.distances, distances, sizeof(uint16_t)*72);
105 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
106#endif
107
110}
111
112/**
113 * @brief Pack a obstacle_distance message
114 * @param system_id ID of this system
115 * @param component_id ID of this component (e.g. 200 for IMU)
116 * @param status MAVLink status structure
117 * @param msg The MAVLink message to compress the data into
118 *
119 * @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.
120 * @param sensor_type Class id of the distance sensor type.
121 * @param distances [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.
122 * @param increment [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
123 * @param min_distance [cm] Minimum distance the sensor can measure.
124 * @param max_distance [cm] Maximum distance the sensor can measure.
125 * @param increment_f [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.
126 * @param angle_offset [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.
127 * @param frame Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.
128 * @return length of the message in bytes (excluding serial stream start sign)
129 */
130static inline uint16_t mavlink_msg_obstacle_distance_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
131 uint64_t time_usec, uint8_t sensor_type, const uint16_t *distances, uint8_t increment, uint16_t min_distance, uint16_t max_distance, float increment_f, float angle_offset, uint8_t frame)
132{
133#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
135 _mav_put_uint64_t(buf, 0, time_usec);
136 _mav_put_uint16_t(buf, 152, min_distance);
137 _mav_put_uint16_t(buf, 154, max_distance);
138 _mav_put_uint8_t(buf, 156, sensor_type);
139 _mav_put_uint8_t(buf, 157, increment);
140 _mav_put_float(buf, 158, increment_f);
141 _mav_put_float(buf, 162, angle_offset);
142 _mav_put_uint8_t(buf, 166, frame);
143 _mav_put_uint16_t_array(buf, 8, distances, 72);
144 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
145#else
146 mavlink_obstacle_distance_t packet;
147 packet.time_usec = time_usec;
148 packet.min_distance = min_distance;
149 packet.max_distance = max_distance;
150 packet.sensor_type = sensor_type;
151 packet.increment = increment;
152 packet.increment_f = increment_f;
153 packet.angle_offset = angle_offset;
154 packet.frame = frame;
155 mav_array_memcpy(packet.distances, distances, sizeof(uint16_t)*72);
156 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
157#endif
158
160#if MAVLINK_CRC_EXTRA
161 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC);
162#else
163 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_MIN_LEN, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
164#endif
165}
166
167/**
168 * @brief Pack a obstacle_distance message on a channel
169 * @param system_id ID of this system
170 * @param component_id ID of this component (e.g. 200 for IMU)
171 * @param chan The MAVLink channel this message will be sent over
172 * @param msg The MAVLink message to compress the data into
173 * @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.
174 * @param sensor_type Class id of the distance sensor type.
175 * @param distances [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.
176 * @param increment [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
177 * @param min_distance [cm] Minimum distance the sensor can measure.
178 * @param max_distance [cm] Maximum distance the sensor can measure.
179 * @param increment_f [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.
180 * @param angle_offset [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.
181 * @param frame Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.
182 * @return length of the message in bytes (excluding serial stream start sign)
183 */
184static inline uint16_t mavlink_msg_obstacle_distance_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
185 mavlink_message_t* msg,
186 uint64_t time_usec,uint8_t sensor_type,const uint16_t *distances,uint8_t increment,uint16_t min_distance,uint16_t max_distance,float increment_f,float angle_offset,uint8_t frame)
187{
188#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
190 _mav_put_uint64_t(buf, 0, time_usec);
191 _mav_put_uint16_t(buf, 152, min_distance);
192 _mav_put_uint16_t(buf, 154, max_distance);
193 _mav_put_uint8_t(buf, 156, sensor_type);
194 _mav_put_uint8_t(buf, 157, increment);
195 _mav_put_float(buf, 158, increment_f);
196 _mav_put_float(buf, 162, angle_offset);
197 _mav_put_uint8_t(buf, 166, frame);
198 _mav_put_uint16_t_array(buf, 8, distances, 72);
199 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
200#else
201 mavlink_obstacle_distance_t packet;
202 packet.time_usec = time_usec;
203 packet.min_distance = min_distance;
204 packet.max_distance = max_distance;
205 packet.sensor_type = sensor_type;
206 packet.increment = increment;
207 packet.increment_f = increment_f;
208 packet.angle_offset = angle_offset;
209 packet.frame = frame;
210 mav_array_memcpy(packet.distances, distances, sizeof(uint16_t)*72);
211 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
212#endif
213
215 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);
216}
217
218/**
219 * @brief Encode a obstacle_distance struct
220 *
221 * @param system_id ID of this system
222 * @param component_id ID of this component (e.g. 200 for IMU)
223 * @param msg The MAVLink message to compress the data into
224 * @param obstacle_distance C-struct to read the message contents from
225 */
226static 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)
227{
228 return mavlink_msg_obstacle_distance_pack(system_id, component_id, msg, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame);
229}
230
231/**
232 * @brief Encode a obstacle_distance struct on a channel
233 *
234 * @param system_id ID of this system
235 * @param component_id ID of this component (e.g. 200 for IMU)
236 * @param chan The MAVLink channel this message will be sent over
237 * @param msg The MAVLink message to compress the data into
238 * @param obstacle_distance C-struct to read the message contents from
239 */
240static 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)
241{
242 return mavlink_msg_obstacle_distance_pack_chan(system_id, component_id, chan, msg, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame);
243}
244
245/**
246 * @brief Encode a obstacle_distance struct with provided status structure
247 *
248 * @param system_id ID of this system
249 * @param component_id ID of this component (e.g. 200 for IMU)
250 * @param status MAVLink status structure
251 * @param msg The MAVLink message to compress the data into
252 * @param obstacle_distance C-struct to read the message contents from
253 */
254static inline uint16_t mavlink_msg_obstacle_distance_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_obstacle_distance_t* obstacle_distance)
255{
256 return mavlink_msg_obstacle_distance_pack_status(system_id, component_id, _status, msg, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame);
257}
258
259/**
260 * @brief Send a obstacle_distance message
261 * @param chan MAVLink channel to send the message
262 *
263 * @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.
264 * @param sensor_type Class id of the distance sensor type.
265 * @param distances [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.
266 * @param increment [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
267 * @param min_distance [cm] Minimum distance the sensor can measure.
268 * @param max_distance [cm] Maximum distance the sensor can measure.
269 * @param increment_f [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.
270 * @param angle_offset [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.
271 * @param frame Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.
272 */
273#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
274
275static inline void mavlink_msg_obstacle_distance_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_type, const uint16_t *distances, uint8_t increment, uint16_t min_distance, uint16_t max_distance, float increment_f, float angle_offset, uint8_t frame)
276{
277#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
278 char buf[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN];
279 _mav_put_uint64_t(buf, 0, time_usec);
280 _mav_put_uint16_t(buf, 152, min_distance);
281 _mav_put_uint16_t(buf, 154, max_distance);
282 _mav_put_uint8_t(buf, 156, sensor_type);
283 _mav_put_uint8_t(buf, 157, increment);
284 _mav_put_float(buf, 158, increment_f);
285 _mav_put_float(buf, 162, angle_offset);
286 _mav_put_uint8_t(buf, 166, frame);
287 _mav_put_uint16_t_array(buf, 8, distances, 72);
288 _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);
289#else
290 mavlink_obstacle_distance_t packet;
291 packet.time_usec = time_usec;
292 packet.min_distance = min_distance;
293 packet.max_distance = max_distance;
294 packet.sensor_type = sensor_type;
295 packet.increment = increment;
296 packet.increment_f = increment_f;
297 packet.angle_offset = angle_offset;
298 packet.frame = frame;
299 mav_array_memcpy(packet.distances, distances, sizeof(uint16_t)*72);
300 _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);
301#endif
302}
303
304/**
305 * @brief Send a obstacle_distance message
306 * @param chan MAVLink channel to send the message
307 * @param struct The MAVLink struct to serialize
308 */
309static inline void mavlink_msg_obstacle_distance_send_struct(mavlink_channel_t chan, const mavlink_obstacle_distance_t* obstacle_distance)
310{
311#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
312 mavlink_msg_obstacle_distance_send(chan, obstacle_distance->time_usec, obstacle_distance->sensor_type, obstacle_distance->distances, obstacle_distance->increment, obstacle_distance->min_distance, obstacle_distance->max_distance, obstacle_distance->increment_f, obstacle_distance->angle_offset, obstacle_distance->frame);
313#else
314 _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);
315#endif
316}
317
318#if MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
319/*
320 This variant of _send() can be used to save stack space by reusing
321 memory from the receive buffer. The caller provides a
322 mavlink_message_t which is the size of a full mavlink message. This
323 is usually the receive buffer for the channel, and allows a reply to an
324 incoming message with minimum stack space usage.
325 */
326static inline void mavlink_msg_obstacle_distance_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_type, const uint16_t *distances, uint8_t increment, uint16_t min_distance, uint16_t max_distance, float increment_f, float angle_offset, uint8_t frame)
327{
328#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
329 char *buf = (char *)msgbuf;
330 _mav_put_uint64_t(buf, 0, time_usec);
331 _mav_put_uint16_t(buf, 152, min_distance);
332 _mav_put_uint16_t(buf, 154, max_distance);
333 _mav_put_uint8_t(buf, 156, sensor_type);
334 _mav_put_uint8_t(buf, 157, increment);
335 _mav_put_float(buf, 158, increment_f);
336 _mav_put_float(buf, 162, angle_offset);
337 _mav_put_uint8_t(buf, 166, frame);
338 _mav_put_uint16_t_array(buf, 8, distances, 72);
339 _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);
340#else
341 mavlink_obstacle_distance_t *packet = (mavlink_obstacle_distance_t *)msgbuf;
342 packet->time_usec = time_usec;
343 packet->min_distance = min_distance;
344 packet->max_distance = max_distance;
345 packet->sensor_type = sensor_type;
346 packet->increment = increment;
347 packet->increment_f = increment_f;
348 packet->angle_offset = angle_offset;
349 packet->frame = frame;
350 mav_array_memcpy(packet->distances, distances, sizeof(uint16_t)*72);
351 _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);
352#endif
353}
354#endif
355
356#endif
357
358// MESSAGE OBSTACLE_DISTANCE UNPACKING
359
360
361/**
362 * @brief Get field time_usec from obstacle_distance message
363 *
364 * @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.
365 */
366static inline uint64_t mavlink_msg_obstacle_distance_get_time_usec(const mavlink_message_t* msg)
367{
368 return _MAV_RETURN_uint64_t(msg, 0);
369}
370
371/**
372 * @brief Get field sensor_type from obstacle_distance message
373 *
374 * @return Class id of the distance sensor type.
375 */
376static inline uint8_t mavlink_msg_obstacle_distance_get_sensor_type(const mavlink_message_t* msg)
377{
378 return _MAV_RETURN_uint8_t(msg, 156);
379}
380
381/**
382 * @brief Get field distances from obstacle_distance message
383 *
384 * @return [cm] Distance of obstacles around the vehicle with index 0 corresponding to north + angle_offset, unless otherwise specified in the frame. A value of 0 is valid and means that the obstacle is practically touching the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used. In a array element, one unit corresponds to 1cm.
385 */
386static inline uint16_t mavlink_msg_obstacle_distance_get_distances(const mavlink_message_t* msg, uint16_t *distances)
387{
388 return _MAV_RETURN_uint16_t_array(msg, distances, 72, 8);
389}
390
391/**
392 * @brief Get field increment from obstacle_distance message
393 *
394 * @return [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
395 */
396static inline uint8_t mavlink_msg_obstacle_distance_get_increment(const mavlink_message_t* msg)
397{
398 return _MAV_RETURN_uint8_t(msg, 157);
399}
400
401/**
402 * @brief Get field min_distance from obstacle_distance message
403 *
404 * @return [cm] Minimum distance the sensor can measure.
405 */
406static inline uint16_t mavlink_msg_obstacle_distance_get_min_distance(const mavlink_message_t* msg)
407{
408 return _MAV_RETURN_uint16_t(msg, 152);
409}
410
411/**
412 * @brief Get field max_distance from obstacle_distance message
413 *
414 * @return [cm] Maximum distance the sensor can measure.
415 */
416static inline uint16_t mavlink_msg_obstacle_distance_get_max_distance(const mavlink_message_t* msg)
417{
418 return _MAV_RETURN_uint16_t(msg, 154);
419}
420
421/**
422 * @brief Get field increment_f from obstacle_distance message
423 *
424 * @return [deg] Angular width in degrees of each array element as a float. If non-zero then this value is used instead of the uint8_t increment field. Positive is clockwise direction, negative is counter-clockwise.
425 */
426static inline float mavlink_msg_obstacle_distance_get_increment_f(const mavlink_message_t* msg)
427{
428 return _MAV_RETURN_float(msg, 158);
429}
430
431/**
432 * @brief Get field angle_offset from obstacle_distance message
433 *
434 * @return [deg] Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive is clockwise direction, negative is counter-clockwise.
435 */
436static inline float mavlink_msg_obstacle_distance_get_angle_offset(const mavlink_message_t* msg)
437{
438 return _MAV_RETURN_float(msg, 162);
439}
440
441/**
442 * @brief Get field frame from obstacle_distance message
443 *
444 * @return Coordinate frame of reference for the yaw rotation and offset of the sensor data. Defaults to MAV_FRAME_GLOBAL, which is north aligned. For body-mounted sensors use MAV_FRAME_BODY_FRD, which is vehicle front aligned.
445 */
446static inline uint8_t mavlink_msg_obstacle_distance_get_frame(const mavlink_message_t* msg)
447{
448 return _MAV_RETURN_uint8_t(msg, 166);
449}
450
451/**
452 * @brief Decode a obstacle_distance message into a struct
453 *
454 * @param msg The message to decode
455 * @param obstacle_distance C-struct to decode the message contents into
456 */
457static inline void mavlink_msg_obstacle_distance_decode(const mavlink_message_t* msg, mavlink_obstacle_distance_t* obstacle_distance)
458{
459#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
460 obstacle_distance->time_usec = mavlink_msg_obstacle_distance_get_time_usec(msg);
461 mavlink_msg_obstacle_distance_get_distances(msg, obstacle_distance->distances);
462 obstacle_distance->min_distance = mavlink_msg_obstacle_distance_get_min_distance(msg);
463 obstacle_distance->max_distance = mavlink_msg_obstacle_distance_get_max_distance(msg);
464 obstacle_distance->sensor_type = mavlink_msg_obstacle_distance_get_sensor_type(msg);
465 obstacle_distance->increment = mavlink_msg_obstacle_distance_get_increment(msg);
466 obstacle_distance->increment_f = mavlink_msg_obstacle_distance_get_increment_f(msg);
467 obstacle_distance->angle_offset = mavlink_msg_obstacle_distance_get_angle_offset(msg);
468 obstacle_distance->frame = mavlink_msg_obstacle_distance_get_frame(msg);
469#else
470 uint8_t len = msg->len < MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN? msg->len : MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN;
471 memset(obstacle_distance, 0, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN);
472 memcpy(obstacle_distance, _MAV_PAYLOAD(msg), len);
473#endif
474}