2 // MESSAGE OBSTACLE_DISTANCE PACKING
4 #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE 330
7 typedef 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
;
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
24 #define MAVLINK_MSG_ID_OBSTACLE_DISTANCE_CRC 23
25 #define MAVLINK_MSG_ID_330_CRC 23
27 #define MAVLINK_MSG_OBSTACLE_DISTANCE_FIELD_DISTANCES_LEN 72
29 #if MAVLINK_COMMAND_24BIT
30 #define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE { \
32 "OBSTACLE_DISTANCE", \
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) }, \
46 #define MAVLINK_MESSAGE_INFO_OBSTACLE_DISTANCE { \
47 "OBSTACLE_DISTANCE", \
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) }, \
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
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)
79 static 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
)
82 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
83 char buf
[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
];
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
);
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
);
108 msg
->msgid
= MAVLINK_MSG_ID_OBSTACLE_DISTANCE
;
109 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
);
113 * @brief Pack a obstacle_distance message on a channel
114 * @param system_id ID of this system
115 * @param component_id ID of this component (e.g. 200 for IMU)
116 * @param chan The MAVLink channel this message will be sent over
117 * @param msg The MAVLink message to compress the data into
118 * @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.
119 * @param sensor_type Class id of the distance sensor type.
120 * @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.
121 * @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.
122 * @param min_distance [cm] Minimum distance the sensor can measure.
123 * @param max_distance [cm] Maximum distance the sensor can measure.
124 * @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.
125 * @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.
126 * @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.
127 * @return length of the message in bytes (excluding serial stream start sign)
129 static inline uint16_t mavlink_msg_obstacle_distance_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
130 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
)
133 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
134 char buf
[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
];
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
);
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
);
159 msg
->msgid
= MAVLINK_MSG_ID_OBSTACLE_DISTANCE
;
160 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
);
164 * @brief Encode a obstacle_distance struct
166 * @param system_id ID of this system
167 * @param component_id ID of this component (e.g. 200 for IMU)
168 * @param msg The MAVLink message to compress the data into
169 * @param obstacle_distance C-struct to read the message contents from
171 static 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
)
173 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
);
177 * @brief Encode a obstacle_distance struct on a channel
179 * @param system_id ID of this system
180 * @param component_id ID of this component (e.g. 200 for IMU)
181 * @param chan The MAVLink channel this message will be sent over
182 * @param msg The MAVLink message to compress the data into
183 * @param obstacle_distance C-struct to read the message contents from
185 static 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
)
187 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
);
191 * @brief Send a obstacle_distance message
192 * @param chan MAVLink channel to send the message
194 * @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.
195 * @param sensor_type Class id of the distance sensor type.
196 * @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.
197 * @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.
198 * @param min_distance [cm] Minimum distance the sensor can measure.
199 * @param max_distance [cm] Maximum distance the sensor can measure.
200 * @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.
201 * @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.
202 * @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.
204 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
206 static 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
)
208 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
209 char buf
[MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
];
210 _mav_put_uint64_t(buf
, 0, time_usec
);
211 _mav_put_uint16_t(buf
, 152, min_distance
);
212 _mav_put_uint16_t(buf
, 154, max_distance
);
213 _mav_put_uint8_t(buf
, 156, sensor_type
);
214 _mav_put_uint8_t(buf
, 157, increment
);
215 _mav_put_float(buf
, 158, increment_f
);
216 _mav_put_float(buf
, 162, angle_offset
);
217 _mav_put_uint8_t(buf
, 166, frame
);
218 _mav_put_uint16_t_array(buf
, 8, distances
, 72);
219 _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
);
221 mavlink_obstacle_distance_t packet
;
222 packet
.time_usec
= time_usec
;
223 packet
.min_distance
= min_distance
;
224 packet
.max_distance
= max_distance
;
225 packet
.sensor_type
= sensor_type
;
226 packet
.increment
= increment
;
227 packet
.increment_f
= increment_f
;
228 packet
.angle_offset
= angle_offset
;
229 packet
.frame
= frame
;
230 mav_array_memcpy(packet
.distances
, distances
, sizeof(uint16_t)*72);
231 _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
);
236 * @brief Send a obstacle_distance message
237 * @param chan MAVLink channel to send the message
238 * @param struct The MAVLink struct to serialize
240 static inline void mavlink_msg_obstacle_distance_send_struct(mavlink_channel_t chan
, const mavlink_obstacle_distance_t
* obstacle_distance
)
242 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
243 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
);
245 _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
);
249 #if MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
251 This varient of _send() can be used to save stack space by re-using
252 memory from the receive buffer. The caller provides a
253 mavlink_message_t which is the size of a full mavlink message. This
254 is usually the receive buffer for the channel, and allows a reply to an
255 incoming message with minimum stack space usage.
257 static 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
)
259 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
260 char *buf
= (char *)msgbuf
;
261 _mav_put_uint64_t(buf
, 0, time_usec
);
262 _mav_put_uint16_t(buf
, 152, min_distance
);
263 _mav_put_uint16_t(buf
, 154, max_distance
);
264 _mav_put_uint8_t(buf
, 156, sensor_type
);
265 _mav_put_uint8_t(buf
, 157, increment
);
266 _mav_put_float(buf
, 158, increment_f
);
267 _mav_put_float(buf
, 162, angle_offset
);
268 _mav_put_uint8_t(buf
, 166, frame
);
269 _mav_put_uint16_t_array(buf
, 8, distances
, 72);
270 _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
);
272 mavlink_obstacle_distance_t
*packet
= (mavlink_obstacle_distance_t
*)msgbuf
;
273 packet
->time_usec
= time_usec
;
274 packet
->min_distance
= min_distance
;
275 packet
->max_distance
= max_distance
;
276 packet
->sensor_type
= sensor_type
;
277 packet
->increment
= increment
;
278 packet
->increment_f
= increment_f
;
279 packet
->angle_offset
= angle_offset
;
280 packet
->frame
= frame
;
281 mav_array_memcpy(packet
->distances
, distances
, sizeof(uint16_t)*72);
282 _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
);
289 // MESSAGE OBSTACLE_DISTANCE UNPACKING
293 * @brief Get field time_usec from obstacle_distance message
295 * @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.
297 static inline uint64_t mavlink_msg_obstacle_distance_get_time_usec(const mavlink_message_t
* msg
)
299 return _MAV_RETURN_uint64_t(msg
, 0);
303 * @brief Get field sensor_type from obstacle_distance message
305 * @return Class id of the distance sensor type.
307 static inline uint8_t mavlink_msg_obstacle_distance_get_sensor_type(const mavlink_message_t
* msg
)
309 return _MAV_RETURN_uint8_t(msg
, 156);
313 * @brief Get field distances from obstacle_distance message
315 * @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.
317 static inline uint16_t mavlink_msg_obstacle_distance_get_distances(const mavlink_message_t
* msg
, uint16_t *distances
)
319 return _MAV_RETURN_uint16_t_array(msg
, distances
, 72, 8);
323 * @brief Get field increment from obstacle_distance message
325 * @return [deg] Angular width in degrees of each array element. Increment direction is clockwise. This field is ignored if increment_f is non-zero.
327 static inline uint8_t mavlink_msg_obstacle_distance_get_increment(const mavlink_message_t
* msg
)
329 return _MAV_RETURN_uint8_t(msg
, 157);
333 * @brief Get field min_distance from obstacle_distance message
335 * @return [cm] Minimum distance the sensor can measure.
337 static inline uint16_t mavlink_msg_obstacle_distance_get_min_distance(const mavlink_message_t
* msg
)
339 return _MAV_RETURN_uint16_t(msg
, 152);
343 * @brief Get field max_distance from obstacle_distance message
345 * @return [cm] Maximum distance the sensor can measure.
347 static inline uint16_t mavlink_msg_obstacle_distance_get_max_distance(const mavlink_message_t
* msg
)
349 return _MAV_RETURN_uint16_t(msg
, 154);
353 * @brief Get field increment_f from obstacle_distance message
355 * @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.
357 static inline float mavlink_msg_obstacle_distance_get_increment_f(const mavlink_message_t
* msg
)
359 return _MAV_RETURN_float(msg
, 158);
363 * @brief Get field angle_offset from obstacle_distance message
365 * @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.
367 static inline float mavlink_msg_obstacle_distance_get_angle_offset(const mavlink_message_t
* msg
)
369 return _MAV_RETURN_float(msg
, 162);
373 * @brief Get field frame from obstacle_distance message
375 * @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.
377 static inline uint8_t mavlink_msg_obstacle_distance_get_frame(const mavlink_message_t
* msg
)
379 return _MAV_RETURN_uint8_t(msg
, 166);
383 * @brief Decode a obstacle_distance message into a struct
385 * @param msg The message to decode
386 * @param obstacle_distance C-struct to decode the message contents into
388 static inline void mavlink_msg_obstacle_distance_decode(const mavlink_message_t
* msg
, mavlink_obstacle_distance_t
* obstacle_distance
)
390 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
391 obstacle_distance
->time_usec
= mavlink_msg_obstacle_distance_get_time_usec(msg
);
392 mavlink_msg_obstacle_distance_get_distances(msg
, obstacle_distance
->distances
);
393 obstacle_distance
->min_distance
= mavlink_msg_obstacle_distance_get_min_distance(msg
);
394 obstacle_distance
->max_distance
= mavlink_msg_obstacle_distance_get_max_distance(msg
);
395 obstacle_distance
->sensor_type
= mavlink_msg_obstacle_distance_get_sensor_type(msg
);
396 obstacle_distance
->increment
= mavlink_msg_obstacle_distance_get_increment(msg
);
397 obstacle_distance
->increment_f
= mavlink_msg_obstacle_distance_get_increment_f(msg
);
398 obstacle_distance
->angle_offset
= mavlink_msg_obstacle_distance_get_angle_offset(msg
);
399 obstacle_distance
->frame
= mavlink_msg_obstacle_distance_get_frame(msg
);
401 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
? msg
->len
: MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
;
402 memset(obstacle_distance
, 0, MAVLINK_MSG_ID_OBSTACLE_DISTANCE_LEN
);
403 memcpy(obstacle_distance
, _MAV_PAYLOAD(msg
), len
);