Merge remote-tracking branch 'upstream/master' into abo_fw_alt_vel_control
[inav.git] / lib / main / MAVLink / common / mavlink_msg_distance_sensor.h
blob7e4e8504086113f9d0852c3a401aca3057de7cb8
1 #pragma once
2 // MESSAGE DISTANCE_SENSOR PACKING
4 #define MAVLINK_MSG_ID_DISTANCE_SENSOR 132
6 MAVPACKED(
7 typedef struct __mavlink_distance_sensor_t {
8 uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
9 uint16_t min_distance; /*< [cm] Minimum distance the sensor can measure*/
10 uint16_t max_distance; /*< [cm] Maximum distance the sensor can measure*/
11 uint16_t current_distance; /*< [cm] Current distance reading*/
12 uint8_t type; /*< Type of distance sensor.*/
13 uint8_t id; /*< Onboard ID of the sensor*/
14 uint8_t orientation; /*< Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270*/
15 uint8_t covariance; /*< [cm^2] Measurement variance. Max standard deviation is 6cm. 255 if unknown.*/
16 float horizontal_fov; /*< [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.*/
17 float vertical_fov; /*< [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.*/
18 float quaternion[4]; /*< Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid."*/
19 uint8_t signal_quality; /*< [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal.*/
20 }) mavlink_distance_sensor_t;
22 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN 39
23 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN 14
24 #define MAVLINK_MSG_ID_132_LEN 39
25 #define MAVLINK_MSG_ID_132_MIN_LEN 14
27 #define MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC 85
28 #define MAVLINK_MSG_ID_132_CRC 85
30 #define MAVLINK_MSG_DISTANCE_SENSOR_FIELD_QUATERNION_LEN 4
32 #if MAVLINK_COMMAND_24BIT
33 #define MAVLINK_MESSAGE_INFO_DISTANCE_SENSOR { \
34 132, \
35 "DISTANCE_SENSOR", \
36 12, \
37 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_distance_sensor_t, time_boot_ms) }, \
38 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_distance_sensor_t, min_distance) }, \
39 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_distance_sensor_t, max_distance) }, \
40 { "current_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_distance_sensor_t, current_distance) }, \
41 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_distance_sensor_t, type) }, \
42 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_distance_sensor_t, id) }, \
43 { "orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_distance_sensor_t, orientation) }, \
44 { "covariance", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_distance_sensor_t, covariance) }, \
45 { "horizontal_fov", NULL, MAVLINK_TYPE_FLOAT, 0, 14, offsetof(mavlink_distance_sensor_t, horizontal_fov) }, \
46 { "vertical_fov", NULL, MAVLINK_TYPE_FLOAT, 0, 18, offsetof(mavlink_distance_sensor_t, vertical_fov) }, \
47 { "quaternion", NULL, MAVLINK_TYPE_FLOAT, 4, 22, offsetof(mavlink_distance_sensor_t, quaternion) }, \
48 { "signal_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 38, offsetof(mavlink_distance_sensor_t, signal_quality) }, \
49 } \
51 #else
52 #define MAVLINK_MESSAGE_INFO_DISTANCE_SENSOR { \
53 "DISTANCE_SENSOR", \
54 12, \
55 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_distance_sensor_t, time_boot_ms) }, \
56 { "min_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_distance_sensor_t, min_distance) }, \
57 { "max_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_distance_sensor_t, max_distance) }, \
58 { "current_distance", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_distance_sensor_t, current_distance) }, \
59 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_distance_sensor_t, type) }, \
60 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 11, offsetof(mavlink_distance_sensor_t, id) }, \
61 { "orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_distance_sensor_t, orientation) }, \
62 { "covariance", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_distance_sensor_t, covariance) }, \
63 { "horizontal_fov", NULL, MAVLINK_TYPE_FLOAT, 0, 14, offsetof(mavlink_distance_sensor_t, horizontal_fov) }, \
64 { "vertical_fov", NULL, MAVLINK_TYPE_FLOAT, 0, 18, offsetof(mavlink_distance_sensor_t, vertical_fov) }, \
65 { "quaternion", NULL, MAVLINK_TYPE_FLOAT, 4, 22, offsetof(mavlink_distance_sensor_t, quaternion) }, \
66 { "signal_quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 38, offsetof(mavlink_distance_sensor_t, signal_quality) }, \
67 } \
69 #endif
71 /**
72 * @brief Pack a distance_sensor message
73 * @param system_id ID of this system
74 * @param component_id ID of this component (e.g. 200 for IMU)
75 * @param msg The MAVLink message to compress the data into
77 * @param time_boot_ms [ms] Timestamp (time since system boot).
78 * @param min_distance [cm] Minimum distance the sensor can measure
79 * @param max_distance [cm] Maximum distance the sensor can measure
80 * @param current_distance [cm] Current distance reading
81 * @param type Type of distance sensor.
82 * @param id Onboard ID of the sensor
83 * @param orientation Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270
84 * @param covariance [cm^2] Measurement variance. Max standard deviation is 6cm. 255 if unknown.
85 * @param horizontal_fov [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
86 * @param vertical_fov [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
87 * @param quaternion Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid."
88 * @param signal_quality [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal.
89 * @return length of the message in bytes (excluding serial stream start sign)
91 static inline uint16_t mavlink_msg_distance_sensor_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
92 uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance, float horizontal_fov, float vertical_fov, const float *quaternion, uint8_t signal_quality)
94 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
95 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
96 _mav_put_uint32_t(buf, 0, time_boot_ms);
97 _mav_put_uint16_t(buf, 4, min_distance);
98 _mav_put_uint16_t(buf, 6, max_distance);
99 _mav_put_uint16_t(buf, 8, current_distance);
100 _mav_put_uint8_t(buf, 10, type);
101 _mav_put_uint8_t(buf, 11, id);
102 _mav_put_uint8_t(buf, 12, orientation);
103 _mav_put_uint8_t(buf, 13, covariance);
104 _mav_put_float(buf, 14, horizontal_fov);
105 _mav_put_float(buf, 18, vertical_fov);
106 _mav_put_uint8_t(buf, 38, signal_quality);
107 _mav_put_float_array(buf, 22, quaternion, 4);
108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
109 #else
110 mavlink_distance_sensor_t packet;
111 packet.time_boot_ms = time_boot_ms;
112 packet.min_distance = min_distance;
113 packet.max_distance = max_distance;
114 packet.current_distance = current_distance;
115 packet.type = type;
116 packet.id = id;
117 packet.orientation = orientation;
118 packet.covariance = covariance;
119 packet.horizontal_fov = horizontal_fov;
120 packet.vertical_fov = vertical_fov;
121 packet.signal_quality = signal_quality;
122 mav_array_memcpy(packet.quaternion, quaternion, sizeof(float)*4);
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
124 #endif
126 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
127 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
131 * @brief Pack a distance_sensor message on a channel
132 * @param system_id ID of this system
133 * @param component_id ID of this component (e.g. 200 for IMU)
134 * @param chan The MAVLink channel this message will be sent over
135 * @param msg The MAVLink message to compress the data into
136 * @param time_boot_ms [ms] Timestamp (time since system boot).
137 * @param min_distance [cm] Minimum distance the sensor can measure
138 * @param max_distance [cm] Maximum distance the sensor can measure
139 * @param current_distance [cm] Current distance reading
140 * @param type Type of distance sensor.
141 * @param id Onboard ID of the sensor
142 * @param orientation Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270
143 * @param covariance [cm^2] Measurement variance. Max standard deviation is 6cm. 255 if unknown.
144 * @param horizontal_fov [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
145 * @param vertical_fov [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
146 * @param quaternion Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid."
147 * @param signal_quality [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal.
148 * @return length of the message in bytes (excluding serial stream start sign)
150 static inline uint16_t mavlink_msg_distance_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
151 mavlink_message_t* msg,
152 uint32_t time_boot_ms,uint16_t min_distance,uint16_t max_distance,uint16_t current_distance,uint8_t type,uint8_t id,uint8_t orientation,uint8_t covariance,float horizontal_fov,float vertical_fov,const float *quaternion,uint8_t signal_quality)
154 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
155 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
156 _mav_put_uint32_t(buf, 0, time_boot_ms);
157 _mav_put_uint16_t(buf, 4, min_distance);
158 _mav_put_uint16_t(buf, 6, max_distance);
159 _mav_put_uint16_t(buf, 8, current_distance);
160 _mav_put_uint8_t(buf, 10, type);
161 _mav_put_uint8_t(buf, 11, id);
162 _mav_put_uint8_t(buf, 12, orientation);
163 _mav_put_uint8_t(buf, 13, covariance);
164 _mav_put_float(buf, 14, horizontal_fov);
165 _mav_put_float(buf, 18, vertical_fov);
166 _mav_put_uint8_t(buf, 38, signal_quality);
167 _mav_put_float_array(buf, 22, quaternion, 4);
168 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
169 #else
170 mavlink_distance_sensor_t packet;
171 packet.time_boot_ms = time_boot_ms;
172 packet.min_distance = min_distance;
173 packet.max_distance = max_distance;
174 packet.current_distance = current_distance;
175 packet.type = type;
176 packet.id = id;
177 packet.orientation = orientation;
178 packet.covariance = covariance;
179 packet.horizontal_fov = horizontal_fov;
180 packet.vertical_fov = vertical_fov;
181 packet.signal_quality = signal_quality;
182 mav_array_memcpy(packet.quaternion, quaternion, sizeof(float)*4);
183 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
184 #endif
186 msg->msgid = MAVLINK_MSG_ID_DISTANCE_SENSOR;
187 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
191 * @brief Encode a distance_sensor struct
193 * @param system_id ID of this system
194 * @param component_id ID of this component (e.g. 200 for IMU)
195 * @param msg The MAVLink message to compress the data into
196 * @param distance_sensor C-struct to read the message contents from
198 static inline uint16_t mavlink_msg_distance_sensor_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_distance_sensor_t* distance_sensor)
200 return mavlink_msg_distance_sensor_pack(system_id, component_id, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance, distance_sensor->horizontal_fov, distance_sensor->vertical_fov, distance_sensor->quaternion, distance_sensor->signal_quality);
204 * @brief Encode a distance_sensor struct on a channel
206 * @param system_id ID of this system
207 * @param component_id ID of this component (e.g. 200 for IMU)
208 * @param chan The MAVLink channel this message will be sent over
209 * @param msg The MAVLink message to compress the data into
210 * @param distance_sensor C-struct to read the message contents from
212 static inline uint16_t mavlink_msg_distance_sensor_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_distance_sensor_t* distance_sensor)
214 return mavlink_msg_distance_sensor_pack_chan(system_id, component_id, chan, msg, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance, distance_sensor->horizontal_fov, distance_sensor->vertical_fov, distance_sensor->quaternion, distance_sensor->signal_quality);
218 * @brief Send a distance_sensor message
219 * @param chan MAVLink channel to send the message
221 * @param time_boot_ms [ms] Timestamp (time since system boot).
222 * @param min_distance [cm] Minimum distance the sensor can measure
223 * @param max_distance [cm] Maximum distance the sensor can measure
224 * @param current_distance [cm] Current distance reading
225 * @param type Type of distance sensor.
226 * @param id Onboard ID of the sensor
227 * @param orientation Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270
228 * @param covariance [cm^2] Measurement variance. Max standard deviation is 6cm. 255 if unknown.
229 * @param horizontal_fov [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
230 * @param vertical_fov [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
231 * @param quaternion Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid."
232 * @param signal_quality [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal.
234 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
236 static inline void mavlink_msg_distance_sensor_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance, float horizontal_fov, float vertical_fov, const float *quaternion, uint8_t signal_quality)
238 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
239 char buf[MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN];
240 _mav_put_uint32_t(buf, 0, time_boot_ms);
241 _mav_put_uint16_t(buf, 4, min_distance);
242 _mav_put_uint16_t(buf, 6, max_distance);
243 _mav_put_uint16_t(buf, 8, current_distance);
244 _mav_put_uint8_t(buf, 10, type);
245 _mav_put_uint8_t(buf, 11, id);
246 _mav_put_uint8_t(buf, 12, orientation);
247 _mav_put_uint8_t(buf, 13, covariance);
248 _mav_put_float(buf, 14, horizontal_fov);
249 _mav_put_float(buf, 18, vertical_fov);
250 _mav_put_uint8_t(buf, 38, signal_quality);
251 _mav_put_float_array(buf, 22, quaternion, 4);
252 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
253 #else
254 mavlink_distance_sensor_t packet;
255 packet.time_boot_ms = time_boot_ms;
256 packet.min_distance = min_distance;
257 packet.max_distance = max_distance;
258 packet.current_distance = current_distance;
259 packet.type = type;
260 packet.id = id;
261 packet.orientation = orientation;
262 packet.covariance = covariance;
263 packet.horizontal_fov = horizontal_fov;
264 packet.vertical_fov = vertical_fov;
265 packet.signal_quality = signal_quality;
266 mav_array_memcpy(packet.quaternion, quaternion, sizeof(float)*4);
267 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)&packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
268 #endif
272 * @brief Send a distance_sensor message
273 * @param chan MAVLink channel to send the message
274 * @param struct The MAVLink struct to serialize
276 static inline void mavlink_msg_distance_sensor_send_struct(mavlink_channel_t chan, const mavlink_distance_sensor_t* distance_sensor)
278 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
279 mavlink_msg_distance_sensor_send(chan, distance_sensor->time_boot_ms, distance_sensor->min_distance, distance_sensor->max_distance, distance_sensor->current_distance, distance_sensor->type, distance_sensor->id, distance_sensor->orientation, distance_sensor->covariance, distance_sensor->horizontal_fov, distance_sensor->vertical_fov, distance_sensor->quaternion, distance_sensor->signal_quality);
280 #else
281 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)distance_sensor, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
282 #endif
285 #if MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
287 This varient of _send() can be used to save stack space by re-using
288 memory from the receive buffer. The caller provides a
289 mavlink_message_t which is the size of a full mavlink message. This
290 is usually the receive buffer for the channel, and allows a reply to an
291 incoming message with minimum stack space usage.
293 static inline void mavlink_msg_distance_sensor_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint16_t min_distance, uint16_t max_distance, uint16_t current_distance, uint8_t type, uint8_t id, uint8_t orientation, uint8_t covariance, float horizontal_fov, float vertical_fov, const float *quaternion, uint8_t signal_quality)
295 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
296 char *buf = (char *)msgbuf;
297 _mav_put_uint32_t(buf, 0, time_boot_ms);
298 _mav_put_uint16_t(buf, 4, min_distance);
299 _mav_put_uint16_t(buf, 6, max_distance);
300 _mav_put_uint16_t(buf, 8, current_distance);
301 _mav_put_uint8_t(buf, 10, type);
302 _mav_put_uint8_t(buf, 11, id);
303 _mav_put_uint8_t(buf, 12, orientation);
304 _mav_put_uint8_t(buf, 13, covariance);
305 _mav_put_float(buf, 14, horizontal_fov);
306 _mav_put_float(buf, 18, vertical_fov);
307 _mav_put_uint8_t(buf, 38, signal_quality);
308 _mav_put_float_array(buf, 22, quaternion, 4);
309 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, buf, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
310 #else
311 mavlink_distance_sensor_t *packet = (mavlink_distance_sensor_t *)msgbuf;
312 packet->time_boot_ms = time_boot_ms;
313 packet->min_distance = min_distance;
314 packet->max_distance = max_distance;
315 packet->current_distance = current_distance;
316 packet->type = type;
317 packet->id = id;
318 packet->orientation = orientation;
319 packet->covariance = covariance;
320 packet->horizontal_fov = horizontal_fov;
321 packet->vertical_fov = vertical_fov;
322 packet->signal_quality = signal_quality;
323 mav_array_memcpy(packet->quaternion, quaternion, sizeof(float)*4);
324 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DISTANCE_SENSOR, (const char *)packet, MAVLINK_MSG_ID_DISTANCE_SENSOR_MIN_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN, MAVLINK_MSG_ID_DISTANCE_SENSOR_CRC);
325 #endif
327 #endif
329 #endif
331 // MESSAGE DISTANCE_SENSOR UNPACKING
335 * @brief Get field time_boot_ms from distance_sensor message
337 * @return [ms] Timestamp (time since system boot).
339 static inline uint32_t mavlink_msg_distance_sensor_get_time_boot_ms(const mavlink_message_t* msg)
341 return _MAV_RETURN_uint32_t(msg, 0);
345 * @brief Get field min_distance from distance_sensor message
347 * @return [cm] Minimum distance the sensor can measure
349 static inline uint16_t mavlink_msg_distance_sensor_get_min_distance(const mavlink_message_t* msg)
351 return _MAV_RETURN_uint16_t(msg, 4);
355 * @brief Get field max_distance from distance_sensor message
357 * @return [cm] Maximum distance the sensor can measure
359 static inline uint16_t mavlink_msg_distance_sensor_get_max_distance(const mavlink_message_t* msg)
361 return _MAV_RETURN_uint16_t(msg, 6);
365 * @brief Get field current_distance from distance_sensor message
367 * @return [cm] Current distance reading
369 static inline uint16_t mavlink_msg_distance_sensor_get_current_distance(const mavlink_message_t* msg)
371 return _MAV_RETURN_uint16_t(msg, 8);
375 * @brief Get field type from distance_sensor message
377 * @return Type of distance sensor.
379 static inline uint8_t mavlink_msg_distance_sensor_get_type(const mavlink_message_t* msg)
381 return _MAV_RETURN_uint8_t(msg, 10);
385 * @brief Get field id from distance_sensor message
387 * @return Onboard ID of the sensor
389 static inline uint8_t mavlink_msg_distance_sensor_get_id(const mavlink_message_t* msg)
391 return _MAV_RETURN_uint8_t(msg, 11);
395 * @brief Get field orientation from distance_sensor message
397 * @return Direction the sensor faces. downward-facing: ROTATION_PITCH_270, upward-facing: ROTATION_PITCH_90, backward-facing: ROTATION_PITCH_180, forward-facing: ROTATION_NONE, left-facing: ROTATION_YAW_90, right-facing: ROTATION_YAW_270
399 static inline uint8_t mavlink_msg_distance_sensor_get_orientation(const mavlink_message_t* msg)
401 return _MAV_RETURN_uint8_t(msg, 12);
405 * @brief Get field covariance from distance_sensor message
407 * @return [cm^2] Measurement variance. Max standard deviation is 6cm. 255 if unknown.
409 static inline uint8_t mavlink_msg_distance_sensor_get_covariance(const mavlink_message_t* msg)
411 return _MAV_RETURN_uint8_t(msg, 13);
415 * @brief Get field horizontal_fov from distance_sensor message
417 * @return [rad] Horizontal Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
419 static inline float mavlink_msg_distance_sensor_get_horizontal_fov(const mavlink_message_t* msg)
421 return _MAV_RETURN_float(msg, 14);
425 * @brief Get field vertical_fov from distance_sensor message
427 * @return [rad] Vertical Field of View (angle) where the distance measurement is valid and the field of view is known. Otherwise this is set to 0.
429 static inline float mavlink_msg_distance_sensor_get_vertical_fov(const mavlink_message_t* msg)
431 return _MAV_RETURN_float(msg, 18);
435 * @brief Get field quaternion from distance_sensor message
437 * @return Quaternion of the sensor orientation in vehicle body frame (w, x, y, z order, zero-rotation is 1, 0, 0, 0). Zero-rotation is along the vehicle body x-axis. This field is required if the orientation is set to MAV_SENSOR_ROTATION_CUSTOM. Set it to 0 if invalid."
439 static inline uint16_t mavlink_msg_distance_sensor_get_quaternion(const mavlink_message_t* msg, float *quaternion)
441 return _MAV_RETURN_float_array(msg, quaternion, 4, 22);
445 * @brief Get field signal_quality from distance_sensor message
447 * @return [%] Signal quality of the sensor. Specific to each sensor type, representing the relation of the signal strength with the target reflectivity, distance, size or aspect, but normalised as a percentage. 0 = unknown/unset signal quality, 1 = invalid signal, 100 = perfect signal.
449 static inline uint8_t mavlink_msg_distance_sensor_get_signal_quality(const mavlink_message_t* msg)
451 return _MAV_RETURN_uint8_t(msg, 38);
455 * @brief Decode a distance_sensor message into a struct
457 * @param msg The message to decode
458 * @param distance_sensor C-struct to decode the message contents into
460 static inline void mavlink_msg_distance_sensor_decode(const mavlink_message_t* msg, mavlink_distance_sensor_t* distance_sensor)
462 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
463 distance_sensor->time_boot_ms = mavlink_msg_distance_sensor_get_time_boot_ms(msg);
464 distance_sensor->min_distance = mavlink_msg_distance_sensor_get_min_distance(msg);
465 distance_sensor->max_distance = mavlink_msg_distance_sensor_get_max_distance(msg);
466 distance_sensor->current_distance = mavlink_msg_distance_sensor_get_current_distance(msg);
467 distance_sensor->type = mavlink_msg_distance_sensor_get_type(msg);
468 distance_sensor->id = mavlink_msg_distance_sensor_get_id(msg);
469 distance_sensor->orientation = mavlink_msg_distance_sensor_get_orientation(msg);
470 distance_sensor->covariance = mavlink_msg_distance_sensor_get_covariance(msg);
471 distance_sensor->horizontal_fov = mavlink_msg_distance_sensor_get_horizontal_fov(msg);
472 distance_sensor->vertical_fov = mavlink_msg_distance_sensor_get_vertical_fov(msg);
473 mavlink_msg_distance_sensor_get_quaternion(msg, distance_sensor->quaternion);
474 distance_sensor->signal_quality = mavlink_msg_distance_sensor_get_signal_quality(msg);
475 #else
476 uint8_t len = msg->len < MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN? msg->len : MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN;
477 memset(distance_sensor, 0, MAVLINK_MSG_ID_DISTANCE_SENSOR_LEN);
478 memcpy(distance_sensor, _MAV_PAYLOAD(msg), len);
479 #endif