MAV'RIC
mavlink_msg_omnidirectional_flow.h
1 // MESSAGE OMNIDIRECTIONAL_FLOW PACKING
2 
3 #define MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW 106
4 
6 {
7  uint64_t time_usec;
9  int16_t left[10];
10  int16_t right[10];
11  uint8_t sensor_id;
12  uint8_t quality;
14 
15 #define MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN 54
16 #define MAVLINK_MSG_ID_106_LEN 54
17 
18 #define MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC 211
19 #define MAVLINK_MSG_ID_106_CRC 211
20 
21 #define MAVLINK_MSG_OMNIDIRECTIONAL_FLOW_FIELD_LEFT_LEN 10
22 #define MAVLINK_MSG_OMNIDIRECTIONAL_FLOW_FIELD_RIGHT_LEN 10
23 
24 #define MAVLINK_MESSAGE_INFO_OMNIDIRECTIONAL_FLOW { \
25  "OMNIDIRECTIONAL_FLOW", \
26  6, \
27  { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_omnidirectional_flow_t, time_usec) }, \
28  { "front_distance_m", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_omnidirectional_flow_t, front_distance_m) }, \
29  { "left", NULL, MAVLINK_TYPE_INT16_T, 10, 12, offsetof(mavlink_omnidirectional_flow_t, left) }, \
30  { "right", NULL, MAVLINK_TYPE_INT16_T, 10, 32, offsetof(mavlink_omnidirectional_flow_t, right) }, \
31  { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 52, offsetof(mavlink_omnidirectional_flow_t, sensor_id) }, \
32  { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 53, offsetof(mavlink_omnidirectional_flow_t, quality) }, \
33  } \
34 }
35 
36 
51 static inline uint16_t mavlink_msg_omnidirectional_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
52  uint64_t time_usec, uint8_t sensor_id, const int16_t *left, const int16_t *right, uint8_t quality, float front_distance_m)
53 {
54 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55  char buf[MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN];
56  _mav_put_uint64_t(buf, 0, time_usec);
57  _mav_put_float(buf, 8, front_distance_m);
58  _mav_put_uint8_t(buf, 52, sensor_id);
59  _mav_put_uint8_t(buf, 53, quality);
60  _mav_put_int16_t_array(buf, 12, left, 10);
61  _mav_put_int16_t_array(buf, 32, right, 10);
62  memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
63 #else
65  packet.time_usec = time_usec;
66  packet.front_distance_m = front_distance_m;
67  packet.sensor_id = sensor_id;
68  packet.quality = quality;
69  mav_array_memcpy(packet.left, left, sizeof(int16_t)*10);
70  mav_array_memcpy(packet.right, right, sizeof(int16_t)*10);
71  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
72 #endif
73 
74  msg->msgid = MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW;
75 #if MAVLINK_CRC_EXTRA
76  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
77 #else
78  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
79 #endif
80 }
81 
96 static inline uint16_t mavlink_msg_omnidirectional_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
97  mavlink_message_t* msg,
98  uint64_t time_usec,uint8_t sensor_id,const int16_t *left,const int16_t *right,uint8_t quality,float front_distance_m)
99 {
100 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
101  char buf[MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN];
102  _mav_put_uint64_t(buf, 0, time_usec);
103  _mav_put_float(buf, 8, front_distance_m);
104  _mav_put_uint8_t(buf, 52, sensor_id);
105  _mav_put_uint8_t(buf, 53, quality);
106  _mav_put_int16_t_array(buf, 12, left, 10);
107  _mav_put_int16_t_array(buf, 32, right, 10);
108  memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
109 #else
111  packet.time_usec = time_usec;
112  packet.front_distance_m = front_distance_m;
113  packet.sensor_id = sensor_id;
114  packet.quality = quality;
115  mav_array_memcpy(packet.left, left, sizeof(int16_t)*10);
116  mav_array_memcpy(packet.right, right, sizeof(int16_t)*10);
117  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
118 #endif
119 
120  msg->msgid = MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW;
121 #if MAVLINK_CRC_EXTRA
122  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
123 #else
124  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
125 #endif
126 }
127 
136 static inline uint16_t mavlink_msg_omnidirectional_flow_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_omnidirectional_flow_t* omnidirectional_flow)
137 {
138  return mavlink_msg_omnidirectional_flow_pack(system_id, component_id, msg, omnidirectional_flow->time_usec, omnidirectional_flow->sensor_id, omnidirectional_flow->left, omnidirectional_flow->right, omnidirectional_flow->quality, omnidirectional_flow->front_distance_m);
139 }
140 
150 static inline uint16_t mavlink_msg_omnidirectional_flow_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_omnidirectional_flow_t* omnidirectional_flow)
151 {
152  return mavlink_msg_omnidirectional_flow_pack_chan(system_id, component_id, chan, msg, omnidirectional_flow->time_usec, omnidirectional_flow->sensor_id, omnidirectional_flow->left, omnidirectional_flow->right, omnidirectional_flow->quality, omnidirectional_flow->front_distance_m);
153 }
154 
166 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
167 
168 static inline void mavlink_msg_omnidirectional_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, const int16_t *left, const int16_t *right, uint8_t quality, float front_distance_m)
169 {
170 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
171  char buf[MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN];
172  _mav_put_uint64_t(buf, 0, time_usec);
173  _mav_put_float(buf, 8, front_distance_m);
174  _mav_put_uint8_t(buf, 52, sensor_id);
175  _mav_put_uint8_t(buf, 53, quality);
176  _mav_put_int16_t_array(buf, 12, left, 10);
177  _mav_put_int16_t_array(buf, 32, right, 10);
178 #if MAVLINK_CRC_EXTRA
179  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
180 #else
181  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
182 #endif
183 #else
185  packet.time_usec = time_usec;
186  packet.front_distance_m = front_distance_m;
187  packet.sensor_id = sensor_id;
188  packet.quality = quality;
189  mav_array_memcpy(packet.left, left, sizeof(int16_t)*10);
190  mav_array_memcpy(packet.right, right, sizeof(int16_t)*10);
191 #if MAVLINK_CRC_EXTRA
192  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
193 #else
194  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
195 #endif
196 #endif
197 }
198 
199 #if MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
200 /*
201  This varient of _send() can be used to save stack space by re-using
202  memory from the receive buffer. The caller provides a
203  mavlink_message_t which is the size of a full mavlink message. This
204  is usually the receive buffer for the channel, and allows a reply to an
205  incoming message with minimum stack space usage.
206  */
207 static inline void mavlink_msg_omnidirectional_flow_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, const int16_t *left, const int16_t *right, uint8_t quality, float front_distance_m)
208 {
209 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
210  char *buf = (char *)msgbuf;
211  _mav_put_uint64_t(buf, 0, time_usec);
212  _mav_put_float(buf, 8, front_distance_m);
213  _mav_put_uint8_t(buf, 52, sensor_id);
214  _mav_put_uint8_t(buf, 53, quality);
215  _mav_put_int16_t_array(buf, 12, left, 10);
216  _mav_put_int16_t_array(buf, 32, right, 10);
217 #if MAVLINK_CRC_EXTRA
218  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
219 #else
220  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, buf, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
221 #endif
222 #else
224  packet->time_usec = time_usec;
225  packet->front_distance_m = front_distance_m;
226  packet->sensor_id = sensor_id;
227  packet->quality = quality;
228  mav_array_memcpy(packet->left, left, sizeof(int16_t)*10);
229  mav_array_memcpy(packet->right, right, sizeof(int16_t)*10);
230 #if MAVLINK_CRC_EXTRA
231  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_CRC);
232 #else
233  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
234 #endif
235 #endif
236 }
237 #endif
238 
239 #endif
240 
241 // MESSAGE OMNIDIRECTIONAL_FLOW UNPACKING
242 
243 
249 static inline uint64_t mavlink_msg_omnidirectional_flow_get_time_usec(const mavlink_message_t* msg)
250 {
251  return _MAV_RETURN_uint64_t(msg, 0);
252 }
253 
259 static inline uint8_t mavlink_msg_omnidirectional_flow_get_sensor_id(const mavlink_message_t* msg)
260 {
261  return _MAV_RETURN_uint8_t(msg, 52);
262 }
263 
269 static inline uint16_t mavlink_msg_omnidirectional_flow_get_left(const mavlink_message_t* msg, int16_t *left)
270 {
271  return _MAV_RETURN_int16_t_array(msg, left, 10, 12);
272 }
273 
279 static inline uint16_t mavlink_msg_omnidirectional_flow_get_right(const mavlink_message_t* msg, int16_t *right)
280 {
281  return _MAV_RETURN_int16_t_array(msg, right, 10, 32);
282 }
283 
289 static inline uint8_t mavlink_msg_omnidirectional_flow_get_quality(const mavlink_message_t* msg)
290 {
291  return _MAV_RETURN_uint8_t(msg, 53);
292 }
293 
299 static inline float mavlink_msg_omnidirectional_flow_get_front_distance_m(const mavlink_message_t* msg)
300 {
301  return _MAV_RETURN_float(msg, 8);
302 }
303 
310 static inline void mavlink_msg_omnidirectional_flow_decode(const mavlink_message_t* msg, mavlink_omnidirectional_flow_t* omnidirectional_flow)
311 {
312 #if MAVLINK_NEED_BYTE_SWAP
313  omnidirectional_flow->time_usec = mavlink_msg_omnidirectional_flow_get_time_usec(msg);
314  omnidirectional_flow->front_distance_m = mavlink_msg_omnidirectional_flow_get_front_distance_m(msg);
315  mavlink_msg_omnidirectional_flow_get_left(msg, omnidirectional_flow->left);
316  mavlink_msg_omnidirectional_flow_get_right(msg, omnidirectional_flow->right);
317  omnidirectional_flow->sensor_id = mavlink_msg_omnidirectional_flow_get_sensor_id(msg);
318  omnidirectional_flow->quality = mavlink_msg_omnidirectional_flow_get_quality(msg);
319 #else
320  memcpy(omnidirectional_flow, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN);
321 #endif
322 }