Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | // MESSAGE OPTICAL_FLOW PACKING |
2 | |||
3 | #define MAVLINK_MSG_ID_OPTICAL_FLOW 100 |
||
4 | |||
5 | typedef struct __mavlink_optical_flow_t |
||
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 in x-sensor direction |
||
12 | int16_t flow_y; ///< Flow in pixels in y-sensor direction |
||
13 | uint8_t sensor_id; ///< Sensor ID |
||
14 | uint8_t quality; ///< Optical flow quality / confidence. 0: bad, 255: maximum quality |
||
15 | } mavlink_optical_flow_t; |
||
16 | |||
17 | #define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 26 |
||
18 | #define MAVLINK_MSG_ID_100_LEN 26 |
||
19 | |||
20 | |||
21 | |||
22 | #define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW { \ |
||
23 | "OPTICAL_FLOW", \ |
||
24 | 8, \ |
||
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) }, \ |
||
33 | } \ |
||
34 | } |
||
35 | |||
36 | |||
37 | /** |
||
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 |
||
42 | * |
||
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) |
||
52 | */ |
||
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) |
||
55 | { |
||
56 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
57 | char buf[26]; |
||
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); |
||
66 | |||
67 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); |
||
68 | #else |
||
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; |
||
78 | |||
79 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); |
||
80 | #endif |
||
81 | |||
82 | msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW; |
||
83 | return mavlink_finalize_message(msg, system_id, component_id, 26, 175); |
||
84 | } |
||
85 | |||
86 | /** |
||
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) |
||
101 | */ |
||
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) |
||
105 | { |
||
106 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
107 | char buf[26]; |
||
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); |
||
116 | |||
117 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); |
||
118 | #else |
||
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; |
||
128 | |||
129 | memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); |
||
130 | #endif |
||
131 | |||
132 | msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW; |
||
133 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 26, 175); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @brief Encode a optical_flow struct into a message |
||
138 | * |
||
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 |
||
143 | */ |
||
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) |
||
145 | { |
||
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); |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @brief Send a optical_flow message |
||
151 | * @param chan MAVLink channel to send the message |
||
152 | * |
||
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 |
||
161 | */ |
||
162 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
||
163 | |||
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) |
||
165 | { |
||
166 | #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS |
||
167 | char buf[26]; |
||
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); |
||
176 | |||
177 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, 26, 175); |
||
178 | #else |
||
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; |
||
188 | |||
189 | _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, 26, 175); |
||
190 | #endif |
||
191 | } |
||
192 | |||
193 | #endif |
||
194 | |||
195 | // MESSAGE OPTICAL_FLOW UNPACKING |
||
196 | |||
197 | |||
198 | /** |
||
199 | * @brief Get field time_usec from optical_flow message |
||
200 | * |
||
201 | * @return Timestamp (UNIX) |
||
202 | */ |
||
203 | static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_message_t* msg) |
||
204 | { |
||
205 | return _MAV_RETURN_uint64_t(msg, 0); |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * @brief Get field sensor_id from optical_flow message |
||
210 | * |
||
211 | * @return Sensor ID |
||
212 | */ |
||
213 | static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t* msg) |
||
214 | { |
||
215 | return _MAV_RETURN_uint8_t(msg, 24); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @brief Get field flow_x from optical_flow message |
||
220 | * |
||
221 | * @return Flow in pixels in x-sensor direction |
||
222 | */ |
||
223 | static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t* msg) |
||
224 | { |
||
225 | return _MAV_RETURN_int16_t(msg, 20); |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * @brief Get field flow_y from optical_flow message |
||
230 | * |
||
231 | * @return Flow in pixels in y-sensor direction |
||
232 | */ |
||
233 | static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t* msg) |
||
234 | { |
||
235 | return _MAV_RETURN_int16_t(msg, 22); |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * @brief Get field flow_comp_m_x from optical_flow message |
||
240 | * |
||
241 | * @return Flow in meters in x-sensor direction, angular-speed compensated |
||
242 | */ |
||
243 | static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t* msg) |
||
244 | { |
||
245 | return _MAV_RETURN_float(msg, 8); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * @brief Get field flow_comp_m_y from optical_flow message |
||
250 | * |
||
251 | * @return Flow in meters in y-sensor direction, angular-speed compensated |
||
252 | */ |
||
253 | static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t* msg) |
||
254 | { |
||
255 | return _MAV_RETURN_float(msg, 12); |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * @brief Get field quality from optical_flow message |
||
260 | * |
||
261 | * @return Optical flow quality / confidence. 0: bad, 255: maximum quality |
||
262 | */ |
||
263 | static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t* msg) |
||
264 | { |
||
265 | return _MAV_RETURN_uint8_t(msg, 25); |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * @brief Get field ground_distance from optical_flow message |
||
270 | * |
||
271 | * @return Ground distance in meters. Positive value: distance known. Negative value: Unknown distance |
||
272 | */ |
||
273 | static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t* msg) |
||
274 | { |
||
275 | return _MAV_RETURN_float(msg, 16); |
||
276 | } |
||
277 | |||
278 | /** |
||
279 | * @brief Decode a optical_flow message into a struct |
||
280 | * |
||
281 | * @param msg The message to decode |
||
282 | * @param optical_flow C-struct to decode the message contents into |
||
283 | */ |
||
284 | static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t* msg, mavlink_optical_flow_t* optical_flow) |
||
285 | { |
||
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); |
||
295 | #else |
||
296 | memcpy(optical_flow, _MAV_PAYLOAD(msg), 26); |
||
297 | #endif |
||
298 | } |