source: flair-src/branches/mavlink/tools/Controller/Mavlink/src/include/common/mavlink_msg_hil_optical_flow.h@ 76

Last change on this file since 76 was 75, checked in by Thomas Fuhrmann, 8 years ago

Change the version of mavlink generated messages and rename it to include

File size: 25.4 KB
Line 
1// MESSAGE HIL_OPTICAL_FLOW PACKING
2
3#define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW 114
4
5typedef struct MAVLINK_PACKED __mavlink_hil_optical_flow_t
6{
7 uint64_t time_usec; /*< Timestamp (microseconds, synced to UNIX time or since system boot)*/
8 uint32_t integration_time_us; /*< Integration time in microseconds. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.*/
9 float integrated_x; /*< Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.)*/
10 float integrated_y; /*< Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.)*/
11 float integrated_xgyro; /*< RH rotation around X axis (rad)*/
12 float integrated_ygyro; /*< RH rotation around Y axis (rad)*/
13 float integrated_zgyro; /*< RH rotation around Z axis (rad)*/
14 uint32_t time_delta_distance_us; /*< Time in microseconds since the distance was sampled.*/
15 float distance; /*< Distance to the center of the flow field in meters. Positive value (including zero): distance known. Negative value: Unknown distance.*/
16 int16_t temperature; /*< Temperature * 100 in centi-degrees Celsius*/
17 uint8_t sensor_id; /*< Sensor ID*/
18 uint8_t quality; /*< Optical flow quality / confidence. 0: no valid flow, 255: maximum quality*/
19} mavlink_hil_optical_flow_t;
20
21#define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN 44
22#define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN 44
23#define MAVLINK_MSG_ID_114_LEN 44
24#define MAVLINK_MSG_ID_114_MIN_LEN 44
25
26#define MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC 237
27#define MAVLINK_MSG_ID_114_CRC 237
28
29
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_HIL_OPTICAL_FLOW { \
33 114, \
34 "HIL_OPTICAL_FLOW", \
35 12, \
36 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_optical_flow_t, time_usec) }, \
37 { "integration_time_us", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_hil_optical_flow_t, integration_time_us) }, \
38 { "integrated_x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_optical_flow_t, integrated_x) }, \
39 { "integrated_y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_optical_flow_t, integrated_y) }, \
40 { "integrated_xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_optical_flow_t, integrated_xgyro) }, \
41 { "integrated_ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_optical_flow_t, integrated_ygyro) }, \
42 { "integrated_zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_optical_flow_t, integrated_zgyro) }, \
43 { "time_delta_distance_us", NULL, MAVLINK_TYPE_UINT32_T, 0, 32, offsetof(mavlink_hil_optical_flow_t, time_delta_distance_us) }, \
44 { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_optical_flow_t, distance) }, \
45 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_hil_optical_flow_t, temperature) }, \
46 { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_hil_optical_flow_t, sensor_id) }, \
47 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_hil_optical_flow_t, quality) }, \
48 } \
49}
50#else
51#define MAVLINK_MESSAGE_INFO_HIL_OPTICAL_FLOW { \
52 "HIL_OPTICAL_FLOW", \
53 12, \
54 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_optical_flow_t, time_usec) }, \
55 { "integration_time_us", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_hil_optical_flow_t, integration_time_us) }, \
56 { "integrated_x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_optical_flow_t, integrated_x) }, \
57 { "integrated_y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_optical_flow_t, integrated_y) }, \
58 { "integrated_xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_optical_flow_t, integrated_xgyro) }, \
59 { "integrated_ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_optical_flow_t, integrated_ygyro) }, \
60 { "integrated_zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_optical_flow_t, integrated_zgyro) }, \
61 { "time_delta_distance_us", NULL, MAVLINK_TYPE_UINT32_T, 0, 32, offsetof(mavlink_hil_optical_flow_t, time_delta_distance_us) }, \
62 { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_optical_flow_t, distance) }, \
63 { "temperature", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_hil_optical_flow_t, temperature) }, \
64 { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_hil_optical_flow_t, sensor_id) }, \
65 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_hil_optical_flow_t, quality) }, \
66 } \
67}
68#endif
69
70/**
71 * @brief Pack a hil_optical_flow message
72 * @param system_id ID of this system
73 * @param component_id ID of this component (e.g. 200 for IMU)
74 * @param msg The MAVLink message to compress the data into
75 *
76 * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot)
77 * @param sensor_id Sensor ID
78 * @param integration_time_us Integration time in microseconds. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.
79 * @param integrated_x Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.)
80 * @param integrated_y Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.)
81 * @param integrated_xgyro RH rotation around X axis (rad)
82 * @param integrated_ygyro RH rotation around Y axis (rad)
83 * @param integrated_zgyro RH rotation around Z axis (rad)
84 * @param temperature Temperature * 100 in centi-degrees Celsius
85 * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
86 * @param time_delta_distance_us Time in microseconds since the distance was sampled.
87 * @param distance Distance to the center of the flow field in meters. Positive value (including zero): distance known. Negative value: Unknown distance.
88 * @return length of the message in bytes (excluding serial stream start sign)
89 */
90static inline uint16_t mavlink_msg_hil_optical_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
91 uint64_t time_usec, uint8_t sensor_id, uint32_t integration_time_us, float integrated_x, float integrated_y, float integrated_xgyro, float integrated_ygyro, float integrated_zgyro, int16_t temperature, uint8_t quality, uint32_t time_delta_distance_us, float distance)
92{
93#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
94 char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
95 _mav_put_uint64_t(buf, 0, time_usec);
96 _mav_put_uint32_t(buf, 8, integration_time_us);
97 _mav_put_float(buf, 12, integrated_x);
98 _mav_put_float(buf, 16, integrated_y);
99 _mav_put_float(buf, 20, integrated_xgyro);
100 _mav_put_float(buf, 24, integrated_ygyro);
101 _mav_put_float(buf, 28, integrated_zgyro);
102 _mav_put_uint32_t(buf, 32, time_delta_distance_us);
103 _mav_put_float(buf, 36, distance);
104 _mav_put_int16_t(buf, 40, temperature);
105 _mav_put_uint8_t(buf, 42, sensor_id);
106 _mav_put_uint8_t(buf, 43, quality);
107
108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
109#else
110 mavlink_hil_optical_flow_t packet;
111 packet.time_usec = time_usec;
112 packet.integration_time_us = integration_time_us;
113 packet.integrated_x = integrated_x;
114 packet.integrated_y = integrated_y;
115 packet.integrated_xgyro = integrated_xgyro;
116 packet.integrated_ygyro = integrated_ygyro;
117 packet.integrated_zgyro = integrated_zgyro;
118 packet.time_delta_distance_us = time_delta_distance_us;
119 packet.distance = distance;
120 packet.temperature = temperature;
121 packet.sensor_id = sensor_id;
122 packet.quality = quality;
123
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
125#endif
126
127 msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW;
128 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
129}
130
131/**
132 * @brief Pack a hil_optical_flow message on a channel
133 * @param system_id ID of this system
134 * @param component_id ID of this component (e.g. 200 for IMU)
135 * @param chan The MAVLink channel this message will be sent over
136 * @param msg The MAVLink message to compress the data into
137 * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot)
138 * @param sensor_id Sensor ID
139 * @param integration_time_us Integration time in microseconds. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.
140 * @param integrated_x Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.)
141 * @param integrated_y Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.)
142 * @param integrated_xgyro RH rotation around X axis (rad)
143 * @param integrated_ygyro RH rotation around Y axis (rad)
144 * @param integrated_zgyro RH rotation around Z axis (rad)
145 * @param temperature Temperature * 100 in centi-degrees Celsius
146 * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
147 * @param time_delta_distance_us Time in microseconds since the distance was sampled.
148 * @param distance Distance to the center of the flow field in meters. Positive value (including zero): distance known. Negative value: Unknown distance.
149 * @return length of the message in bytes (excluding serial stream start sign)
150 */
151static inline uint16_t mavlink_msg_hil_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
152 mavlink_message_t* msg,
153 uint64_t time_usec,uint8_t sensor_id,uint32_t integration_time_us,float integrated_x,float integrated_y,float integrated_xgyro,float integrated_ygyro,float integrated_zgyro,int16_t temperature,uint8_t quality,uint32_t time_delta_distance_us,float distance)
154{
155#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
156 char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
157 _mav_put_uint64_t(buf, 0, time_usec);
158 _mav_put_uint32_t(buf, 8, integration_time_us);
159 _mav_put_float(buf, 12, integrated_x);
160 _mav_put_float(buf, 16, integrated_y);
161 _mav_put_float(buf, 20, integrated_xgyro);
162 _mav_put_float(buf, 24, integrated_ygyro);
163 _mav_put_float(buf, 28, integrated_zgyro);
164 _mav_put_uint32_t(buf, 32, time_delta_distance_us);
165 _mav_put_float(buf, 36, distance);
166 _mav_put_int16_t(buf, 40, temperature);
167 _mav_put_uint8_t(buf, 42, sensor_id);
168 _mav_put_uint8_t(buf, 43, quality);
169
170 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
171#else
172 mavlink_hil_optical_flow_t packet;
173 packet.time_usec = time_usec;
174 packet.integration_time_us = integration_time_us;
175 packet.integrated_x = integrated_x;
176 packet.integrated_y = integrated_y;
177 packet.integrated_xgyro = integrated_xgyro;
178 packet.integrated_ygyro = integrated_ygyro;
179 packet.integrated_zgyro = integrated_zgyro;
180 packet.time_delta_distance_us = time_delta_distance_us;
181 packet.distance = distance;
182 packet.temperature = temperature;
183 packet.sensor_id = sensor_id;
184 packet.quality = quality;
185
186 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
187#endif
188
189 msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW;
190 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
191}
192
193/**
194 * @brief Encode a hil_optical_flow struct
195 *
196 * @param system_id ID of this system
197 * @param component_id ID of this component (e.g. 200 for IMU)
198 * @param msg The MAVLink message to compress the data into
199 * @param hil_optical_flow C-struct to read the message contents from
200 */
201static 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)
202{
203 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->integration_time_us, hil_optical_flow->integrated_x, hil_optical_flow->integrated_y, hil_optical_flow->integrated_xgyro, hil_optical_flow->integrated_ygyro, hil_optical_flow->integrated_zgyro, hil_optical_flow->temperature, hil_optical_flow->quality, hil_optical_flow->time_delta_distance_us, hil_optical_flow->distance);
204}
205
206/**
207 * @brief Encode a hil_optical_flow struct on a channel
208 *
209 * @param system_id ID of this system
210 * @param component_id ID of this component (e.g. 200 for IMU)
211 * @param chan The MAVLink channel this message will be sent over
212 * @param msg The MAVLink message to compress the data into
213 * @param hil_optical_flow C-struct to read the message contents from
214 */
215static 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)
216{
217 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->integration_time_us, hil_optical_flow->integrated_x, hil_optical_flow->integrated_y, hil_optical_flow->integrated_xgyro, hil_optical_flow->integrated_ygyro, hil_optical_flow->integrated_zgyro, hil_optical_flow->temperature, hil_optical_flow->quality, hil_optical_flow->time_delta_distance_us, hil_optical_flow->distance);
218}
219
220/**
221 * @brief Send a hil_optical_flow message
222 * @param chan MAVLink channel to send the message
223 *
224 * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot)
225 * @param sensor_id Sensor ID
226 * @param integration_time_us Integration time in microseconds. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.
227 * @param integrated_x Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.)
228 * @param integrated_y Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.)
229 * @param integrated_xgyro RH rotation around X axis (rad)
230 * @param integrated_ygyro RH rotation around Y axis (rad)
231 * @param integrated_zgyro RH rotation around Z axis (rad)
232 * @param temperature Temperature * 100 in centi-degrees Celsius
233 * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
234 * @param time_delta_distance_us Time in microseconds since the distance was sampled.
235 * @param distance Distance to the center of the flow field in meters. Positive value (including zero): distance known. Negative value: Unknown distance.
236 */
237#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
238
239static inline void mavlink_msg_hil_optical_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, uint32_t integration_time_us, float integrated_x, float integrated_y, float integrated_xgyro, float integrated_ygyro, float integrated_zgyro, int16_t temperature, uint8_t quality, uint32_t time_delta_distance_us, float distance)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
243 _mav_put_uint64_t(buf, 0, time_usec);
244 _mav_put_uint32_t(buf, 8, integration_time_us);
245 _mav_put_float(buf, 12, integrated_x);
246 _mav_put_float(buf, 16, integrated_y);
247 _mav_put_float(buf, 20, integrated_xgyro);
248 _mav_put_float(buf, 24, integrated_ygyro);
249 _mav_put_float(buf, 28, integrated_zgyro);
250 _mav_put_uint32_t(buf, 32, time_delta_distance_us);
251 _mav_put_float(buf, 36, distance);
252 _mav_put_int16_t(buf, 40, temperature);
253 _mav_put_uint8_t(buf, 42, sensor_id);
254 _mav_put_uint8_t(buf, 43, quality);
255
256 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
257#else
258 mavlink_hil_optical_flow_t packet;
259 packet.time_usec = time_usec;
260 packet.integration_time_us = integration_time_us;
261 packet.integrated_x = integrated_x;
262 packet.integrated_y = integrated_y;
263 packet.integrated_xgyro = integrated_xgyro;
264 packet.integrated_ygyro = integrated_ygyro;
265 packet.integrated_zgyro = integrated_zgyro;
266 packet.time_delta_distance_us = time_delta_distance_us;
267 packet.distance = distance;
268 packet.temperature = temperature;
269 packet.sensor_id = sensor_id;
270 packet.quality = quality;
271
272 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
273#endif
274}
275
276/**
277 * @brief Send a hil_optical_flow message
278 * @param chan MAVLink channel to send the message
279 * @param struct The MAVLink struct to serialize
280 */
281static inline void mavlink_msg_hil_optical_flow_send_struct(mavlink_channel_t chan, const mavlink_hil_optical_flow_t* hil_optical_flow)
282{
283#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
284 mavlink_msg_hil_optical_flow_send(chan, hil_optical_flow->time_usec, hil_optical_flow->sensor_id, hil_optical_flow->integration_time_us, hil_optical_flow->integrated_x, hil_optical_flow->integrated_y, hil_optical_flow->integrated_xgyro, hil_optical_flow->integrated_ygyro, hil_optical_flow->integrated_zgyro, hil_optical_flow->temperature, hil_optical_flow->quality, hil_optical_flow->time_delta_distance_us, hil_optical_flow->distance);
285#else
286 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, (const char *)hil_optical_flow, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
287#endif
288}
289
290#if MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
291/*
292 This varient of _send() can be used to save stack space by re-using
293 memory from the receive buffer. The caller provides a
294 mavlink_message_t which is the size of a full mavlink message. This
295 is usually the receive buffer for the channel, and allows a reply to an
296 incoming message with minimum stack space usage.
297 */
298static 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, uint32_t integration_time_us, float integrated_x, float integrated_y, float integrated_xgyro, float integrated_ygyro, float integrated_zgyro, int16_t temperature, uint8_t quality, uint32_t time_delta_distance_us, float distance)
299{
300#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
301 char *buf = (char *)msgbuf;
302 _mav_put_uint64_t(buf, 0, time_usec);
303 _mav_put_uint32_t(buf, 8, integration_time_us);
304 _mav_put_float(buf, 12, integrated_x);
305 _mav_put_float(buf, 16, integrated_y);
306 _mav_put_float(buf, 20, integrated_xgyro);
307 _mav_put_float(buf, 24, integrated_ygyro);
308 _mav_put_float(buf, 28, integrated_zgyro);
309 _mav_put_uint32_t(buf, 32, time_delta_distance_us);
310 _mav_put_float(buf, 36, distance);
311 _mav_put_int16_t(buf, 40, temperature);
312 _mav_put_uint8_t(buf, 42, sensor_id);
313 _mav_put_uint8_t(buf, 43, quality);
314
315 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
316#else
317 mavlink_hil_optical_flow_t *packet = (mavlink_hil_optical_flow_t *)msgbuf;
318 packet->time_usec = time_usec;
319 packet->integration_time_us = integration_time_us;
320 packet->integrated_x = integrated_x;
321 packet->integrated_y = integrated_y;
322 packet->integrated_xgyro = integrated_xgyro;
323 packet->integrated_ygyro = integrated_ygyro;
324 packet->integrated_zgyro = integrated_zgyro;
325 packet->time_delta_distance_us = time_delta_distance_us;
326 packet->distance = distance;
327 packet->temperature = temperature;
328 packet->sensor_id = sensor_id;
329 packet->quality = quality;
330
331 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
332#endif
333}
334#endif
335
336#endif
337
338// MESSAGE HIL_OPTICAL_FLOW UNPACKING
339
340
341/**
342 * @brief Get field time_usec from hil_optical_flow message
343 *
344 * @return Timestamp (microseconds, synced to UNIX time or since system boot)
345 */
346static inline uint64_t mavlink_msg_hil_optical_flow_get_time_usec(const mavlink_message_t* msg)
347{
348 return _MAV_RETURN_uint64_t(msg, 0);
349}
350
351/**
352 * @brief Get field sensor_id from hil_optical_flow message
353 *
354 * @return Sensor ID
355 */
356static inline uint8_t mavlink_msg_hil_optical_flow_get_sensor_id(const mavlink_message_t* msg)
357{
358 return _MAV_RETURN_uint8_t(msg, 42);
359}
360
361/**
362 * @brief Get field integration_time_us from hil_optical_flow message
363 *
364 * @return Integration time in microseconds. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.
365 */
366static inline uint32_t mavlink_msg_hil_optical_flow_get_integration_time_us(const mavlink_message_t* msg)
367{
368 return _MAV_RETURN_uint32_t(msg, 8);
369}
370
371/**
372 * @brief Get field integrated_x from hil_optical_flow message
373 *
374 * @return Flow in radians around X axis (Sensor RH rotation about the X axis induces a positive flow. Sensor linear motion along the positive Y axis induces a negative flow.)
375 */
376static inline float mavlink_msg_hil_optical_flow_get_integrated_x(const mavlink_message_t* msg)
377{
378 return _MAV_RETURN_float(msg, 12);
379}
380
381/**
382 * @brief Get field integrated_y from hil_optical_flow message
383 *
384 * @return Flow in radians around Y axis (Sensor RH rotation about the Y axis induces a positive flow. Sensor linear motion along the positive X axis induces a positive flow.)
385 */
386static inline float mavlink_msg_hil_optical_flow_get_integrated_y(const mavlink_message_t* msg)
387{
388 return _MAV_RETURN_float(msg, 16);
389}
390
391/**
392 * @brief Get field integrated_xgyro from hil_optical_flow message
393 *
394 * @return RH rotation around X axis (rad)
395 */
396static inline float mavlink_msg_hil_optical_flow_get_integrated_xgyro(const mavlink_message_t* msg)
397{
398 return _MAV_RETURN_float(msg, 20);
399}
400
401/**
402 * @brief Get field integrated_ygyro from hil_optical_flow message
403 *
404 * @return RH rotation around Y axis (rad)
405 */
406static inline float mavlink_msg_hil_optical_flow_get_integrated_ygyro(const mavlink_message_t* msg)
407{
408 return _MAV_RETURN_float(msg, 24);
409}
410
411/**
412 * @brief Get field integrated_zgyro from hil_optical_flow message
413 *
414 * @return RH rotation around Z axis (rad)
415 */
416static inline float mavlink_msg_hil_optical_flow_get_integrated_zgyro(const mavlink_message_t* msg)
417{
418 return _MAV_RETURN_float(msg, 28);
419}
420
421/**
422 * @brief Get field temperature from hil_optical_flow message
423 *
424 * @return Temperature * 100 in centi-degrees Celsius
425 */
426static inline int16_t mavlink_msg_hil_optical_flow_get_temperature(const mavlink_message_t* msg)
427{
428 return _MAV_RETURN_int16_t(msg, 40);
429}
430
431/**
432 * @brief Get field quality from hil_optical_flow message
433 *
434 * @return Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
435 */
436static inline uint8_t mavlink_msg_hil_optical_flow_get_quality(const mavlink_message_t* msg)
437{
438 return _MAV_RETURN_uint8_t(msg, 43);
439}
440
441/**
442 * @brief Get field time_delta_distance_us from hil_optical_flow message
443 *
444 * @return Time in microseconds since the distance was sampled.
445 */
446static inline uint32_t mavlink_msg_hil_optical_flow_get_time_delta_distance_us(const mavlink_message_t* msg)
447{
448 return _MAV_RETURN_uint32_t(msg, 32);
449}
450
451/**
452 * @brief Get field distance from hil_optical_flow message
453 *
454 * @return Distance to the center of the flow field in meters. Positive value (including zero): distance known. Negative value: Unknown distance.
455 */
456static inline float mavlink_msg_hil_optical_flow_get_distance(const mavlink_message_t* msg)
457{
458 return _MAV_RETURN_float(msg, 36);
459}
460
461/**
462 * @brief Decode a hil_optical_flow message into a struct
463 *
464 * @param msg The message to decode
465 * @param hil_optical_flow C-struct to decode the message contents into
466 */
467static inline void mavlink_msg_hil_optical_flow_decode(const mavlink_message_t* msg, mavlink_hil_optical_flow_t* hil_optical_flow)
468{
469#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
470 hil_optical_flow->time_usec = mavlink_msg_hil_optical_flow_get_time_usec(msg);
471 hil_optical_flow->integration_time_us = mavlink_msg_hil_optical_flow_get_integration_time_us(msg);
472 hil_optical_flow->integrated_x = mavlink_msg_hil_optical_flow_get_integrated_x(msg);
473 hil_optical_flow->integrated_y = mavlink_msg_hil_optical_flow_get_integrated_y(msg);
474 hil_optical_flow->integrated_xgyro = mavlink_msg_hil_optical_flow_get_integrated_xgyro(msg);
475 hil_optical_flow->integrated_ygyro = mavlink_msg_hil_optical_flow_get_integrated_ygyro(msg);
476 hil_optical_flow->integrated_zgyro = mavlink_msg_hil_optical_flow_get_integrated_zgyro(msg);
477 hil_optical_flow->time_delta_distance_us = mavlink_msg_hil_optical_flow_get_time_delta_distance_us(msg);
478 hil_optical_flow->distance = mavlink_msg_hil_optical_flow_get_distance(msg);
479 hil_optical_flow->temperature = mavlink_msg_hil_optical_flow_get_temperature(msg);
480 hil_optical_flow->sensor_id = mavlink_msg_hil_optical_flow_get_sensor_id(msg);
481 hil_optical_flow->quality = mavlink_msg_hil_optical_flow_get_quality(msg);
482#else
483 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN? msg->len : MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN;
484 memset(hil_optical_flow, 0, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
485 memcpy(hil_optical_flow, _MAV_PAYLOAD(msg), len);
486#endif
487}
Note: See TracBrowser for help on using the repository browser.