2
0

mavlink_msg_vfr_hud.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. #pragma once
  2. // MESSAGE VFR_HUD PACKING
  3. #define MAVLINK_MSG_ID_VFR_HUD 74
  4. typedef struct __mavlink_vfr_hud_t {
  5. float airspeed; /*< [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.*/
  6. float groundspeed; /*< [m/s] Current ground speed.*/
  7. float alt; /*< [m] Current altitude (MSL).*/
  8. float climb; /*< [m/s] Current climb rate.*/
  9. int16_t heading; /*< [deg] Current heading in compass units (0-360, 0=north).*/
  10. uint16_t throttle; /*< [%] Current throttle setting (0 to 100).*/
  11. } mavlink_vfr_hud_t;
  12. #define MAVLINK_MSG_ID_VFR_HUD_LEN 20
  13. #define MAVLINK_MSG_ID_VFR_HUD_MIN_LEN 20
  14. #define MAVLINK_MSG_ID_74_LEN 20
  15. #define MAVLINK_MSG_ID_74_MIN_LEN 20
  16. #define MAVLINK_MSG_ID_VFR_HUD_CRC 20
  17. #define MAVLINK_MSG_ID_74_CRC 20
  18. #if MAVLINK_COMMAND_24BIT
  19. #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
  20. 74, \
  21. "VFR_HUD", \
  22. 6, \
  23. { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
  24. { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
  25. { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
  26. { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
  27. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
  28. { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
  29. } \
  30. }
  31. #else
  32. #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
  33. "VFR_HUD", \
  34. 6, \
  35. { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
  36. { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
  37. { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
  38. { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
  39. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
  40. { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
  41. } \
  42. }
  43. #endif
  44. /**
  45. * @brief Pack a vfr_hud message
  46. * @param system_id ID of this system
  47. * @param component_id ID of this component (e.g. 200 for IMU)
  48. * @param msg The MAVLink message to compress the data into
  49. *
  50. * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
  51. * @param groundspeed [m/s] Current ground speed.
  52. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  53. * @param throttle [%] Current throttle setting (0 to 100).
  54. * @param alt [m] Current altitude (MSL).
  55. * @param climb [m/s] Current climb rate.
  56. * @return length of the message in bytes (excluding serial stream start sign)
  57. */
  58. static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  59. float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  60. {
  61. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  62. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  63. _mav_put_float(buf, 0, airspeed);
  64. _mav_put_float(buf, 4, groundspeed);
  65. _mav_put_float(buf, 8, alt);
  66. _mav_put_float(buf, 12, climb);
  67. _mav_put_int16_t(buf, 16, heading);
  68. _mav_put_uint16_t(buf, 18, throttle);
  69. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
  70. #else
  71. mavlink_vfr_hud_t packet;
  72. packet.airspeed = airspeed;
  73. packet.groundspeed = groundspeed;
  74. packet.alt = alt;
  75. packet.climb = climb;
  76. packet.heading = heading;
  77. packet.throttle = throttle;
  78. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
  79. #endif
  80. msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
  81. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  82. }
  83. /**
  84. * @brief Pack a vfr_hud message
  85. * @param system_id ID of this system
  86. * @param component_id ID of this component (e.g. 200 for IMU)
  87. * @param status MAVLink status structure
  88. * @param msg The MAVLink message to compress the data into
  89. *
  90. * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
  91. * @param groundspeed [m/s] Current ground speed.
  92. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  93. * @param throttle [%] Current throttle setting (0 to 100).
  94. * @param alt [m] Current altitude (MSL).
  95. * @param climb [m/s] Current climb rate.
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_vfr_hud_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  99. float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  100. {
  101. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  102. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  103. _mav_put_float(buf, 0, airspeed);
  104. _mav_put_float(buf, 4, groundspeed);
  105. _mav_put_float(buf, 8, alt);
  106. _mav_put_float(buf, 12, climb);
  107. _mav_put_int16_t(buf, 16, heading);
  108. _mav_put_uint16_t(buf, 18, throttle);
  109. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
  110. #else
  111. mavlink_vfr_hud_t packet;
  112. packet.airspeed = airspeed;
  113. packet.groundspeed = groundspeed;
  114. packet.alt = alt;
  115. packet.climb = climb;
  116. packet.heading = heading;
  117. packet.throttle = throttle;
  118. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
  119. #endif
  120. msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
  121. #if MAVLINK_CRC_EXTRA
  122. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  123. #else
  124. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN);
  125. #endif
  126. }
  127. /**
  128. * @brief Pack a vfr_hud message on a channel
  129. * @param system_id ID of this system
  130. * @param component_id ID of this component (e.g. 200 for IMU)
  131. * @param chan The MAVLink channel this message will be sent over
  132. * @param msg The MAVLink message to compress the data into
  133. * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
  134. * @param groundspeed [m/s] Current ground speed.
  135. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  136. * @param throttle [%] Current throttle setting (0 to 100).
  137. * @param alt [m] Current altitude (MSL).
  138. * @param climb [m/s] Current climb rate.
  139. * @return length of the message in bytes (excluding serial stream start sign)
  140. */
  141. static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  142. mavlink_message_t* msg,
  143. float airspeed,float groundspeed,int16_t heading,uint16_t throttle,float alt,float climb)
  144. {
  145. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  146. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  147. _mav_put_float(buf, 0, airspeed);
  148. _mav_put_float(buf, 4, groundspeed);
  149. _mav_put_float(buf, 8, alt);
  150. _mav_put_float(buf, 12, climb);
  151. _mav_put_int16_t(buf, 16, heading);
  152. _mav_put_uint16_t(buf, 18, throttle);
  153. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
  154. #else
  155. mavlink_vfr_hud_t packet;
  156. packet.airspeed = airspeed;
  157. packet.groundspeed = groundspeed;
  158. packet.alt = alt;
  159. packet.climb = climb;
  160. packet.heading = heading;
  161. packet.throttle = throttle;
  162. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
  163. #endif
  164. msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
  165. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  166. }
  167. /**
  168. * @brief Encode a vfr_hud struct
  169. *
  170. * @param system_id ID of this system
  171. * @param component_id ID of this component (e.g. 200 for IMU)
  172. * @param msg The MAVLink message to compress the data into
  173. * @param vfr_hud C-struct to read the message contents from
  174. */
  175. static inline uint16_t mavlink_msg_vfr_hud_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
  176. {
  177. return mavlink_msg_vfr_hud_pack(system_id, component_id, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  178. }
  179. /**
  180. * @brief Encode a vfr_hud struct on a channel
  181. *
  182. * @param system_id ID of this system
  183. * @param component_id ID of this component (e.g. 200 for IMU)
  184. * @param chan The MAVLink channel this message will be sent over
  185. * @param msg The MAVLink message to compress the data into
  186. * @param vfr_hud C-struct to read the message contents from
  187. */
  188. static inline uint16_t mavlink_msg_vfr_hud_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
  189. {
  190. return mavlink_msg_vfr_hud_pack_chan(system_id, component_id, chan, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  191. }
  192. /**
  193. * @brief Encode a vfr_hud struct with provided status structure
  194. *
  195. * @param system_id ID of this system
  196. * @param component_id ID of this component (e.g. 200 for IMU)
  197. * @param status MAVLink status structure
  198. * @param msg The MAVLink message to compress the data into
  199. * @param vfr_hud C-struct to read the message contents from
  200. */
  201. static inline uint16_t mavlink_msg_vfr_hud_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
  202. {
  203. return mavlink_msg_vfr_hud_pack_status(system_id, component_id, _status, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  204. }
  205. /**
  206. * @brief Send a vfr_hud message
  207. * @param chan MAVLink channel to send the message
  208. *
  209. * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
  210. * @param groundspeed [m/s] Current ground speed.
  211. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  212. * @param throttle [%] Current throttle setting (0 to 100).
  213. * @param alt [m] Current altitude (MSL).
  214. * @param climb [m/s] Current climb rate.
  215. */
  216. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  217. static inline void mavlink_msg_vfr_hud_send(mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  218. {
  219. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  220. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  221. _mav_put_float(buf, 0, airspeed);
  222. _mav_put_float(buf, 4, groundspeed);
  223. _mav_put_float(buf, 8, alt);
  224. _mav_put_float(buf, 12, climb);
  225. _mav_put_int16_t(buf, 16, heading);
  226. _mav_put_uint16_t(buf, 18, throttle);
  227. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  228. #else
  229. mavlink_vfr_hud_t packet;
  230. packet.airspeed = airspeed;
  231. packet.groundspeed = groundspeed;
  232. packet.alt = alt;
  233. packet.climb = climb;
  234. packet.heading = heading;
  235. packet.throttle = throttle;
  236. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)&packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  237. #endif
  238. }
  239. /**
  240. * @brief Send a vfr_hud message
  241. * @param chan MAVLink channel to send the message
  242. * @param struct The MAVLink struct to serialize
  243. */
  244. static inline void mavlink_msg_vfr_hud_send_struct(mavlink_channel_t chan, const mavlink_vfr_hud_t* vfr_hud)
  245. {
  246. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  247. mavlink_msg_vfr_hud_send(chan, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  248. #else
  249. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)vfr_hud, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  250. #endif
  251. }
  252. #if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  253. /*
  254. This variant of _send() can be used to save stack space by re-using
  255. memory from the receive buffer. The caller provides a
  256. mavlink_message_t which is the size of a full mavlink message. This
  257. is usually the receive buffer for the channel, and allows a reply to an
  258. incoming message with minimum stack space usage.
  259. */
  260. static inline void mavlink_msg_vfr_hud_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  261. {
  262. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  263. char *buf = (char *)msgbuf;
  264. _mav_put_float(buf, 0, airspeed);
  265. _mav_put_float(buf, 4, groundspeed);
  266. _mav_put_float(buf, 8, alt);
  267. _mav_put_float(buf, 12, climb);
  268. _mav_put_int16_t(buf, 16, heading);
  269. _mav_put_uint16_t(buf, 18, throttle);
  270. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  271. #else
  272. mavlink_vfr_hud_t *packet = (mavlink_vfr_hud_t *)msgbuf;
  273. packet->airspeed = airspeed;
  274. packet->groundspeed = groundspeed;
  275. packet->alt = alt;
  276. packet->climb = climb;
  277. packet->heading = heading;
  278. packet->throttle = throttle;
  279. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  280. #endif
  281. }
  282. #endif
  283. #endif
  284. // MESSAGE VFR_HUD UNPACKING
  285. /**
  286. * @brief Get field airspeed from vfr_hud message
  287. *
  288. * @return [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
  289. */
  290. static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg)
  291. {
  292. return _MAV_RETURN_float(msg, 0);
  293. }
  294. /**
  295. * @brief Get field groundspeed from vfr_hud message
  296. *
  297. * @return [m/s] Current ground speed.
  298. */
  299. static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg)
  300. {
  301. return _MAV_RETURN_float(msg, 4);
  302. }
  303. /**
  304. * @brief Get field heading from vfr_hud message
  305. *
  306. * @return [deg] Current heading in compass units (0-360, 0=north).
  307. */
  308. static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg)
  309. {
  310. return _MAV_RETURN_int16_t(msg, 16);
  311. }
  312. /**
  313. * @brief Get field throttle from vfr_hud message
  314. *
  315. * @return [%] Current throttle setting (0 to 100).
  316. */
  317. static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg)
  318. {
  319. return _MAV_RETURN_uint16_t(msg, 18);
  320. }
  321. /**
  322. * @brief Get field alt from vfr_hud message
  323. *
  324. * @return [m] Current altitude (MSL).
  325. */
  326. static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg)
  327. {
  328. return _MAV_RETURN_float(msg, 8);
  329. }
  330. /**
  331. * @brief Get field climb from vfr_hud message
  332. *
  333. * @return [m/s] Current climb rate.
  334. */
  335. static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg)
  336. {
  337. return _MAV_RETURN_float(msg, 12);
  338. }
  339. /**
  340. * @brief Decode a vfr_hud message into a struct
  341. *
  342. * @param msg The message to decode
  343. * @param vfr_hud C-struct to decode the message contents into
  344. */
  345. static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud)
  346. {
  347. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  348. vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg);
  349. vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg);
  350. vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg);
  351. vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg);
  352. vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg);
  353. vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg);
  354. #else
  355. uint8_t len = msg->len < MAVLINK_MSG_ID_VFR_HUD_LEN? msg->len : MAVLINK_MSG_ID_VFR_HUD_LEN;
  356. memset(vfr_hud, 0, MAVLINK_MSG_ID_VFR_HUD_LEN);
  357. memcpy(vfr_hud, _MAV_PAYLOAD(msg), len);
  358. #endif
  359. }