mavlink_msg_hil_optical_flow.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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
  121. * @param system_id ID of this system
  122. * @param component_id ID of this component (e.g. 200 for IMU)
  123. * @param status MAVLink status structure
  124. * @param msg The MAVLink message to compress the data into
  125. *
  126. * @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.
  127. * @param sensor_id Sensor ID
  128. * @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.
  129. * @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.)
  130. * @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.)
  131. * @param integrated_xgyro [rad] RH rotation around X axis
  132. * @param integrated_ygyro [rad] RH rotation around Y axis
  133. * @param integrated_zgyro [rad] RH rotation around Z axis
  134. * @param temperature [cdegC] Temperature
  135. * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
  136. * @param time_delta_distance_us [us] Time since the distance was sampled.
  137. * @param distance [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance.
  138. * @return length of the message in bytes (excluding serial stream start sign)
  139. */
  140. static inline uint16_t mavlink_msg_hil_optical_flow_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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. #if MAVLINK_CRC_EXTRA
  176. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_CRC);
  177. #else
  178. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_MIN_LEN, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
  179. #endif
  180. }
  181. /**
  182. * @brief Pack a hil_optical_flow message on a channel
  183. * @param system_id ID of this system
  184. * @param component_id ID of this component (e.g. 200 for IMU)
  185. * @param chan The MAVLink channel this message will be sent over
  186. * @param msg The MAVLink message to compress the data into
  187. * @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.
  188. * @param sensor_id Sensor ID
  189. * @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.
  190. * @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.)
  191. * @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.)
  192. * @param integrated_xgyro [rad] RH rotation around X axis
  193. * @param integrated_ygyro [rad] RH rotation around Y axis
  194. * @param integrated_zgyro [rad] RH rotation around Z axis
  195. * @param temperature [cdegC] Temperature
  196. * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
  197. * @param time_delta_distance_us [us] Time since the distance was sampled.
  198. * @param distance [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance.
  199. * @return length of the message in bytes (excluding serial stream start sign)
  200. */
  201. static inline uint16_t mavlink_msg_hil_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  202. mavlink_message_t* msg,
  203. 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)
  204. {
  205. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  206. char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
  207. _mav_put_uint64_t(buf, 0, time_usec);
  208. _mav_put_uint32_t(buf, 8, integration_time_us);
  209. _mav_put_float(buf, 12, integrated_x);
  210. _mav_put_float(buf, 16, integrated_y);
  211. _mav_put_float(buf, 20, integrated_xgyro);
  212. _mav_put_float(buf, 24, integrated_ygyro);
  213. _mav_put_float(buf, 28, integrated_zgyro);
  214. _mav_put_uint32_t(buf, 32, time_delta_distance_us);
  215. _mav_put_float(buf, 36, distance);
  216. _mav_put_int16_t(buf, 40, temperature);
  217. _mav_put_uint8_t(buf, 42, sensor_id);
  218. _mav_put_uint8_t(buf, 43, quality);
  219. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
  220. #else
  221. mavlink_hil_optical_flow_t packet;
  222. packet.time_usec = time_usec;
  223. packet.integration_time_us = integration_time_us;
  224. packet.integrated_x = integrated_x;
  225. packet.integrated_y = integrated_y;
  226. packet.integrated_xgyro = integrated_xgyro;
  227. packet.integrated_ygyro = integrated_ygyro;
  228. packet.integrated_zgyro = integrated_zgyro;
  229. packet.time_delta_distance_us = time_delta_distance_us;
  230. packet.distance = distance;
  231. packet.temperature = temperature;
  232. packet.sensor_id = sensor_id;
  233. packet.quality = quality;
  234. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
  235. #endif
  236. msg->msgid = MAVLINK_MSG_ID_HIL_OPTICAL_FLOW;
  237. 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);
  238. }
  239. /**
  240. * @brief Encode a hil_optical_flow struct
  241. *
  242. * @param system_id ID of this system
  243. * @param component_id ID of this component (e.g. 200 for IMU)
  244. * @param msg The MAVLink message to compress the data into
  245. * @param hil_optical_flow C-struct to read the message contents from
  246. */
  247. 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)
  248. {
  249. 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);
  250. }
  251. /**
  252. * @brief Encode a hil_optical_flow struct on a channel
  253. *
  254. * @param system_id ID of this system
  255. * @param component_id ID of this component (e.g. 200 for IMU)
  256. * @param chan The MAVLink channel this message will be sent over
  257. * @param msg The MAVLink message to compress the data into
  258. * @param hil_optical_flow C-struct to read the message contents from
  259. */
  260. 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)
  261. {
  262. 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);
  263. }
  264. /**
  265. * @brief Encode a hil_optical_flow struct with provided status structure
  266. *
  267. * @param system_id ID of this system
  268. * @param component_id ID of this component (e.g. 200 for IMU)
  269. * @param status MAVLink status structure
  270. * @param msg The MAVLink message to compress the data into
  271. * @param hil_optical_flow C-struct to read the message contents from
  272. */
  273. static inline uint16_t mavlink_msg_hil_optical_flow_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_optical_flow_t* hil_optical_flow)
  274. {
  275. return mavlink_msg_hil_optical_flow_pack_status(system_id, component_id, _status, 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);
  276. }
  277. /**
  278. * @brief Send a hil_optical_flow message
  279. * @param chan MAVLink channel to send the message
  280. *
  281. * @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.
  282. * @param sensor_id Sensor ID
  283. * @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.
  284. * @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.)
  285. * @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.)
  286. * @param integrated_xgyro [rad] RH rotation around X axis
  287. * @param integrated_ygyro [rad] RH rotation around Y axis
  288. * @param integrated_zgyro [rad] RH rotation around Z axis
  289. * @param temperature [cdegC] Temperature
  290. * @param quality Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
  291. * @param time_delta_distance_us [us] Time since the distance was sampled.
  292. * @param distance [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance.
  293. */
  294. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  295. 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)
  296. {
  297. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  298. char buf[MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN];
  299. _mav_put_uint64_t(buf, 0, time_usec);
  300. _mav_put_uint32_t(buf, 8, integration_time_us);
  301. _mav_put_float(buf, 12, integrated_x);
  302. _mav_put_float(buf, 16, integrated_y);
  303. _mav_put_float(buf, 20, integrated_xgyro);
  304. _mav_put_float(buf, 24, integrated_ygyro);
  305. _mav_put_float(buf, 28, integrated_zgyro);
  306. _mav_put_uint32_t(buf, 32, time_delta_distance_us);
  307. _mav_put_float(buf, 36, distance);
  308. _mav_put_int16_t(buf, 40, temperature);
  309. _mav_put_uint8_t(buf, 42, sensor_id);
  310. _mav_put_uint8_t(buf, 43, quality);
  311. _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);
  312. #else
  313. mavlink_hil_optical_flow_t packet;
  314. packet.time_usec = time_usec;
  315. packet.integration_time_us = integration_time_us;
  316. packet.integrated_x = integrated_x;
  317. packet.integrated_y = integrated_y;
  318. packet.integrated_xgyro = integrated_xgyro;
  319. packet.integrated_ygyro = integrated_ygyro;
  320. packet.integrated_zgyro = integrated_zgyro;
  321. packet.time_delta_distance_us = time_delta_distance_us;
  322. packet.distance = distance;
  323. packet.temperature = temperature;
  324. packet.sensor_id = sensor_id;
  325. packet.quality = quality;
  326. _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);
  327. #endif
  328. }
  329. /**
  330. * @brief Send a hil_optical_flow message
  331. * @param chan MAVLink channel to send the message
  332. * @param struct The MAVLink struct to serialize
  333. */
  334. static inline void mavlink_msg_hil_optical_flow_send_struct(mavlink_channel_t chan, const mavlink_hil_optical_flow_t* hil_optical_flow)
  335. {
  336. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  337. 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);
  338. #else
  339. _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);
  340. #endif
  341. }
  342. #if MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  343. /*
  344. This variant of _send() can be used to save stack space by re-using
  345. memory from the receive buffer. The caller provides a
  346. mavlink_message_t which is the size of a full mavlink message. This
  347. is usually the receive buffer for the channel, and allows a reply to an
  348. incoming message with minimum stack space usage.
  349. */
  350. 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)
  351. {
  352. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  353. char *buf = (char *)msgbuf;
  354. _mav_put_uint64_t(buf, 0, time_usec);
  355. _mav_put_uint32_t(buf, 8, integration_time_us);
  356. _mav_put_float(buf, 12, integrated_x);
  357. _mav_put_float(buf, 16, integrated_y);
  358. _mav_put_float(buf, 20, integrated_xgyro);
  359. _mav_put_float(buf, 24, integrated_ygyro);
  360. _mav_put_float(buf, 28, integrated_zgyro);
  361. _mav_put_uint32_t(buf, 32, time_delta_distance_us);
  362. _mav_put_float(buf, 36, distance);
  363. _mav_put_int16_t(buf, 40, temperature);
  364. _mav_put_uint8_t(buf, 42, sensor_id);
  365. _mav_put_uint8_t(buf, 43, quality);
  366. _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);
  367. #else
  368. mavlink_hil_optical_flow_t *packet = (mavlink_hil_optical_flow_t *)msgbuf;
  369. packet->time_usec = time_usec;
  370. packet->integration_time_us = integration_time_us;
  371. packet->integrated_x = integrated_x;
  372. packet->integrated_y = integrated_y;
  373. packet->integrated_xgyro = integrated_xgyro;
  374. packet->integrated_ygyro = integrated_ygyro;
  375. packet->integrated_zgyro = integrated_zgyro;
  376. packet->time_delta_distance_us = time_delta_distance_us;
  377. packet->distance = distance;
  378. packet->temperature = temperature;
  379. packet->sensor_id = sensor_id;
  380. packet->quality = quality;
  381. _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);
  382. #endif
  383. }
  384. #endif
  385. #endif
  386. // MESSAGE HIL_OPTICAL_FLOW UNPACKING
  387. /**
  388. * @brief Get field time_usec from hil_optical_flow message
  389. *
  390. * @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.
  391. */
  392. static inline uint64_t mavlink_msg_hil_optical_flow_get_time_usec(const mavlink_message_t* msg)
  393. {
  394. return _MAV_RETURN_uint64_t(msg, 0);
  395. }
  396. /**
  397. * @brief Get field sensor_id from hil_optical_flow message
  398. *
  399. * @return Sensor ID
  400. */
  401. static inline uint8_t mavlink_msg_hil_optical_flow_get_sensor_id(const mavlink_message_t* msg)
  402. {
  403. return _MAV_RETURN_uint8_t(msg, 42);
  404. }
  405. /**
  406. * @brief Get field integration_time_us from hil_optical_flow message
  407. *
  408. * @return [us] Integration time. Divide integrated_x and integrated_y by the integration time to obtain average flow. The integration time also indicates the.
  409. */
  410. static inline uint32_t mavlink_msg_hil_optical_flow_get_integration_time_us(const mavlink_message_t* msg)
  411. {
  412. return _MAV_RETURN_uint32_t(msg, 8);
  413. }
  414. /**
  415. * @brief Get field integrated_x from hil_optical_flow message
  416. *
  417. * @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.)
  418. */
  419. static inline float mavlink_msg_hil_optical_flow_get_integrated_x(const mavlink_message_t* msg)
  420. {
  421. return _MAV_RETURN_float(msg, 12);
  422. }
  423. /**
  424. * @brief Get field integrated_y from hil_optical_flow message
  425. *
  426. * @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.)
  427. */
  428. static inline float mavlink_msg_hil_optical_flow_get_integrated_y(const mavlink_message_t* msg)
  429. {
  430. return _MAV_RETURN_float(msg, 16);
  431. }
  432. /**
  433. * @brief Get field integrated_xgyro from hil_optical_flow message
  434. *
  435. * @return [rad] RH rotation around X axis
  436. */
  437. static inline float mavlink_msg_hil_optical_flow_get_integrated_xgyro(const mavlink_message_t* msg)
  438. {
  439. return _MAV_RETURN_float(msg, 20);
  440. }
  441. /**
  442. * @brief Get field integrated_ygyro from hil_optical_flow message
  443. *
  444. * @return [rad] RH rotation around Y axis
  445. */
  446. static inline float mavlink_msg_hil_optical_flow_get_integrated_ygyro(const mavlink_message_t* msg)
  447. {
  448. return _MAV_RETURN_float(msg, 24);
  449. }
  450. /**
  451. * @brief Get field integrated_zgyro from hil_optical_flow message
  452. *
  453. * @return [rad] RH rotation around Z axis
  454. */
  455. static inline float mavlink_msg_hil_optical_flow_get_integrated_zgyro(const mavlink_message_t* msg)
  456. {
  457. return _MAV_RETURN_float(msg, 28);
  458. }
  459. /**
  460. * @brief Get field temperature from hil_optical_flow message
  461. *
  462. * @return [cdegC] Temperature
  463. */
  464. static inline int16_t mavlink_msg_hil_optical_flow_get_temperature(const mavlink_message_t* msg)
  465. {
  466. return _MAV_RETURN_int16_t(msg, 40);
  467. }
  468. /**
  469. * @brief Get field quality from hil_optical_flow message
  470. *
  471. * @return Optical flow quality / confidence. 0: no valid flow, 255: maximum quality
  472. */
  473. static inline uint8_t mavlink_msg_hil_optical_flow_get_quality(const mavlink_message_t* msg)
  474. {
  475. return _MAV_RETURN_uint8_t(msg, 43);
  476. }
  477. /**
  478. * @brief Get field time_delta_distance_us from hil_optical_flow message
  479. *
  480. * @return [us] Time since the distance was sampled.
  481. */
  482. static inline uint32_t mavlink_msg_hil_optical_flow_get_time_delta_distance_us(const mavlink_message_t* msg)
  483. {
  484. return _MAV_RETURN_uint32_t(msg, 32);
  485. }
  486. /**
  487. * @brief Get field distance from hil_optical_flow message
  488. *
  489. * @return [m] Distance to the center of the flow field. Positive value (including zero): distance known. Negative value: Unknown distance.
  490. */
  491. static inline float mavlink_msg_hil_optical_flow_get_distance(const mavlink_message_t* msg)
  492. {
  493. return _MAV_RETURN_float(msg, 36);
  494. }
  495. /**
  496. * @brief Decode a hil_optical_flow message into a struct
  497. *
  498. * @param msg The message to decode
  499. * @param hil_optical_flow C-struct to decode the message contents into
  500. */
  501. static inline void mavlink_msg_hil_optical_flow_decode(const mavlink_message_t* msg, mavlink_hil_optical_flow_t* hil_optical_flow)
  502. {
  503. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  504. hil_optical_flow->time_usec = mavlink_msg_hil_optical_flow_get_time_usec(msg);
  505. hil_optical_flow->integration_time_us = mavlink_msg_hil_optical_flow_get_integration_time_us(msg);
  506. hil_optical_flow->integrated_x = mavlink_msg_hil_optical_flow_get_integrated_x(msg);
  507. hil_optical_flow->integrated_y = mavlink_msg_hil_optical_flow_get_integrated_y(msg);
  508. hil_optical_flow->integrated_xgyro = mavlink_msg_hil_optical_flow_get_integrated_xgyro(msg);
  509. hil_optical_flow->integrated_ygyro = mavlink_msg_hil_optical_flow_get_integrated_ygyro(msg);
  510. hil_optical_flow->integrated_zgyro = mavlink_msg_hil_optical_flow_get_integrated_zgyro(msg);
  511. hil_optical_flow->time_delta_distance_us = mavlink_msg_hil_optical_flow_get_time_delta_distance_us(msg);
  512. hil_optical_flow->distance = mavlink_msg_hil_optical_flow_get_distance(msg);
  513. hil_optical_flow->temperature = mavlink_msg_hil_optical_flow_get_temperature(msg);
  514. hil_optical_flow->sensor_id = mavlink_msg_hil_optical_flow_get_sensor_id(msg);
  515. hil_optical_flow->quality = mavlink_msg_hil_optical_flow_get_quality(msg);
  516. #else
  517. uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN? msg->len : MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN;
  518. memset(hil_optical_flow, 0, MAVLINK_MSG_ID_HIL_OPTICAL_FLOW_LEN);
  519. memcpy(hil_optical_flow, _MAV_PAYLOAD(msg), len);
  520. #endif
  521. }