1 // MESSAGE OPTICAL_FLOW PACKING
3 #define MAVLINK_MSG_ID_OPTICAL_FLOW 100
5 typedef struct __mavlink_optical_flow_t
{
6 uint64_t time_usec
; ///< Timestamp (UNIX)
7 float flow_comp_m_x
; ///< Flow in meters in x-sensor direction, angular-speed compensated
8 float flow_comp_m_y
; ///< Flow in meters in y-sensor direction, angular-speed compensated
9 float ground_distance
; ///< Ground distance in meters. Positive value: distance known. Negative value: Unknown distance
10 int16_t flow_x
; ///< Flow in pixels in x-sensor direction
11 int16_t flow_y
; ///< Flow in pixels in y-sensor direction
12 uint8_t sensor_id
; ///< Sensor ID
13 uint8_t quality
; ///< Optical flow quality / confidence. 0: bad, 255: maximum quality
14 } mavlink_optical_flow_t
;
16 #define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 26
17 #define MAVLINK_MSG_ID_100_LEN 26
20 #define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW \
25 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) }, \
26 { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) }, \
27 { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) }, \
28 { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) }, \
29 { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) }, \
30 { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) }, \
31 { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) }, \
32 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) }, \
38 * @brief Pack a optical_flow message
39 * @param system_id ID of this system
40 * @param component_id ID of this component (e.g. 200 for IMU)
41 * @param msg The MAVLink message to compress the data into
43 * @param time_usec Timestamp (UNIX)
44 * @param sensor_id Sensor ID
45 * @param flow_x Flow in pixels in x-sensor direction
46 * @param flow_y Flow in pixels in y-sensor direction
47 * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated
48 * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated
49 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
50 * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance
51 * @return length of the message in bytes (excluding serial stream start sign)
53 static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
*msg
,
54 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
)
56 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
58 _mav_put_uint64_t(buf
, 0, time_usec
);
59 _mav_put_float(buf
, 8, flow_comp_m_x
);
60 _mav_put_float(buf
, 12, flow_comp_m_y
);
61 _mav_put_float(buf
, 16, ground_distance
);
62 _mav_put_int16_t(buf
, 20, flow_x
);
63 _mav_put_int16_t(buf
, 22, flow_y
);
64 _mav_put_uint8_t(buf
, 24, sensor_id
);
65 _mav_put_uint8_t(buf
, 25, quality
);
67 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 26);
69 mavlink_optical_flow_t packet
;
70 packet
.time_usec
= time_usec
;
71 packet
.flow_comp_m_x
= flow_comp_m_x
;
72 packet
.flow_comp_m_y
= flow_comp_m_y
;
73 packet
.ground_distance
= ground_distance
;
74 packet
.flow_x
= flow_x
;
75 packet
.flow_y
= flow_y
;
76 packet
.sensor_id
= sensor_id
;
77 packet
.quality
= quality
;
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 26);
80 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
82 msg
->msgid
= MAVLINK_MSG_ID_OPTICAL_FLOW
;
83 return mavlink_finalize_message(msg
, system_id
, component_id
, 26, 175);
87 * @brief Pack a optical_flow message on a channel
88 * @param system_id ID of this system
89 * @param component_id ID of this component (e.g. 200 for IMU)
90 * @param chan The MAVLink channel this message was sent over
91 * @param msg The MAVLink message to compress the data into
92 * @param time_usec Timestamp (UNIX)
93 * @param sensor_id Sensor ID
94 * @param flow_x Flow in pixels in x-sensor direction
95 * @param flow_y Flow in pixels in y-sensor direction
96 * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated
97 * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated
98 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
99 * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance
100 * @return length of the message in bytes (excluding serial stream start sign)
102 static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
103 mavlink_message_t
*msg
,
104 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
)
106 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
108 _mav_put_uint64_t(buf
, 0, time_usec
);
109 _mav_put_float(buf
, 8, flow_comp_m_x
);
110 _mav_put_float(buf
, 12, flow_comp_m_y
);
111 _mav_put_float(buf
, 16, ground_distance
);
112 _mav_put_int16_t(buf
, 20, flow_x
);
113 _mav_put_int16_t(buf
, 22, flow_y
);
114 _mav_put_uint8_t(buf
, 24, sensor_id
);
115 _mav_put_uint8_t(buf
, 25, quality
);
117 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 26);
119 mavlink_optical_flow_t packet
;
120 packet
.time_usec
= time_usec
;
121 packet
.flow_comp_m_x
= flow_comp_m_x
;
122 packet
.flow_comp_m_y
= flow_comp_m_y
;
123 packet
.ground_distance
= ground_distance
;
124 packet
.flow_x
= flow_x
;
125 packet
.flow_y
= flow_y
;
126 packet
.sensor_id
= sensor_id
;
127 packet
.quality
= quality
;
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 26);
130 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
132 msg
->msgid
= MAVLINK_MSG_ID_OPTICAL_FLOW
;
133 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, 26, 175);
137 * @brief Encode a optical_flow struct into a message
139 * @param system_id ID of this system
140 * @param component_id ID of this component (e.g. 200 for IMU)
141 * @param msg The MAVLink message to compress the data into
142 * @param optical_flow C-struct to read the message contents from
144 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
)
146 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
);
150 * @brief Send a optical_flow message
151 * @param chan MAVLink channel to send the message
153 * @param time_usec Timestamp (UNIX)
154 * @param sensor_id Sensor ID
155 * @param flow_x Flow in pixels in x-sensor direction
156 * @param flow_y Flow in pixels in y-sensor direction
157 * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated
158 * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated
159 * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality
160 * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance
162 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
164 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
)
166 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
168 _mav_put_uint64_t(buf
, 0, time_usec
);
169 _mav_put_float(buf
, 8, flow_comp_m_x
);
170 _mav_put_float(buf
, 12, flow_comp_m_y
);
171 _mav_put_float(buf
, 16, ground_distance
);
172 _mav_put_int16_t(buf
, 20, flow_x
);
173 _mav_put_int16_t(buf
, 22, flow_y
);
174 _mav_put_uint8_t(buf
, 24, sensor_id
);
175 _mav_put_uint8_t(buf
, 25, quality
);
177 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_OPTICAL_FLOW
, buf
, 26, 175);
179 mavlink_optical_flow_t packet
;
180 packet
.time_usec
= time_usec
;
181 packet
.flow_comp_m_x
= flow_comp_m_x
;
182 packet
.flow_comp_m_y
= flow_comp_m_y
;
183 packet
.ground_distance
= ground_distance
;
184 packet
.flow_x
= flow_x
;
185 packet
.flow_y
= flow_y
;
186 packet
.sensor_id
= sensor_id
;
187 packet
.quality
= quality
;
189 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_OPTICAL_FLOW
, (const char *)&packet
, 26, 175);
190 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
195 // MESSAGE OPTICAL_FLOW UNPACKING
199 * @brief Get field time_usec from optical_flow message
201 * @return Timestamp (UNIX)
203 static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_message_t
*msg
)
205 return _MAV_RETURN_uint64_t(msg
, 0);
209 * @brief Get field sensor_id from optical_flow message
213 static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t
*msg
)
215 return _MAV_RETURN_uint8_t(msg
, 24);
219 * @brief Get field flow_x from optical_flow message
221 * @return Flow in pixels in x-sensor direction
223 static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t
*msg
)
225 return _MAV_RETURN_int16_t(msg
, 20);
229 * @brief Get field flow_y from optical_flow message
231 * @return Flow in pixels in y-sensor direction
233 static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t
*msg
)
235 return _MAV_RETURN_int16_t(msg
, 22);
239 * @brief Get field flow_comp_m_x from optical_flow message
241 * @return Flow in meters in x-sensor direction, angular-speed compensated
243 static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t
*msg
)
245 return _MAV_RETURN_float(msg
, 8);
249 * @brief Get field flow_comp_m_y from optical_flow message
251 * @return Flow in meters in y-sensor direction, angular-speed compensated
253 static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t
*msg
)
255 return _MAV_RETURN_float(msg
, 12);
259 * @brief Get field quality from optical_flow message
261 * @return Optical flow quality / confidence. 0: bad, 255: maximum quality
263 static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t
*msg
)
265 return _MAV_RETURN_uint8_t(msg
, 25);
269 * @brief Get field ground_distance from optical_flow message
271 * @return Ground distance in meters. Positive value: distance known. Negative value: Unknown distance
273 static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t
*msg
)
275 return _MAV_RETURN_float(msg
, 16);
279 * @brief Decode a optical_flow message into a struct
281 * @param msg The message to decode
282 * @param optical_flow C-struct to decode the message contents into
284 static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t
*msg
, mavlink_optical_flow_t
*optical_flow
)
286 #if MAVLINK_NEED_BYTE_SWAP
287 optical_flow
->time_usec
= mavlink_msg_optical_flow_get_time_usec(msg
);
288 optical_flow
->flow_comp_m_x
= mavlink_msg_optical_flow_get_flow_comp_m_x(msg
);
289 optical_flow
->flow_comp_m_y
= mavlink_msg_optical_flow_get_flow_comp_m_y(msg
);
290 optical_flow
->ground_distance
= mavlink_msg_optical_flow_get_ground_distance(msg
);
291 optical_flow
->flow_x
= mavlink_msg_optical_flow_get_flow_x(msg
);
292 optical_flow
->flow_y
= mavlink_msg_optical_flow_get_flow_y(msg
);
293 optical_flow
->sensor_id
= mavlink_msg_optical_flow_get_sensor_id(msg
);
294 optical_flow
->quality
= mavlink_msg_optical_flow_get_quality(msg
);
296 memcpy(optical_flow
, _MAV_PAYLOAD(msg
), 26);