mavlink_msg_hil_optical_flow.h 26 KB

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