Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_optical_flow.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE OPTICAL_FLOW PACKING
3
4#define MAVLINK_MSG_ID_OPTICAL_FLOW 100
5
6MAVPACKED(
7typedef struct __mavlink_optical_flow_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 float flow_comp_m_x; /*< [m/s] Flow in x-sensor direction, angular-speed compensated*/
10 float flow_comp_m_y; /*< [m/s] Flow in y-sensor direction, angular-speed compensated*/
11 float ground_distance; /*< [m] Ground distance. Positive value: distance known. Negative value: Unknown distance*/
12 int16_t flow_x; /*< [dpix] Flow in x-sensor direction*/
13 int16_t flow_y; /*< [dpix] Flow in y-sensor direction*/
14 uint8_t sensor_id; /*< Sensor ID*/
15 uint8_t quality; /*< Optical flow quality / confidence. 0: bad, 255: maximum quality*/
16 float flow_rate_x; /*< [rad/s] Flow rate about X axis*/
17 float flow_rate_y; /*< [rad/s] Flow rate about Y axis*/
18}) mavlink_optical_flow_t;
19
20#define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 34
21#define MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN 26
22#define MAVLINK_MSG_ID_100_LEN 34
23#define MAVLINK_MSG_ID_100_MIN_LEN 26
24
25#define MAVLINK_MSG_ID_OPTICAL_FLOW_CRC 175
26#define MAVLINK_MSG_ID_100_CRC 175
27
28
29
30#if MAVLINK_COMMAND_24BIT
31#define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW {
32 100,
33 "OPTICAL_FLOW",
34 10,
35 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) },
36 { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) },
37 { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) },
38 { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) },
39 { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) },
40 { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) },
41 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) },
42 { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) },
43 { "flow_rate_x", NULL, MAVLINK_TYPE_FLOAT, 0, 26, offsetof(mavlink_optical_flow_t, flow_rate_x) },
44 { "flow_rate_y", NULL, MAVLINK_TYPE_FLOAT, 0, 30, offsetof(mavlink_optical_flow_t, flow_rate_y) },
45 } \
46}
47#else
48#define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW {
49 "OPTICAL_FLOW",
50 10,
51 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) },
52 { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) },
53 { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) },
54 { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) },
55 { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) },
56 { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) },
57 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) },
58 { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) },
59 { "flow_rate_x", NULL, MAVLINK_TYPE_FLOAT, 0, 26, offsetof(mavlink_optical_flow_t, flow_rate_x) },
60 { "flow_rate_y", NULL, MAVLINK_TYPE_FLOAT, 0, 30, offsetof(mavlink_optical_flow_t, flow_rate_y) },
61 } \
62}
63#endif
64
65/**
66 * @brief Pack a optical_flow message
67 * @param system_id ID of this system
68 * @param component_id ID of this component (e.g. 200 for IMU)
69 * @param msg The MAVLink message to compress the data into
70 *
71 * @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.
72 * @param sensor_id Sensor ID
73 * @param flow_x [dpix] Flow in x-sensor direction
74 * @param flow_y [dpix] Flow in y-sensor direction
75 * @param flow_comp_m_x [m/s] Flow in x-sensor direction, angular-speed compensated
76 * @param flow_comp_m_y [m/s] Flow in y-sensor direction, angular-speed compensated
77 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
78 * @param ground_distance [m] Ground distance. Positive value: distance known. Negative value: Unknown distance
79 * @param flow_rate_x [rad/s] Flow rate about X axis
80 * @param flow_rate_y [rad/s] Flow rate about Y axis
81 * @return length of the message in bytes (excluding serial stream start sign)
82 */
83static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
84 uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance, float flow_rate_x, float flow_rate_y)
85{
86#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
88 _mav_put_uint64_t(buf, 0, time_usec);
89 _mav_put_float(buf, 8, flow_comp_m_x);
90 _mav_put_float(buf, 12, flow_comp_m_y);
91 _mav_put_float(buf, 16, ground_distance);
92 _mav_put_int16_t(buf, 20, flow_x);
93 _mav_put_int16_t(buf, 22, flow_y);
94 _mav_put_uint8_t(buf, 24, sensor_id);
95 _mav_put_uint8_t(buf, 25, quality);
96 _mav_put_float(buf, 26, flow_rate_x);
97 _mav_put_float(buf, 30, flow_rate_y);
98
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
100#else
101 mavlink_optical_flow_t packet;
102 packet.time_usec = time_usec;
103 packet.flow_comp_m_x = flow_comp_m_x;
104 packet.flow_comp_m_y = flow_comp_m_y;
105 packet.ground_distance = ground_distance;
106 packet.flow_x = flow_x;
107 packet.flow_y = flow_y;
108 packet.sensor_id = sensor_id;
109 packet.quality = quality;
110 packet.flow_rate_x = flow_rate_x;
111 packet.flow_rate_y = flow_rate_y;
112
113 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
114#endif
115
116 msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
117 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
118}
119
120/**
121 * @brief Pack a optical_flow message
122 * @param system_id ID of this system
123 * @param component_id ID of this component (e.g. 200 for IMU)
124 * @param status MAVLink status structure
125 * @param msg The MAVLink message to compress the data into
126 *
127 * @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.
128 * @param sensor_id Sensor ID
129 * @param flow_x [dpix] Flow in x-sensor direction
130 * @param flow_y [dpix] Flow in y-sensor direction
131 * @param flow_comp_m_x [m/s] Flow in x-sensor direction, angular-speed compensated
132 * @param flow_comp_m_y [m/s] Flow in y-sensor direction, angular-speed compensated
133 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
134 * @param ground_distance [m] Ground distance. Positive value: distance known. Negative value: Unknown distance
135 * @param flow_rate_x [rad/s] Flow rate about X axis
136 * @param flow_rate_y [rad/s] Flow rate about Y axis
137 * @return length of the message in bytes (excluding serial stream start sign)
138 */
139static inline uint16_t mavlink_msg_optical_flow_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
140 uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance, float flow_rate_x, float flow_rate_y)
141{
142#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
144 _mav_put_uint64_t(buf, 0, time_usec);
145 _mav_put_float(buf, 8, flow_comp_m_x);
146 _mav_put_float(buf, 12, flow_comp_m_y);
147 _mav_put_float(buf, 16, ground_distance);
148 _mav_put_int16_t(buf, 20, flow_x);
149 _mav_put_int16_t(buf, 22, flow_y);
150 _mav_put_uint8_t(buf, 24, sensor_id);
151 _mav_put_uint8_t(buf, 25, quality);
152 _mav_put_float(buf, 26, flow_rate_x);
153 _mav_put_float(buf, 30, flow_rate_y);
154
155 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
156#else
157 mavlink_optical_flow_t packet;
158 packet.time_usec = time_usec;
159 packet.flow_comp_m_x = flow_comp_m_x;
160 packet.flow_comp_m_y = flow_comp_m_y;
161 packet.ground_distance = ground_distance;
162 packet.flow_x = flow_x;
163 packet.flow_y = flow_y;
164 packet.sensor_id = sensor_id;
165 packet.quality = quality;
166 packet.flow_rate_x = flow_rate_x;
167 packet.flow_rate_y = flow_rate_y;
168
169 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
170#endif
171
172 msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
173#if MAVLINK_CRC_EXTRA
174 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
175#else
176 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
177#endif
178}
179
180/**
181 * @brief Pack a optical_flow message on a channel
182 * @param system_id ID of this system
183 * @param component_id ID of this component (e.g. 200 for IMU)
184 * @param chan The MAVLink channel this message will be sent over
185 * @param msg The MAVLink message to compress the data into
186 * @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.
187 * @param sensor_id Sensor ID
188 * @param flow_x [dpix] Flow in x-sensor direction
189 * @param flow_y [dpix] Flow in y-sensor direction
190 * @param flow_comp_m_x [m/s] Flow in x-sensor direction, angular-speed compensated
191 * @param flow_comp_m_y [m/s] Flow in y-sensor direction, angular-speed compensated
192 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
193 * @param ground_distance [m] Ground distance. Positive value: distance known. Negative value: Unknown distance
194 * @param flow_rate_x [rad/s] Flow rate about X axis
195 * @param flow_rate_y [rad/s] Flow rate about Y axis
196 * @return length of the message in bytes (excluding serial stream start sign)
197 */
198static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
199 mavlink_message_t* msg,
200 uint64_t time_usec,uint8_t sensor_id,int16_t flow_x,int16_t flow_y,float flow_comp_m_x,float flow_comp_m_y,uint8_t quality,float ground_distance,float flow_rate_x,float flow_rate_y)
201{
202#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
204 _mav_put_uint64_t(buf, 0, time_usec);
205 _mav_put_float(buf, 8, flow_comp_m_x);
206 _mav_put_float(buf, 12, flow_comp_m_y);
207 _mav_put_float(buf, 16, ground_distance);
208 _mav_put_int16_t(buf, 20, flow_x);
209 _mav_put_int16_t(buf, 22, flow_y);
210 _mav_put_uint8_t(buf, 24, sensor_id);
211 _mav_put_uint8_t(buf, 25, quality);
212 _mav_put_float(buf, 26, flow_rate_x);
213 _mav_put_float(buf, 30, flow_rate_y);
214
215 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
216#else
217 mavlink_optical_flow_t packet;
218 packet.time_usec = time_usec;
219 packet.flow_comp_m_x = flow_comp_m_x;
220 packet.flow_comp_m_y = flow_comp_m_y;
221 packet.ground_distance = ground_distance;
222 packet.flow_x = flow_x;
223 packet.flow_y = flow_y;
224 packet.sensor_id = sensor_id;
225 packet.quality = quality;
226 packet.flow_rate_x = flow_rate_x;
227 packet.flow_rate_y = flow_rate_y;
228
229 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
230#endif
231
232 msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
233 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
234}
235
236/**
237 * @brief Encode a optical_flow struct
238 *
239 * @param system_id ID of this system
240 * @param component_id ID of this component (e.g. 200 for IMU)
241 * @param msg The MAVLink message to compress the data into
242 * @param optical_flow C-struct to read the message contents from
243 */
244static inline uint16_t mavlink_msg_optical_flow_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow)
245{
246 return mavlink_msg_optical_flow_pack(system_id, component_id, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y);
247}
248
249/**
250 * @brief Encode a optical_flow struct on a channel
251 *
252 * @param system_id ID of this system
253 * @param component_id ID of this component (e.g. 200 for IMU)
254 * @param chan The MAVLink channel this message will be sent over
255 * @param msg The MAVLink message to compress the data into
256 * @param optical_flow C-struct to read the message contents from
257 */
258static inline uint16_t mavlink_msg_optical_flow_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow)
259{
260 return mavlink_msg_optical_flow_pack_chan(system_id, component_id, chan, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y);
261}
262
263/**
264 * @brief Encode a optical_flow struct with provided status structure
265 *
266 * @param system_id ID of this system
267 * @param component_id ID of this component (e.g. 200 for IMU)
268 * @param status MAVLink status structure
269 * @param msg The MAVLink message to compress the data into
270 * @param optical_flow C-struct to read the message contents from
271 */
272static inline uint16_t mavlink_msg_optical_flow_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow)
273{
274 return mavlink_msg_optical_flow_pack_status(system_id, component_id, _status, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y);
275}
276
277/**
278 * @brief Send a optical_flow message
279 * @param chan MAVLink channel to send the message
280 *
281 * @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.
282 * @param sensor_id Sensor ID
283 * @param flow_x [dpix] Flow in x-sensor direction
284 * @param flow_y [dpix] Flow in y-sensor direction
285 * @param flow_comp_m_x [m/s] Flow in x-sensor direction, angular-speed compensated
286 * @param flow_comp_m_y [m/s] Flow in y-sensor direction, angular-speed compensated
287 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
288 * @param ground_distance [m] Ground distance. Positive value: distance known. Negative value: Unknown distance
289 * @param flow_rate_x [rad/s] Flow rate about X axis
290 * @param flow_rate_y [rad/s] Flow rate about Y axis
291 */
292#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
293
294static inline void mavlink_msg_optical_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance, float flow_rate_x, float flow_rate_y)
295{
296#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
297 char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_LEN];
298 _mav_put_uint64_t(buf, 0, time_usec);
299 _mav_put_float(buf, 8, flow_comp_m_x);
300 _mav_put_float(buf, 12, flow_comp_m_y);
301 _mav_put_float(buf, 16, ground_distance);
302 _mav_put_int16_t(buf, 20, flow_x);
303 _mav_put_int16_t(buf, 22, flow_y);
304 _mav_put_uint8_t(buf, 24, sensor_id);
305 _mav_put_uint8_t(buf, 25, quality);
306 _mav_put_float(buf, 26, flow_rate_x);
307 _mav_put_float(buf, 30, flow_rate_y);
308
309 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
310#else
311 mavlink_optical_flow_t packet;
312 packet.time_usec = time_usec;
313 packet.flow_comp_m_x = flow_comp_m_x;
314 packet.flow_comp_m_y = flow_comp_m_y;
315 packet.ground_distance = ground_distance;
316 packet.flow_x = flow_x;
317 packet.flow_y = flow_y;
318 packet.sensor_id = sensor_id;
319 packet.quality = quality;
320 packet.flow_rate_x = flow_rate_x;
321 packet.flow_rate_y = flow_rate_y;
322
323 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
324#endif
325}
326
327/**
328 * @brief Send a optical_flow message
329 * @param chan MAVLink channel to send the message
330 * @param struct The MAVLink struct to serialize
331 */
332static inline void mavlink_msg_optical_flow_send_struct(mavlink_channel_t chan, const mavlink_optical_flow_t* optical_flow)
333{
334#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
335 mavlink_msg_optical_flow_send(chan, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance, optical_flow->flow_rate_x, optical_flow->flow_rate_y);
336#else
337 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)optical_flow, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
338#endif
339}
340
341#if MAVLINK_MSG_ID_OPTICAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
342/*
343 This variant of _send() can be used to save stack space by reusing
344 memory from the receive buffer. The caller provides a
345 mavlink_message_t which is the size of a full mavlink message. This
346 is usually the receive buffer for the channel, and allows a reply to an
347 incoming message with minimum stack space usage.
348 */
349static inline void mavlink_msg_optical_flow_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance, float flow_rate_x, float flow_rate_y)
350{
351#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
352 char *buf = (char *)msgbuf;
353 _mav_put_uint64_t(buf, 0, time_usec);
354 _mav_put_float(buf, 8, flow_comp_m_x);
355 _mav_put_float(buf, 12, flow_comp_m_y);
356 _mav_put_float(buf, 16, ground_distance);
357 _mav_put_int16_t(buf, 20, flow_x);
358 _mav_put_int16_t(buf, 22, flow_y);
359 _mav_put_uint8_t(buf, 24, sensor_id);
360 _mav_put_uint8_t(buf, 25, quality);
361 _mav_put_float(buf, 26, flow_rate_x);
362 _mav_put_float(buf, 30, flow_rate_y);
363
364 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
365#else
366 mavlink_optical_flow_t *packet = (mavlink_optical_flow_t *)msgbuf;
367 packet->time_usec = time_usec;
368 packet->flow_comp_m_x = flow_comp_m_x;
369 packet->flow_comp_m_y = flow_comp_m_y;
370 packet->ground_distance = ground_distance;
371 packet->flow_x = flow_x;
372 packet->flow_y = flow_y;
373 packet->sensor_id = sensor_id;
374 packet->quality = quality;
375 packet->flow_rate_x = flow_rate_x;
376 packet->flow_rate_y = flow_rate_y;
377
378 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
379#endif
380}
381#endif
382
383#endif
384
385// MESSAGE OPTICAL_FLOW UNPACKING
386
387
388/**
389 * @brief Get field time_usec from optical_flow message
390 *
391 * @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.
392 */
393static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_message_t* msg)
394{
395 return _MAV_RETURN_uint64_t(msg, 0);
396}
397
398/**
399 * @brief Get field sensor_id from optical_flow message
400 *
401 * @return Sensor ID
402 */
403static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t* msg)
404{
405 return _MAV_RETURN_uint8_t(msg, 24);
406}
407
408/**
409 * @brief Get field flow_x from optical_flow message
410 *
411 * @return [dpix] Flow in x-sensor direction
412 */
413static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t* msg)
414{
415 return _MAV_RETURN_int16_t(msg, 20);
416}
417
418/**
419 * @brief Get field flow_y from optical_flow message
420 *
421 * @return [dpix] Flow in y-sensor direction
422 */
423static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t* msg)
424{
425 return _MAV_RETURN_int16_t(msg, 22);
426}
427
428/**
429 * @brief Get field flow_comp_m_x from optical_flow message
430 *
431 * @return [m/s] Flow in x-sensor direction, angular-speed compensated
432 */
433static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t* msg)
434{
435 return _MAV_RETURN_float(msg, 8);
436}
437
438/**
439 * @brief Get field flow_comp_m_y from optical_flow message
440 *
441 * @return [m/s] Flow in y-sensor direction, angular-speed compensated
442 */
443static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t* msg)
444{
445 return _MAV_RETURN_float(msg, 12);
446}
447
448/**
449 * @brief Get field quality from optical_flow message
450 *
451 * @return Optical flow quality / confidence. 0: bad, 255: maximum quality
452 */
453static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t* msg)
454{
455 return _MAV_RETURN_uint8_t(msg, 25);
456}
457
458/**
459 * @brief Get field ground_distance from optical_flow message
460 *
461 * @return [m] Ground distance. Positive value: distance known. Negative value: Unknown distance
462 */
463static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t* msg)
464{
465 return _MAV_RETURN_float(msg, 16);
466}
467
468/**
469 * @brief Get field flow_rate_x from optical_flow message
470 *
471 * @return [rad/s] Flow rate about X axis
472 */
473static inline float mavlink_msg_optical_flow_get_flow_rate_x(const mavlink_message_t* msg)
474{
475 return _MAV_RETURN_float(msg, 26);
476}
477
478/**
479 * @brief Get field flow_rate_y from optical_flow message
480 *
481 * @return [rad/s] Flow rate about Y axis
482 */
483static inline float mavlink_msg_optical_flow_get_flow_rate_y(const mavlink_message_t* msg)
484{
485 return _MAV_RETURN_float(msg, 30);
486}
487
488/**
489 * @brief Decode a optical_flow message into a struct
490 *
491 * @param msg The message to decode
492 * @param optical_flow C-struct to decode the message contents into
493 */
494static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t* msg, mavlink_optical_flow_t* optical_flow)
495{
496#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
497 optical_flow->time_usec = mavlink_msg_optical_flow_get_time_usec(msg);
498 optical_flow->flow_comp_m_x = mavlink_msg_optical_flow_get_flow_comp_m_x(msg);
499 optical_flow->flow_comp_m_y = mavlink_msg_optical_flow_get_flow_comp_m_y(msg);
500 optical_flow->ground_distance = mavlink_msg_optical_flow_get_ground_distance(msg);
501 optical_flow->flow_x = mavlink_msg_optical_flow_get_flow_x(msg);
502 optical_flow->flow_y = mavlink_msg_optical_flow_get_flow_y(msg);
503 optical_flow->sensor_id = mavlink_msg_optical_flow_get_sensor_id(msg);
504 optical_flow->quality = mavlink_msg_optical_flow_get_quality(msg);
505 optical_flow->flow_rate_x = mavlink_msg_optical_flow_get_flow_rate_x(msg);
506 optical_flow->flow_rate_y = mavlink_msg_optical_flow_get_flow_rate_y(msg);
507#else
508 uint8_t len = msg->len < MAVLINK_MSG_ID_OPTICAL_FLOW_LEN? msg->len : MAVLINK_MSG_ID_OPTICAL_FLOW_LEN;
509 memset(optical_flow, 0, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
510 memcpy(optical_flow, _MAV_PAYLOAD(msg), len);
511#endif
512}