mavlink_msg_optical_flow.h
Go to the documentation of this file.
1 // MESSAGE OPTICAL_FLOW PACKING
2 
3 #define MAVLINK_MSG_ID_OPTICAL_FLOW 100
4 
6 {
7  uint64_t time_usec; /*< Timestamp (UNIX)*/
8  float flow_comp_m_x; /*< Flow in meters in x-sensor direction, angular-speed compensated*/
9  float flow_comp_m_y; /*< Flow in meters in y-sensor direction, angular-speed compensated*/
10  float ground_distance; /*< Ground distance in meters. Positive value: distance known. Negative value: Unknown distance*/
11  int16_t flow_x; /*< Flow in pixels * 10 in x-sensor direction (dezi-pixels)*/
12  int16_t flow_y; /*< Flow in pixels * 10 in y-sensor direction (dezi-pixels)*/
13  uint8_t sensor_id; /*< Sensor ID*/
14  uint8_t quality; /*< Optical flow quality / confidence. 0: bad, 255: maximum quality*/
16 
17 #define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 26
18 #define MAVLINK_MSG_ID_100_LEN 26
19 
20 #define MAVLINK_MSG_ID_OPTICAL_FLOW_CRC 175
21 #define MAVLINK_MSG_ID_100_CRC 175
22 
23 
24 
25 #define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW { \
26  "OPTICAL_FLOW", \
27  8, \
28  { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) }, \
29  { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) }, \
30  { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) }, \
31  { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) }, \
32  { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) }, \
33  { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) }, \
34  { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) }, \
35  { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) }, \
36  } \
37 }
38 
39 
56 static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
57  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)
58 {
59 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
61  _mav_put_uint64_t(buf, 0, time_usec);
62  _mav_put_float(buf, 8, flow_comp_m_x);
63  _mav_put_float(buf, 12, flow_comp_m_y);
64  _mav_put_float(buf, 16, ground_distance);
65  _mav_put_int16_t(buf, 20, flow_x);
66  _mav_put_int16_t(buf, 22, flow_y);
67  _mav_put_uint8_t(buf, 24, sensor_id);
68  _mav_put_uint8_t(buf, 25, quality);
69 
71 #else
73  packet.time_usec = time_usec;
77  packet.flow_x = flow_x;
78  packet.flow_y = flow_y;
79  packet.sensor_id = sensor_id;
80  packet.quality = quality;
81 
83 #endif
84 
85  msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
86 #if MAVLINK_CRC_EXTRA
88 #else
89  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
90 #endif
91 }
92 
109 static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
110  mavlink_message_t* msg,
111  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)
112 {
113 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115  _mav_put_uint64_t(buf, 0, time_usec);
116  _mav_put_float(buf, 8, flow_comp_m_x);
117  _mav_put_float(buf, 12, flow_comp_m_y);
118  _mav_put_float(buf, 16, ground_distance);
119  _mav_put_int16_t(buf, 20, flow_x);
120  _mav_put_int16_t(buf, 22, flow_y);
121  _mav_put_uint8_t(buf, 24, sensor_id);
122  _mav_put_uint8_t(buf, 25, quality);
123 
125 #else
126  mavlink_optical_flow_t packet;
127  packet.time_usec = time_usec;
128  packet.flow_comp_m_x = flow_comp_m_x;
129  packet.flow_comp_m_y = flow_comp_m_y;
131  packet.flow_x = flow_x;
132  packet.flow_y = flow_y;
133  packet.sensor_id = sensor_id;
134  packet.quality = quality;
135 
137 #endif
138 
139  msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
140 #if MAVLINK_CRC_EXTRA
142 #else
143  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
144 #endif
145 }
146 
155 static 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)
156 {
157  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);
158 }
159 
169 static 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)
170 {
171  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);
172 }
173 
187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
188 
189 static 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)
190 {
191 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193  _mav_put_uint64_t(buf, 0, time_usec);
194  _mav_put_float(buf, 8, flow_comp_m_x);
195  _mav_put_float(buf, 12, flow_comp_m_y);
196  _mav_put_float(buf, 16, ground_distance);
197  _mav_put_int16_t(buf, 20, flow_x);
198  _mav_put_int16_t(buf, 22, flow_y);
199  _mav_put_uint8_t(buf, 24, sensor_id);
200  _mav_put_uint8_t(buf, 25, quality);
201 
202 #if MAVLINK_CRC_EXTRA
204 #else
205  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
206 #endif
207 #else
208  mavlink_optical_flow_t packet;
209  packet.time_usec = time_usec;
210  packet.flow_comp_m_x = flow_comp_m_x;
211  packet.flow_comp_m_y = flow_comp_m_y;
213  packet.flow_x = flow_x;
214  packet.flow_y = flow_y;
215  packet.sensor_id = sensor_id;
216  packet.quality = quality;
217 
218 #if MAVLINK_CRC_EXTRA
219  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
220 #else
221  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
222 #endif
223 #endif
224 }
225 
226 #if MAVLINK_MSG_ID_OPTICAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
227 /*
228  This varient of _send() can be used to save stack space by re-using
229  memory from the receive buffer. The caller provides a
230  mavlink_message_t which is the size of a full mavlink message. This
231  is usually the receive buffer for the channel, and allows a reply to an
232  incoming message with minimum stack space usage.
233  */
234 static 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)
235 {
236 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237  char *buf = (char *)msgbuf;
238  _mav_put_uint64_t(buf, 0, time_usec);
239  _mav_put_float(buf, 8, flow_comp_m_x);
240  _mav_put_float(buf, 12, flow_comp_m_y);
241  _mav_put_float(buf, 16, ground_distance);
242  _mav_put_int16_t(buf, 20, flow_x);
243  _mav_put_int16_t(buf, 22, flow_y);
244  _mav_put_uint8_t(buf, 24, sensor_id);
245  _mav_put_uint8_t(buf, 25, quality);
246 
247 #if MAVLINK_CRC_EXTRA
249 #else
250  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
251 #endif
252 #else
254  packet->time_usec = time_usec;
255  packet->flow_comp_m_x = flow_comp_m_x;
256  packet->flow_comp_m_y = flow_comp_m_y;
258  packet->flow_x = flow_x;
259  packet->flow_y = flow_y;
260  packet->sensor_id = sensor_id;
261  packet->quality = quality;
262 
263 #if MAVLINK_CRC_EXTRA
264  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
265 #else
266  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
267 #endif
268 #endif
269 }
270 #endif
271 
272 #endif
273 
274 // MESSAGE OPTICAL_FLOW UNPACKING
275 
276 
282 static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_message_t* msg)
283 {
284  return _MAV_RETURN_uint64_t(msg, 0);
285 }
286 
292 static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t* msg)
293 {
294  return _MAV_RETURN_uint8_t(msg, 24);
295 }
296 
302 static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t* msg)
303 {
304  return _MAV_RETURN_int16_t(msg, 20);
305 }
306 
312 static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t* msg)
313 {
314  return _MAV_RETURN_int16_t(msg, 22);
315 }
316 
322 static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t* msg)
323 {
324  return _MAV_RETURN_float(msg, 8);
325 }
326 
332 static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t* msg)
333 {
334  return _MAV_RETURN_float(msg, 12);
335 }
336 
342 static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t* msg)
343 {
344  return _MAV_RETURN_uint8_t(msg, 25);
345 }
346 
352 static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t* msg)
353 {
354  return _MAV_RETURN_float(msg, 16);
355 }
356 
363 static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t* msg, mavlink_optical_flow_t* optical_flow)
364 {
365 #if MAVLINK_NEED_BYTE_SWAP
370  optical_flow->flow_x = mavlink_msg_optical_flow_get_flow_x(msg);
371  optical_flow->flow_y = mavlink_msg_optical_flow_get_flow_y(msg);
373  optical_flow->quality = mavlink_msg_optical_flow_get_quality(msg);
374 #else
375  memcpy(optical_flow, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
376 #endif
377 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:151
#define _MAV_RETURN_uint8_t(msg, wire_offset)
Definition: protocol.h:244
#define _mav_put_uint8_t(buf, wire_offset, b)
Definition: protocol.h:140
#define _mav_put_uint64_t(buf, wire_offset, b)
Definition: protocol.h:149
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:146


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:25