mavlink_msg_optical_flow.h
Go to the documentation of this file.
00001 // MESSAGE OPTICAL_FLOW PACKING
00002 
00003 #define MAVLINK_MSG_ID_OPTICAL_FLOW 100
00004 
00005 typedef struct __mavlink_optical_flow_t
00006 {
00007  uint64_t time_usec; /*< Timestamp (UNIX)*/
00008  float flow_comp_m_x; /*< Flow in meters in x-sensor direction, angular-speed compensated*/
00009  float flow_comp_m_y; /*< Flow in meters in y-sensor direction, angular-speed compensated*/
00010  float ground_distance; /*< Ground distance in meters. Positive value: distance known. Negative value: Unknown distance*/
00011  int16_t flow_x; /*< Flow in pixels * 10 in x-sensor direction (dezi-pixels)*/
00012  int16_t flow_y; /*< Flow in pixels * 10 in y-sensor direction (dezi-pixels)*/
00013  uint8_t sensor_id; /*< Sensor ID*/
00014  uint8_t quality; /*< Optical flow quality / confidence. 0: bad, 255: maximum quality*/
00015 } mavlink_optical_flow_t;
00016 
00017 #define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 26
00018 #define MAVLINK_MSG_ID_100_LEN 26
00019 
00020 #define MAVLINK_MSG_ID_OPTICAL_FLOW_CRC 175
00021 #define MAVLINK_MSG_ID_100_CRC 175
00022 
00023 
00024 
00025 #define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW { \
00026         "OPTICAL_FLOW", \
00027         8, \
00028         {  { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) }, \
00029          { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) }, \
00030          { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) }, \
00031          { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) }, \
00032          { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) }, \
00033          { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) }, \
00034          { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) }, \
00035          { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) }, \
00036          } \
00037 }
00038 
00039 
00056 static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
00057                                                        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)
00058 {
00059 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00060         char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_LEN];
00061         _mav_put_uint64_t(buf, 0, time_usec);
00062         _mav_put_float(buf, 8, flow_comp_m_x);
00063         _mav_put_float(buf, 12, flow_comp_m_y);
00064         _mav_put_float(buf, 16, ground_distance);
00065         _mav_put_int16_t(buf, 20, flow_x);
00066         _mav_put_int16_t(buf, 22, flow_y);
00067         _mav_put_uint8_t(buf, 24, sensor_id);
00068         _mav_put_uint8_t(buf, 25, quality);
00069 
00070         memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00071 #else
00072         mavlink_optical_flow_t packet;
00073         packet.time_usec = time_usec;
00074         packet.flow_comp_m_x = flow_comp_m_x;
00075         packet.flow_comp_m_y = flow_comp_m_y;
00076         packet.ground_distance = ground_distance;
00077         packet.flow_x = flow_x;
00078         packet.flow_y = flow_y;
00079         packet.sensor_id = sensor_id;
00080         packet.quality = quality;
00081 
00082         memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00083 #endif
00084 
00085         msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
00086 #if MAVLINK_CRC_EXTRA
00087     return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00088 #else
00089     return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00090 #endif
00091 }
00092 
00109 static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
00110                                                            mavlink_message_t* msg,
00111                                                            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)
00112 {
00113 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00114         char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_LEN];
00115         _mav_put_uint64_t(buf, 0, time_usec);
00116         _mav_put_float(buf, 8, flow_comp_m_x);
00117         _mav_put_float(buf, 12, flow_comp_m_y);
00118         _mav_put_float(buf, 16, ground_distance);
00119         _mav_put_int16_t(buf, 20, flow_x);
00120         _mav_put_int16_t(buf, 22, flow_y);
00121         _mav_put_uint8_t(buf, 24, sensor_id);
00122         _mav_put_uint8_t(buf, 25, quality);
00123 
00124         memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00125 #else
00126         mavlink_optical_flow_t packet;
00127         packet.time_usec = time_usec;
00128         packet.flow_comp_m_x = flow_comp_m_x;
00129         packet.flow_comp_m_y = flow_comp_m_y;
00130         packet.ground_distance = ground_distance;
00131         packet.flow_x = flow_x;
00132         packet.flow_y = flow_y;
00133         packet.sensor_id = sensor_id;
00134         packet.quality = quality;
00135 
00136         memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00137 #endif
00138 
00139         msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW;
00140 #if MAVLINK_CRC_EXTRA
00141     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00142 #else
00143     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00144 #endif
00145 }
00146 
00155 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)
00156 {
00157         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);
00158 }
00159 
00169 static inline uint16_t mavlink_msg_optical_flow_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow)
00170 {
00171         return mavlink_msg_optical_flow_pack_chan(system_id, component_id, chan, 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);
00172 }
00173 
00187 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00188 
00189 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)
00190 {
00191 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00192         char buf[MAVLINK_MSG_ID_OPTICAL_FLOW_LEN];
00193         _mav_put_uint64_t(buf, 0, time_usec);
00194         _mav_put_float(buf, 8, flow_comp_m_x);
00195         _mav_put_float(buf, 12, flow_comp_m_y);
00196         _mav_put_float(buf, 16, ground_distance);
00197         _mav_put_int16_t(buf, 20, flow_x);
00198         _mav_put_int16_t(buf, 22, flow_y);
00199         _mav_put_uint8_t(buf, 24, sensor_id);
00200         _mav_put_uint8_t(buf, 25, quality);
00201 
00202 #if MAVLINK_CRC_EXTRA
00203     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00204 #else
00205     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00206 #endif
00207 #else
00208         mavlink_optical_flow_t packet;
00209         packet.time_usec = time_usec;
00210         packet.flow_comp_m_x = flow_comp_m_x;
00211         packet.flow_comp_m_y = flow_comp_m_y;
00212         packet.ground_distance = ground_distance;
00213         packet.flow_x = flow_x;
00214         packet.flow_y = flow_y;
00215         packet.sensor_id = sensor_id;
00216         packet.quality = quality;
00217 
00218 #if MAVLINK_CRC_EXTRA
00219     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00220 #else
00221     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00222 #endif
00223 #endif
00224 }
00225 
00226 #if MAVLINK_MSG_ID_OPTICAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
00227 /*
00228   This varient of _send() can be used to save stack space by re-using
00229   memory from the receive buffer.  The caller provides a
00230   mavlink_message_t which is the size of a full mavlink message. This
00231   is usually the receive buffer for the channel, and allows a reply to an
00232   incoming message with minimum stack space usage.
00233  */
00234 static inline void mavlink_msg_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)
00235 {
00236 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
00237         char *buf = (char *)msgbuf;
00238         _mav_put_uint64_t(buf, 0, time_usec);
00239         _mav_put_float(buf, 8, flow_comp_m_x);
00240         _mav_put_float(buf, 12, flow_comp_m_y);
00241         _mav_put_float(buf, 16, ground_distance);
00242         _mav_put_int16_t(buf, 20, flow_x);
00243         _mav_put_int16_t(buf, 22, flow_y);
00244         _mav_put_uint8_t(buf, 24, sensor_id);
00245         _mav_put_uint8_t(buf, 25, quality);
00246 
00247 #if MAVLINK_CRC_EXTRA
00248     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00249 #else
00250     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00251 #endif
00252 #else
00253         mavlink_optical_flow_t *packet = (mavlink_optical_flow_t *)msgbuf;
00254         packet->time_usec = time_usec;
00255         packet->flow_comp_m_x = flow_comp_m_x;
00256         packet->flow_comp_m_y = flow_comp_m_y;
00257         packet->ground_distance = ground_distance;
00258         packet->flow_x = flow_x;
00259         packet->flow_y = flow_y;
00260         packet->sensor_id = sensor_id;
00261         packet->quality = quality;
00262 
00263 #if MAVLINK_CRC_EXTRA
00264     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_OPTICAL_FLOW_CRC);
00265 #else
00266     _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)packet, MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00267 #endif
00268 #endif
00269 }
00270 #endif
00271 
00272 #endif
00273 
00274 // MESSAGE OPTICAL_FLOW UNPACKING
00275 
00276 
00282 static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_message_t* msg)
00283 {
00284         return _MAV_RETURN_uint64_t(msg,  0);
00285 }
00286 
00292 static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t* msg)
00293 {
00294         return _MAV_RETURN_uint8_t(msg,  24);
00295 }
00296 
00302 static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t* msg)
00303 {
00304         return _MAV_RETURN_int16_t(msg,  20);
00305 }
00306 
00312 static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t* msg)
00313 {
00314         return _MAV_RETURN_int16_t(msg,  22);
00315 }
00316 
00322 static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t* msg)
00323 {
00324         return _MAV_RETURN_float(msg,  8);
00325 }
00326 
00332 static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t* msg)
00333 {
00334         return _MAV_RETURN_float(msg,  12);
00335 }
00336 
00342 static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t* msg)
00343 {
00344         return _MAV_RETURN_uint8_t(msg,  25);
00345 }
00346 
00352 static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t* msg)
00353 {
00354         return _MAV_RETURN_float(msg,  16);
00355 }
00356 
00363 static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t* msg, mavlink_optical_flow_t* optical_flow)
00364 {
00365 #if MAVLINK_NEED_BYTE_SWAP
00366         optical_flow->time_usec = mavlink_msg_optical_flow_get_time_usec(msg);
00367         optical_flow->flow_comp_m_x = mavlink_msg_optical_flow_get_flow_comp_m_x(msg);
00368         optical_flow->flow_comp_m_y = mavlink_msg_optical_flow_get_flow_comp_m_y(msg);
00369         optical_flow->ground_distance = mavlink_msg_optical_flow_get_ground_distance(msg);
00370         optical_flow->flow_x = mavlink_msg_optical_flow_get_flow_x(msg);
00371         optical_flow->flow_y = mavlink_msg_optical_flow_get_flow_y(msg);
00372         optical_flow->sensor_id = mavlink_msg_optical_flow_get_sensor_id(msg);
00373         optical_flow->quality = mavlink_msg_optical_flow_get_quality(msg);
00374 #else
00375         memcpy(optical_flow, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_OPTICAL_FLOW_LEN);
00376 #endif
00377 }


dji_sdk_dji2mav
Author(s):
autogenerated on Thu Jun 6 2019 17:55:35