MAV'RIC
mavlink_msg_hil_optical_flow.h
1 // MESSAGE HIL_OPTICAL_FLOW PACKING
2 
3 #define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW 114
4 
6 {
7  uint64_t time_usec;
8  float flow_comp_m_x;
9  float flow_comp_m_y;
11  int16_t flow_x;
12  int16_t flow_y;
13  uint8_t sensor_id;
14  uint8_t quality;
16 
17 #define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN 26
18 #define MAVLINK_MSG_ID_114_LEN 26
19 
20 #define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC 119
21 #define MAVLINK_MSG_ID_114_CRC 119
22 
23 
24 
25 #define MAVLINK_MESSAGE_INFO_HIL_OPTICAL_FLOW { \
26  "HIL_OPTICAL_FLOW", \
27  8, \
28  { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_optical_flow_t, time_usec) }, \
29  { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_optical_flow_t, flow_comp_m_x) }, \
30  { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_optical_flow_t, flow_comp_m_y) }, \
31  { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_optical_flow_t, ground_distance) }, \
32  { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_hil_optical_flow_t, flow_x) }, \
33  { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_hil_optical_flow_t, flow_y) }, \
34  { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_hil_optical_flow_t, sensor_id) }, \
35  { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_hil_optical_flow_t, quality) }, \
36  } \
37 }
38 
39 
56 static inline uint16_t mavlink_msg_hil_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
60  char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
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 
70  memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
71 #else
73  packet.time_usec = time_usec;
74  packet.flow_comp_m_x = flow_comp_m_x;
75  packet.flow_comp_m_y = flow_comp_m_y;
76  packet.ground_distance = ground_distance;
77  packet.flow_x = flow_x;
78  packet.flow_y = flow_y;
79  packet.sensor_id = sensor_id;
80  packet.quality = quality;
81 
82  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
83 #endif
84 
85  msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW;
86 #if MAVLINK_CRC_EXTRA
87  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
88 #else
89  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
90 #endif
91 }
92 
109 static inline uint16_t mavlink_msg_hil_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
114  char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
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 
124  memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
125 #else
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;
130  packet.ground_distance = ground_distance;
131  packet.flow_x = flow_x;
132  packet.flow_y = flow_y;
133  packet.sensor_id = sensor_id;
134  packet.quality = quality;
135 
136  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
137 #endif
138 
139  msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW;
140 #if MAVLINK_CRC_EXTRA
141  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
142 #else
143  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
144 #endif
145 }
146 
155 static inline uint16_t mavlink_msg_hil_optical_flow_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_optical_flow_t* hil_optical_flow)
156 {
157  return mavlink_msg_hil_optical_flow_pack(system_id, component_id, msg, hil_optical_flow->time_usec, hil_optical_flow->sensor_id, hil_optical_flow->flow_x, hil_optical_flow->flow_y, hil_optical_flow->flow_comp_m_x, hil_optical_flow->flow_comp_m_y, hil_optical_flow->quality, hil_optical_flow->ground_distance);
158 }
159 
169 static inline uint16_t mavlink_msg_hil_optical_flow_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_optical_flow_t* hil_optical_flow)
170 {
171  return mavlink_msg_hil_optical_flow_pack_chan(system_id, component_id, chan, msg, hil_optical_flow->time_usec, hil_optical_flow->sensor_id, hil_optical_flow->flow_x, hil_optical_flow->flow_y, hil_optical_flow->flow_comp_m_x, hil_optical_flow->flow_comp_m_y, hil_optical_flow->quality, hil_optical_flow->ground_distance);
172 }
173 
187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
188 
189 static inline void mavlink_msg_hil_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
192  char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
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
203  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
204 #else
205  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
206 #endif
207 #else
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;
212  packet.ground_distance = ground_distance;
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_HIL_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
220 #else
221  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
222 #endif
223 #endif
224 }
225 
226 #if MAVLINK_MSG_ID_HIL_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_hil_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
248  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
249 #else
250  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_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;
257  packet->ground_distance = ground_distance;
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_HIL_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
265 #else
266  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
267 #endif
268 #endif
269 }
270 #endif
271 
272 #endif
273 
274 // MESSAGE HIL_OPTICAL_FLOW UNPACKING
275 
276 
282 static inline uint64_t mavlink_msg_hil_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_hil_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_hil_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_hil_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_hil_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_hil_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_hil_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_hil_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_hil_optical_flow_decode(const mavlink_message_t* msg, mavlink_hil_optical_flow_t* hil_optical_flow)
364 {
365 #if MAVLINK_NEED_BYTE_SWAP
366  hil_optical_flow->time_usec = mavlink_msg_hil_optical_flow_get_time_usec(msg);
367  hil_optical_flow->flow_comp_m_x = mavlink_msg_hil_optical_flow_get_flow_comp_m_x(msg);
368  hil_optical_flow->flow_comp_m_y = mavlink_msg_hil_optical_flow_get_flow_comp_m_y(msg);
369  hil_optical_flow->ground_distance = mavlink_msg_hil_optical_flow_get_ground_distance(msg);
370  hil_optical_flow->flow_x = mavlink_msg_hil_optical_flow_get_flow_x(msg);
371  hil_optical_flow->flow_y = mavlink_msg_hil_optical_flow_get_flow_y(msg);
372  hil_optical_flow->sensor_id = mavlink_msg_hil_optical_flow_get_sensor_id(msg);
373  hil_optical_flow->quality = mavlink_msg_hil_optical_flow_get_quality(msg);
374 #else
375  memcpy(hil_optical_flow, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
376 #endif
377 }