/mavlink/include/common/mavlink_msg_hil_controls.h

https://github.com/flixr/mavlink-ivy-interface · C Header · 364 lines · 204 code · 35 blank · 125 comment · 3 complexity · 6ec4c88318ae77a3fb252820dd886425 MD5 · raw file

  1. // MESSAGE HIL_CONTROLS PACKING
  2. #define MAVLINK_MSG_ID_HIL_CONTROLS 91
  3. typedef struct __mavlink_hil_controls_t
  4. {
  5. uint64_t time_usec; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
  6. float roll_ailerons; ///< Control output -1 .. 1
  7. float pitch_elevator; ///< Control output -1 .. 1
  8. float yaw_rudder; ///< Control output -1 .. 1
  9. float throttle; ///< Throttle 0 .. 1
  10. float aux1; ///< Aux 1, -1 .. 1
  11. float aux2; ///< Aux 2, -1 .. 1
  12. float aux3; ///< Aux 3, -1 .. 1
  13. float aux4; ///< Aux 4, -1 .. 1
  14. uint8_t mode; ///< System mode (MAV_MODE)
  15. uint8_t nav_mode; ///< Navigation mode (MAV_NAV_MODE)
  16. } mavlink_hil_controls_t;
  17. #define MAVLINK_MSG_ID_HIL_CONTROLS_LEN 42
  18. #define MAVLINK_MSG_ID_91_LEN 42
  19. #define MAVLINK_MESSAGE_INFO_HIL_CONTROLS { \
  20. "HIL_CONTROLS", \
  21. 11, \
  22. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_controls_t, time_usec) }, \
  23. { "roll_ailerons", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_controls_t, roll_ailerons) }, \
  24. { "pitch_elevator", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_controls_t, pitch_elevator) }, \
  25. { "yaw_rudder", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_controls_t, yaw_rudder) }, \
  26. { "throttle", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_controls_t, throttle) }, \
  27. { "aux1", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_controls_t, aux1) }, \
  28. { "aux2", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_controls_t, aux2) }, \
  29. { "aux3", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_controls_t, aux3) }, \
  30. { "aux4", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_controls_t, aux4) }, \
  31. { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_hil_controls_t, mode) }, \
  32. { "nav_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_hil_controls_t, nav_mode) }, \
  33. } \
  34. }
  35. /**
  36. * @brief Pack a hil_controls message
  37. * @param system_id ID of this system
  38. * @param component_id ID of this component (e.g. 200 for IMU)
  39. * @param msg The MAVLink message to compress the data into
  40. *
  41. * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
  42. * @param roll_ailerons Control output -1 .. 1
  43. * @param pitch_elevator Control output -1 .. 1
  44. * @param yaw_rudder Control output -1 .. 1
  45. * @param throttle Throttle 0 .. 1
  46. * @param aux1 Aux 1, -1 .. 1
  47. * @param aux2 Aux 2, -1 .. 1
  48. * @param aux3 Aux 3, -1 .. 1
  49. * @param aux4 Aux 4, -1 .. 1
  50. * @param mode System mode (MAV_MODE)
  51. * @param nav_mode Navigation mode (MAV_NAV_MODE)
  52. * @return length of the message in bytes (excluding serial stream start sign)
  53. */
  54. static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  55. uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode)
  56. {
  57. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  58. char buf[42];
  59. _mav_put_uint64_t(buf, 0, time_usec);
  60. _mav_put_float(buf, 8, roll_ailerons);
  61. _mav_put_float(buf, 12, pitch_elevator);
  62. _mav_put_float(buf, 16, yaw_rudder);
  63. _mav_put_float(buf, 20, throttle);
  64. _mav_put_float(buf, 24, aux1);
  65. _mav_put_float(buf, 28, aux2);
  66. _mav_put_float(buf, 32, aux3);
  67. _mav_put_float(buf, 36, aux4);
  68. _mav_put_uint8_t(buf, 40, mode);
  69. _mav_put_uint8_t(buf, 41, nav_mode);
  70. memcpy(_MAV_PAYLOAD(msg), buf, 42);
  71. #else
  72. mavlink_hil_controls_t packet;
  73. packet.time_usec = time_usec;
  74. packet.roll_ailerons = roll_ailerons;
  75. packet.pitch_elevator = pitch_elevator;
  76. packet.yaw_rudder = yaw_rudder;
  77. packet.throttle = throttle;
  78. packet.aux1 = aux1;
  79. packet.aux2 = aux2;
  80. packet.aux3 = aux3;
  81. packet.aux4 = aux4;
  82. packet.mode = mode;
  83. packet.nav_mode = nav_mode;
  84. memcpy(_MAV_PAYLOAD(msg), &packet, 42);
  85. #endif
  86. msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
  87. return mavlink_finalize_message(msg, system_id, component_id, 42, 63);
  88. }
  89. /**
  90. * @brief Pack a hil_controls message on a channel
  91. * @param system_id ID of this system
  92. * @param component_id ID of this component (e.g. 200 for IMU)
  93. * @param chan The MAVLink channel this message was sent over
  94. * @param msg The MAVLink message to compress the data into
  95. * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
  96. * @param roll_ailerons Control output -1 .. 1
  97. * @param pitch_elevator Control output -1 .. 1
  98. * @param yaw_rudder Control output -1 .. 1
  99. * @param throttle Throttle 0 .. 1
  100. * @param aux1 Aux 1, -1 .. 1
  101. * @param aux2 Aux 2, -1 .. 1
  102. * @param aux3 Aux 3, -1 .. 1
  103. * @param aux4 Aux 4, -1 .. 1
  104. * @param mode System mode (MAV_MODE)
  105. * @param nav_mode Navigation mode (MAV_NAV_MODE)
  106. * @return length of the message in bytes (excluding serial stream start sign)
  107. */
  108. static inline uint16_t mavlink_msg_hil_controls_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  109. mavlink_message_t* msg,
  110. uint64_t time_usec,float roll_ailerons,float pitch_elevator,float yaw_rudder,float throttle,float aux1,float aux2,float aux3,float aux4,uint8_t mode,uint8_t nav_mode)
  111. {
  112. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  113. char buf[42];
  114. _mav_put_uint64_t(buf, 0, time_usec);
  115. _mav_put_float(buf, 8, roll_ailerons);
  116. _mav_put_float(buf, 12, pitch_elevator);
  117. _mav_put_float(buf, 16, yaw_rudder);
  118. _mav_put_float(buf, 20, throttle);
  119. _mav_put_float(buf, 24, aux1);
  120. _mav_put_float(buf, 28, aux2);
  121. _mav_put_float(buf, 32, aux3);
  122. _mav_put_float(buf, 36, aux4);
  123. _mav_put_uint8_t(buf, 40, mode);
  124. _mav_put_uint8_t(buf, 41, nav_mode);
  125. memcpy(_MAV_PAYLOAD(msg), buf, 42);
  126. #else
  127. mavlink_hil_controls_t packet;
  128. packet.time_usec = time_usec;
  129. packet.roll_ailerons = roll_ailerons;
  130. packet.pitch_elevator = pitch_elevator;
  131. packet.yaw_rudder = yaw_rudder;
  132. packet.throttle = throttle;
  133. packet.aux1 = aux1;
  134. packet.aux2 = aux2;
  135. packet.aux3 = aux3;
  136. packet.aux4 = aux4;
  137. packet.mode = mode;
  138. packet.nav_mode = nav_mode;
  139. memcpy(_MAV_PAYLOAD(msg), &packet, 42);
  140. #endif
  141. msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS;
  142. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 63);
  143. }
  144. /**
  145. * @brief Encode a hil_controls struct into a message
  146. *
  147. * @param system_id ID of this system
  148. * @param component_id ID of this component (e.g. 200 for IMU)
  149. * @param msg The MAVLink message to compress the data into
  150. * @param hil_controls C-struct to read the message contents from
  151. */
  152. static inline uint16_t mavlink_msg_hil_controls_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_controls_t* hil_controls)
  153. {
  154. return mavlink_msg_hil_controls_pack(system_id, component_id, msg, hil_controls->time_usec, hil_controls->roll_ailerons, hil_controls->pitch_elevator, hil_controls->yaw_rudder, hil_controls->throttle, hil_controls->aux1, hil_controls->aux2, hil_controls->aux3, hil_controls->aux4, hil_controls->mode, hil_controls->nav_mode);
  155. }
  156. /**
  157. * @brief Send a hil_controls message
  158. * @param chan MAVLink channel to send the message
  159. *
  160. * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
  161. * @param roll_ailerons Control output -1 .. 1
  162. * @param pitch_elevator Control output -1 .. 1
  163. * @param yaw_rudder Control output -1 .. 1
  164. * @param throttle Throttle 0 .. 1
  165. * @param aux1 Aux 1, -1 .. 1
  166. * @param aux2 Aux 2, -1 .. 1
  167. * @param aux3 Aux 3, -1 .. 1
  168. * @param aux4 Aux 4, -1 .. 1
  169. * @param mode System mode (MAV_MODE)
  170. * @param nav_mode Navigation mode (MAV_NAV_MODE)
  171. */
  172. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  173. static inline void mavlink_msg_hil_controls_send(mavlink_channel_t chan, uint64_t time_usec, float roll_ailerons, float pitch_elevator, float yaw_rudder, float throttle, float aux1, float aux2, float aux3, float aux4, uint8_t mode, uint8_t nav_mode)
  174. {
  175. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  176. char buf[42];
  177. _mav_put_uint64_t(buf, 0, time_usec);
  178. _mav_put_float(buf, 8, roll_ailerons);
  179. _mav_put_float(buf, 12, pitch_elevator);
  180. _mav_put_float(buf, 16, yaw_rudder);
  181. _mav_put_float(buf, 20, throttle);
  182. _mav_put_float(buf, 24, aux1);
  183. _mav_put_float(buf, 28, aux2);
  184. _mav_put_float(buf, 32, aux3);
  185. _mav_put_float(buf, 36, aux4);
  186. _mav_put_uint8_t(buf, 40, mode);
  187. _mav_put_uint8_t(buf, 41, nav_mode);
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, buf, 42, 63);
  189. #else
  190. mavlink_hil_controls_t packet;
  191. packet.time_usec = time_usec;
  192. packet.roll_ailerons = roll_ailerons;
  193. packet.pitch_elevator = pitch_elevator;
  194. packet.yaw_rudder = yaw_rudder;
  195. packet.throttle = throttle;
  196. packet.aux1 = aux1;
  197. packet.aux2 = aux2;
  198. packet.aux3 = aux3;
  199. packet.aux4 = aux4;
  200. packet.mode = mode;
  201. packet.nav_mode = nav_mode;
  202. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_CONTROLS, (const char *)&packet, 42, 63);
  203. #endif
  204. }
  205. #endif
  206. // MESSAGE HIL_CONTROLS UNPACKING
  207. /**
  208. * @brief Get field time_usec from hil_controls message
  209. *
  210. * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
  211. */
  212. static inline uint64_t mavlink_msg_hil_controls_get_time_usec(const mavlink_message_t* msg)
  213. {
  214. return _MAV_RETURN_uint64_t(msg, 0);
  215. }
  216. /**
  217. * @brief Get field roll_ailerons from hil_controls message
  218. *
  219. * @return Control output -1 .. 1
  220. */
  221. static inline float mavlink_msg_hil_controls_get_roll_ailerons(const mavlink_message_t* msg)
  222. {
  223. return _MAV_RETURN_float(msg, 8);
  224. }
  225. /**
  226. * @brief Get field pitch_elevator from hil_controls message
  227. *
  228. * @return Control output -1 .. 1
  229. */
  230. static inline float mavlink_msg_hil_controls_get_pitch_elevator(const mavlink_message_t* msg)
  231. {
  232. return _MAV_RETURN_float(msg, 12);
  233. }
  234. /**
  235. * @brief Get field yaw_rudder from hil_controls message
  236. *
  237. * @return Control output -1 .. 1
  238. */
  239. static inline float mavlink_msg_hil_controls_get_yaw_rudder(const mavlink_message_t* msg)
  240. {
  241. return _MAV_RETURN_float(msg, 16);
  242. }
  243. /**
  244. * @brief Get field throttle from hil_controls message
  245. *
  246. * @return Throttle 0 .. 1
  247. */
  248. static inline float mavlink_msg_hil_controls_get_throttle(const mavlink_message_t* msg)
  249. {
  250. return _MAV_RETURN_float(msg, 20);
  251. }
  252. /**
  253. * @brief Get field aux1 from hil_controls message
  254. *
  255. * @return Aux 1, -1 .. 1
  256. */
  257. static inline float mavlink_msg_hil_controls_get_aux1(const mavlink_message_t* msg)
  258. {
  259. return _MAV_RETURN_float(msg, 24);
  260. }
  261. /**
  262. * @brief Get field aux2 from hil_controls message
  263. *
  264. * @return Aux 2, -1 .. 1
  265. */
  266. static inline float mavlink_msg_hil_controls_get_aux2(const mavlink_message_t* msg)
  267. {
  268. return _MAV_RETURN_float(msg, 28);
  269. }
  270. /**
  271. * @brief Get field aux3 from hil_controls message
  272. *
  273. * @return Aux 3, -1 .. 1
  274. */
  275. static inline float mavlink_msg_hil_controls_get_aux3(const mavlink_message_t* msg)
  276. {
  277. return _MAV_RETURN_float(msg, 32);
  278. }
  279. /**
  280. * @brief Get field aux4 from hil_controls message
  281. *
  282. * @return Aux 4, -1 .. 1
  283. */
  284. static inline float mavlink_msg_hil_controls_get_aux4(const mavlink_message_t* msg)
  285. {
  286. return _MAV_RETURN_float(msg, 36);
  287. }
  288. /**
  289. * @brief Get field mode from hil_controls message
  290. *
  291. * @return System mode (MAV_MODE)
  292. */
  293. static inline uint8_t mavlink_msg_hil_controls_get_mode(const mavlink_message_t* msg)
  294. {
  295. return _MAV_RETURN_uint8_t(msg, 40);
  296. }
  297. /**
  298. * @brief Get field nav_mode from hil_controls message
  299. *
  300. * @return Navigation mode (MAV_NAV_MODE)
  301. */
  302. static inline uint8_t mavlink_msg_hil_controls_get_nav_mode(const mavlink_message_t* msg)
  303. {
  304. return _MAV_RETURN_uint8_t(msg, 41);
  305. }
  306. /**
  307. * @brief Decode a hil_controls message into a struct
  308. *
  309. * @param msg The message to decode
  310. * @param hil_controls C-struct to decode the message contents into
  311. */
  312. static inline void mavlink_msg_hil_controls_decode(const mavlink_message_t* msg, mavlink_hil_controls_t* hil_controls)
  313. {
  314. #if MAVLINK_NEED_BYTE_SWAP
  315. hil_controls->time_usec = mavlink_msg_hil_controls_get_time_usec(msg);
  316. hil_controls->roll_ailerons = mavlink_msg_hil_controls_get_roll_ailerons(msg);
  317. hil_controls->pitch_elevator = mavlink_msg_hil_controls_get_pitch_elevator(msg);
  318. hil_controls->yaw_rudder = mavlink_msg_hil_controls_get_yaw_rudder(msg);
  319. hil_controls->throttle = mavlink_msg_hil_controls_get_throttle(msg);
  320. hil_controls->aux1 = mavlink_msg_hil_controls_get_aux1(msg);
  321. hil_controls->aux2 = mavlink_msg_hil_controls_get_aux2(msg);
  322. hil_controls->aux3 = mavlink_msg_hil_controls_get_aux3(msg);
  323. hil_controls->aux4 = mavlink_msg_hil_controls_get_aux4(msg);
  324. hil_controls->mode = mavlink_msg_hil_controls_get_mode(msg);
  325. hil_controls->nav_mode = mavlink_msg_hil_controls_get_nav_mode(msg);
  326. #else
  327. memcpy(hil_controls, _MAV_PAYLOAD(msg), 42);
  328. #endif
  329. }