mavlink_msg_hil_state.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. #pragma once
  2. // MESSAGE HIL_STATE PACKING
  3. #define MAVLINK_MSG_ID_HIL_STATE 90
  4. typedef struct __mavlink_hil_state_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. float roll; /*< [rad] Roll angle*/
  7. float pitch; /*< [rad] Pitch angle*/
  8. float yaw; /*< [rad] Yaw angle*/
  9. float rollspeed; /*< [rad/s] Body frame roll / phi angular speed*/
  10. float pitchspeed; /*< [rad/s] Body frame pitch / theta angular speed*/
  11. float yawspeed; /*< [rad/s] Body frame yaw / psi angular speed*/
  12. int32_t lat; /*< [degE7] Latitude*/
  13. int32_t lon; /*< [degE7] Longitude*/
  14. int32_t alt; /*< [mm] Altitude*/
  15. int16_t vx; /*< [cm/s] Ground X Speed (Latitude)*/
  16. int16_t vy; /*< [cm/s] Ground Y Speed (Longitude)*/
  17. int16_t vz; /*< [cm/s] Ground Z Speed (Altitude)*/
  18. int16_t xacc; /*< [mG] X acceleration*/
  19. int16_t yacc; /*< [mG] Y acceleration*/
  20. int16_t zacc; /*< [mG] Z acceleration*/
  21. } mavlink_hil_state_t;
  22. #define MAVLINK_MSG_ID_HIL_STATE_LEN 56
  23. #define MAVLINK_MSG_ID_HIL_STATE_MIN_LEN 56
  24. #define MAVLINK_MSG_ID_90_LEN 56
  25. #define MAVLINK_MSG_ID_90_MIN_LEN 56
  26. #define MAVLINK_MSG_ID_HIL_STATE_CRC 183
  27. #define MAVLINK_MSG_ID_90_CRC 183
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_HIL_STATE { \
  30. 90, \
  31. "HIL_STATE", \
  32. 16, \
  33. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_state_t, time_usec) }, \
  34. { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_state_t, roll) }, \
  35. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_state_t, pitch) }, \
  36. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_state_t, yaw) }, \
  37. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_state_t, rollspeed) }, \
  38. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_state_t, pitchspeed) }, \
  39. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_state_t, yawspeed) }, \
  40. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_hil_state_t, lat) }, \
  41. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_hil_state_t, lon) }, \
  42. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_hil_state_t, alt) }, \
  43. { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 44, offsetof(mavlink_hil_state_t, vx) }, \
  44. { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 46, offsetof(mavlink_hil_state_t, vy) }, \
  45. { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 48, offsetof(mavlink_hil_state_t, vz) }, \
  46. { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 50, offsetof(mavlink_hil_state_t, xacc) }, \
  47. { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 52, offsetof(mavlink_hil_state_t, yacc) }, \
  48. { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 54, offsetof(mavlink_hil_state_t, zacc) }, \
  49. } \
  50. }
  51. #else
  52. #define MAVLINK_MESSAGE_INFO_HIL_STATE { \
  53. "HIL_STATE", \
  54. 16, \
  55. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_state_t, time_usec) }, \
  56. { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_state_t, roll) }, \
  57. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_state_t, pitch) }, \
  58. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_state_t, yaw) }, \
  59. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_state_t, rollspeed) }, \
  60. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_state_t, pitchspeed) }, \
  61. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_state_t, yawspeed) }, \
  62. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_hil_state_t, lat) }, \
  63. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_hil_state_t, lon) }, \
  64. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_hil_state_t, alt) }, \
  65. { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 44, offsetof(mavlink_hil_state_t, vx) }, \
  66. { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 46, offsetof(mavlink_hil_state_t, vy) }, \
  67. { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 48, offsetof(mavlink_hil_state_t, vz) }, \
  68. { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 50, offsetof(mavlink_hil_state_t, xacc) }, \
  69. { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 52, offsetof(mavlink_hil_state_t, yacc) }, \
  70. { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 54, offsetof(mavlink_hil_state_t, zacc) }, \
  71. } \
  72. }
  73. #endif
  74. /**
  75. * @brief Pack a hil_state message
  76. * @param system_id ID of this system
  77. * @param component_id ID of this component (e.g. 200 for IMU)
  78. * @param msg The MAVLink message to compress the data into
  79. *
  80. * @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.
  81. * @param roll [rad] Roll angle
  82. * @param pitch [rad] Pitch angle
  83. * @param yaw [rad] Yaw angle
  84. * @param rollspeed [rad/s] Body frame roll / phi angular speed
  85. * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
  86. * @param yawspeed [rad/s] Body frame yaw / psi angular speed
  87. * @param lat [degE7] Latitude
  88. * @param lon [degE7] Longitude
  89. * @param alt [mm] Altitude
  90. * @param vx [cm/s] Ground X Speed (Latitude)
  91. * @param vy [cm/s] Ground Y Speed (Longitude)
  92. * @param vz [cm/s] Ground Z Speed (Altitude)
  93. * @param xacc [mG] X acceleration
  94. * @param yacc [mG] Y acceleration
  95. * @param zacc [mG] Z acceleration
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  99. uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
  100. {
  101. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  102. char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
  103. _mav_put_uint64_t(buf, 0, time_usec);
  104. _mav_put_float(buf, 8, roll);
  105. _mav_put_float(buf, 12, pitch);
  106. _mav_put_float(buf, 16, yaw);
  107. _mav_put_float(buf, 20, rollspeed);
  108. _mav_put_float(buf, 24, pitchspeed);
  109. _mav_put_float(buf, 28, yawspeed);
  110. _mav_put_int32_t(buf, 32, lat);
  111. _mav_put_int32_t(buf, 36, lon);
  112. _mav_put_int32_t(buf, 40, alt);
  113. _mav_put_int16_t(buf, 44, vx);
  114. _mav_put_int16_t(buf, 46, vy);
  115. _mav_put_int16_t(buf, 48, vz);
  116. _mav_put_int16_t(buf, 50, xacc);
  117. _mav_put_int16_t(buf, 52, yacc);
  118. _mav_put_int16_t(buf, 54, zacc);
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
  120. #else
  121. mavlink_hil_state_t packet;
  122. packet.time_usec = time_usec;
  123. packet.roll = roll;
  124. packet.pitch = pitch;
  125. packet.yaw = yaw;
  126. packet.rollspeed = rollspeed;
  127. packet.pitchspeed = pitchspeed;
  128. packet.yawspeed = yawspeed;
  129. packet.lat = lat;
  130. packet.lon = lon;
  131. packet.alt = alt;
  132. packet.vx = vx;
  133. packet.vy = vy;
  134. packet.vz = vz;
  135. packet.xacc = xacc;
  136. packet.yacc = yacc;
  137. packet.zacc = zacc;
  138. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
  139. #endif
  140. msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
  141. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  142. }
  143. /**
  144. * @brief Pack a hil_state message
  145. * @param system_id ID of this system
  146. * @param component_id ID of this component (e.g. 200 for IMU)
  147. * @param status MAVLink status structure
  148. * @param msg The MAVLink message to compress the data into
  149. *
  150. * @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.
  151. * @param roll [rad] Roll angle
  152. * @param pitch [rad] Pitch angle
  153. * @param yaw [rad] Yaw angle
  154. * @param rollspeed [rad/s] Body frame roll / phi angular speed
  155. * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
  156. * @param yawspeed [rad/s] Body frame yaw / psi angular speed
  157. * @param lat [degE7] Latitude
  158. * @param lon [degE7] Longitude
  159. * @param alt [mm] Altitude
  160. * @param vx [cm/s] Ground X Speed (Latitude)
  161. * @param vy [cm/s] Ground Y Speed (Longitude)
  162. * @param vz [cm/s] Ground Z Speed (Altitude)
  163. * @param xacc [mG] X acceleration
  164. * @param yacc [mG] Y acceleration
  165. * @param zacc [mG] Z acceleration
  166. * @return length of the message in bytes (excluding serial stream start sign)
  167. */
  168. static inline uint16_t mavlink_msg_hil_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  169. uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
  170. {
  171. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  172. char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
  173. _mav_put_uint64_t(buf, 0, time_usec);
  174. _mav_put_float(buf, 8, roll);
  175. _mav_put_float(buf, 12, pitch);
  176. _mav_put_float(buf, 16, yaw);
  177. _mav_put_float(buf, 20, rollspeed);
  178. _mav_put_float(buf, 24, pitchspeed);
  179. _mav_put_float(buf, 28, yawspeed);
  180. _mav_put_int32_t(buf, 32, lat);
  181. _mav_put_int32_t(buf, 36, lon);
  182. _mav_put_int32_t(buf, 40, alt);
  183. _mav_put_int16_t(buf, 44, vx);
  184. _mav_put_int16_t(buf, 46, vy);
  185. _mav_put_int16_t(buf, 48, vz);
  186. _mav_put_int16_t(buf, 50, xacc);
  187. _mav_put_int16_t(buf, 52, yacc);
  188. _mav_put_int16_t(buf, 54, zacc);
  189. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
  190. #else
  191. mavlink_hil_state_t packet;
  192. packet.time_usec = time_usec;
  193. packet.roll = roll;
  194. packet.pitch = pitch;
  195. packet.yaw = yaw;
  196. packet.rollspeed = rollspeed;
  197. packet.pitchspeed = pitchspeed;
  198. packet.yawspeed = yawspeed;
  199. packet.lat = lat;
  200. packet.lon = lon;
  201. packet.alt = alt;
  202. packet.vx = vx;
  203. packet.vy = vy;
  204. packet.vz = vz;
  205. packet.xacc = xacc;
  206. packet.yacc = yacc;
  207. packet.zacc = zacc;
  208. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
  209. #endif
  210. msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
  211. #if MAVLINK_CRC_EXTRA
  212. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  213. #else
  214. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN);
  215. #endif
  216. }
  217. /**
  218. * @brief Pack a hil_state message on a channel
  219. * @param system_id ID of this system
  220. * @param component_id ID of this component (e.g. 200 for IMU)
  221. * @param chan The MAVLink channel this message will be sent over
  222. * @param msg The MAVLink message to compress the data into
  223. * @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.
  224. * @param roll [rad] Roll angle
  225. * @param pitch [rad] Pitch angle
  226. * @param yaw [rad] Yaw angle
  227. * @param rollspeed [rad/s] Body frame roll / phi angular speed
  228. * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
  229. * @param yawspeed [rad/s] Body frame yaw / psi angular speed
  230. * @param lat [degE7] Latitude
  231. * @param lon [degE7] Longitude
  232. * @param alt [mm] Altitude
  233. * @param vx [cm/s] Ground X Speed (Latitude)
  234. * @param vy [cm/s] Ground Y Speed (Longitude)
  235. * @param vz [cm/s] Ground Z Speed (Altitude)
  236. * @param xacc [mG] X acceleration
  237. * @param yacc [mG] Y acceleration
  238. * @param zacc [mG] Z acceleration
  239. * @return length of the message in bytes (excluding serial stream start sign)
  240. */
  241. static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  242. mavlink_message_t* msg,
  243. uint64_t time_usec,float roll,float pitch,float yaw,float rollspeed,float pitchspeed,float yawspeed,int32_t lat,int32_t lon,int32_t alt,int16_t vx,int16_t vy,int16_t vz,int16_t xacc,int16_t yacc,int16_t zacc)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
  247. _mav_put_uint64_t(buf, 0, time_usec);
  248. _mav_put_float(buf, 8, roll);
  249. _mav_put_float(buf, 12, pitch);
  250. _mav_put_float(buf, 16, yaw);
  251. _mav_put_float(buf, 20, rollspeed);
  252. _mav_put_float(buf, 24, pitchspeed);
  253. _mav_put_float(buf, 28, yawspeed);
  254. _mav_put_int32_t(buf, 32, lat);
  255. _mav_put_int32_t(buf, 36, lon);
  256. _mav_put_int32_t(buf, 40, alt);
  257. _mav_put_int16_t(buf, 44, vx);
  258. _mav_put_int16_t(buf, 46, vy);
  259. _mav_put_int16_t(buf, 48, vz);
  260. _mav_put_int16_t(buf, 50, xacc);
  261. _mav_put_int16_t(buf, 52, yacc);
  262. _mav_put_int16_t(buf, 54, zacc);
  263. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
  264. #else
  265. mavlink_hil_state_t packet;
  266. packet.time_usec = time_usec;
  267. packet.roll = roll;
  268. packet.pitch = pitch;
  269. packet.yaw = yaw;
  270. packet.rollspeed = rollspeed;
  271. packet.pitchspeed = pitchspeed;
  272. packet.yawspeed = yawspeed;
  273. packet.lat = lat;
  274. packet.lon = lon;
  275. packet.alt = alt;
  276. packet.vx = vx;
  277. packet.vy = vy;
  278. packet.vz = vz;
  279. packet.xacc = xacc;
  280. packet.yacc = yacc;
  281. packet.zacc = zacc;
  282. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
  283. #endif
  284. msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
  285. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  286. }
  287. /**
  288. * @brief Encode a hil_state struct
  289. *
  290. * @param system_id ID of this system
  291. * @param component_id ID of this component (e.g. 200 for IMU)
  292. * @param msg The MAVLink message to compress the data into
  293. * @param hil_state C-struct to read the message contents from
  294. */
  295. static inline uint16_t mavlink_msg_hil_state_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
  296. {
  297. return mavlink_msg_hil_state_pack(system_id, component_id, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
  298. }
  299. /**
  300. * @brief Encode a hil_state struct on a channel
  301. *
  302. * @param system_id ID of this system
  303. * @param component_id ID of this component (e.g. 200 for IMU)
  304. * @param chan The MAVLink channel this message will be sent over
  305. * @param msg The MAVLink message to compress the data into
  306. * @param hil_state C-struct to read the message contents from
  307. */
  308. static inline uint16_t mavlink_msg_hil_state_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
  309. {
  310. return mavlink_msg_hil_state_pack_chan(system_id, component_id, chan, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
  311. }
  312. /**
  313. * @brief Encode a hil_state struct with provided status structure
  314. *
  315. * @param system_id ID of this system
  316. * @param component_id ID of this component (e.g. 200 for IMU)
  317. * @param status MAVLink status structure
  318. * @param msg The MAVLink message to compress the data into
  319. * @param hil_state C-struct to read the message contents from
  320. */
  321. static inline uint16_t mavlink_msg_hil_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
  322. {
  323. return mavlink_msg_hil_state_pack_status(system_id, component_id, _status, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
  324. }
  325. /**
  326. * @brief Send a hil_state message
  327. * @param chan MAVLink channel to send the message
  328. *
  329. * @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.
  330. * @param roll [rad] Roll angle
  331. * @param pitch [rad] Pitch angle
  332. * @param yaw [rad] Yaw angle
  333. * @param rollspeed [rad/s] Body frame roll / phi angular speed
  334. * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
  335. * @param yawspeed [rad/s] Body frame yaw / psi angular speed
  336. * @param lat [degE7] Latitude
  337. * @param lon [degE7] Longitude
  338. * @param alt [mm] Altitude
  339. * @param vx [cm/s] Ground X Speed (Latitude)
  340. * @param vy [cm/s] Ground Y Speed (Longitude)
  341. * @param vz [cm/s] Ground Z Speed (Altitude)
  342. * @param xacc [mG] X acceleration
  343. * @param yacc [mG] Y acceleration
  344. * @param zacc [mG] Z acceleration
  345. */
  346. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  347. static inline void mavlink_msg_hil_state_send(mavlink_channel_t chan, uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
  348. {
  349. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  350. char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
  351. _mav_put_uint64_t(buf, 0, time_usec);
  352. _mav_put_float(buf, 8, roll);
  353. _mav_put_float(buf, 12, pitch);
  354. _mav_put_float(buf, 16, yaw);
  355. _mav_put_float(buf, 20, rollspeed);
  356. _mav_put_float(buf, 24, pitchspeed);
  357. _mav_put_float(buf, 28, yawspeed);
  358. _mav_put_int32_t(buf, 32, lat);
  359. _mav_put_int32_t(buf, 36, lon);
  360. _mav_put_int32_t(buf, 40, alt);
  361. _mav_put_int16_t(buf, 44, vx);
  362. _mav_put_int16_t(buf, 46, vy);
  363. _mav_put_int16_t(buf, 48, vz);
  364. _mav_put_int16_t(buf, 50, xacc);
  365. _mav_put_int16_t(buf, 52, yacc);
  366. _mav_put_int16_t(buf, 54, zacc);
  367. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, buf, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  368. #else
  369. mavlink_hil_state_t packet;
  370. packet.time_usec = time_usec;
  371. packet.roll = roll;
  372. packet.pitch = pitch;
  373. packet.yaw = yaw;
  374. packet.rollspeed = rollspeed;
  375. packet.pitchspeed = pitchspeed;
  376. packet.yawspeed = yawspeed;
  377. packet.lat = lat;
  378. packet.lon = lon;
  379. packet.alt = alt;
  380. packet.vx = vx;
  381. packet.vy = vy;
  382. packet.vz = vz;
  383. packet.xacc = xacc;
  384. packet.yacc = yacc;
  385. packet.zacc = zacc;
  386. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)&packet, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  387. #endif
  388. }
  389. /**
  390. * @brief Send a hil_state message
  391. * @param chan MAVLink channel to send the message
  392. * @param struct The MAVLink struct to serialize
  393. */
  394. static inline void mavlink_msg_hil_state_send_struct(mavlink_channel_t chan, const mavlink_hil_state_t* hil_state)
  395. {
  396. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  397. mavlink_msg_hil_state_send(chan, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
  398. #else
  399. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)hil_state, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  400. #endif
  401. }
  402. #if MAVLINK_MSG_ID_HIL_STATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  403. /*
  404. This variant of _send() can be used to save stack space by re-using
  405. memory from the receive buffer. The caller provides a
  406. mavlink_message_t which is the size of a full mavlink message. This
  407. is usually the receive buffer for the channel, and allows a reply to an
  408. incoming message with minimum stack space usage.
  409. */
  410. static inline void mavlink_msg_hil_state_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
  411. {
  412. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  413. char *buf = (char *)msgbuf;
  414. _mav_put_uint64_t(buf, 0, time_usec);
  415. _mav_put_float(buf, 8, roll);
  416. _mav_put_float(buf, 12, pitch);
  417. _mav_put_float(buf, 16, yaw);
  418. _mav_put_float(buf, 20, rollspeed);
  419. _mav_put_float(buf, 24, pitchspeed);
  420. _mav_put_float(buf, 28, yawspeed);
  421. _mav_put_int32_t(buf, 32, lat);
  422. _mav_put_int32_t(buf, 36, lon);
  423. _mav_put_int32_t(buf, 40, alt);
  424. _mav_put_int16_t(buf, 44, vx);
  425. _mav_put_int16_t(buf, 46, vy);
  426. _mav_put_int16_t(buf, 48, vz);
  427. _mav_put_int16_t(buf, 50, xacc);
  428. _mav_put_int16_t(buf, 52, yacc);
  429. _mav_put_int16_t(buf, 54, zacc);
  430. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, buf, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  431. #else
  432. mavlink_hil_state_t *packet = (mavlink_hil_state_t *)msgbuf;
  433. packet->time_usec = time_usec;
  434. packet->roll = roll;
  435. packet->pitch = pitch;
  436. packet->yaw = yaw;
  437. packet->rollspeed = rollspeed;
  438. packet->pitchspeed = pitchspeed;
  439. packet->yawspeed = yawspeed;
  440. packet->lat = lat;
  441. packet->lon = lon;
  442. packet->alt = alt;
  443. packet->vx = vx;
  444. packet->vy = vy;
  445. packet->vz = vz;
  446. packet->xacc = xacc;
  447. packet->yacc = yacc;
  448. packet->zacc = zacc;
  449. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)packet, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
  450. #endif
  451. }
  452. #endif
  453. #endif
  454. // MESSAGE HIL_STATE UNPACKING
  455. /**
  456. * @brief Get field time_usec from hil_state message
  457. *
  458. * @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.
  459. */
  460. static inline uint64_t mavlink_msg_hil_state_get_time_usec(const mavlink_message_t* msg)
  461. {
  462. return _MAV_RETURN_uint64_t(msg, 0);
  463. }
  464. /**
  465. * @brief Get field roll from hil_state message
  466. *
  467. * @return [rad] Roll angle
  468. */
  469. static inline float mavlink_msg_hil_state_get_roll(const mavlink_message_t* msg)
  470. {
  471. return _MAV_RETURN_float(msg, 8);
  472. }
  473. /**
  474. * @brief Get field pitch from hil_state message
  475. *
  476. * @return [rad] Pitch angle
  477. */
  478. static inline float mavlink_msg_hil_state_get_pitch(const mavlink_message_t* msg)
  479. {
  480. return _MAV_RETURN_float(msg, 12);
  481. }
  482. /**
  483. * @brief Get field yaw from hil_state message
  484. *
  485. * @return [rad] Yaw angle
  486. */
  487. static inline float mavlink_msg_hil_state_get_yaw(const mavlink_message_t* msg)
  488. {
  489. return _MAV_RETURN_float(msg, 16);
  490. }
  491. /**
  492. * @brief Get field rollspeed from hil_state message
  493. *
  494. * @return [rad/s] Body frame roll / phi angular speed
  495. */
  496. static inline float mavlink_msg_hil_state_get_rollspeed(const mavlink_message_t* msg)
  497. {
  498. return _MAV_RETURN_float(msg, 20);
  499. }
  500. /**
  501. * @brief Get field pitchspeed from hil_state message
  502. *
  503. * @return [rad/s] Body frame pitch / theta angular speed
  504. */
  505. static inline float mavlink_msg_hil_state_get_pitchspeed(const mavlink_message_t* msg)
  506. {
  507. return _MAV_RETURN_float(msg, 24);
  508. }
  509. /**
  510. * @brief Get field yawspeed from hil_state message
  511. *
  512. * @return [rad/s] Body frame yaw / psi angular speed
  513. */
  514. static inline float mavlink_msg_hil_state_get_yawspeed(const mavlink_message_t* msg)
  515. {
  516. return _MAV_RETURN_float(msg, 28);
  517. }
  518. /**
  519. * @brief Get field lat from hil_state message
  520. *
  521. * @return [degE7] Latitude
  522. */
  523. static inline int32_t mavlink_msg_hil_state_get_lat(const mavlink_message_t* msg)
  524. {
  525. return _MAV_RETURN_int32_t(msg, 32);
  526. }
  527. /**
  528. * @brief Get field lon from hil_state message
  529. *
  530. * @return [degE7] Longitude
  531. */
  532. static inline int32_t mavlink_msg_hil_state_get_lon(const mavlink_message_t* msg)
  533. {
  534. return _MAV_RETURN_int32_t(msg, 36);
  535. }
  536. /**
  537. * @brief Get field alt from hil_state message
  538. *
  539. * @return [mm] Altitude
  540. */
  541. static inline int32_t mavlink_msg_hil_state_get_alt(const mavlink_message_t* msg)
  542. {
  543. return _MAV_RETURN_int32_t(msg, 40);
  544. }
  545. /**
  546. * @brief Get field vx from hil_state message
  547. *
  548. * @return [cm/s] Ground X Speed (Latitude)
  549. */
  550. static inline int16_t mavlink_msg_hil_state_get_vx(const mavlink_message_t* msg)
  551. {
  552. return _MAV_RETURN_int16_t(msg, 44);
  553. }
  554. /**
  555. * @brief Get field vy from hil_state message
  556. *
  557. * @return [cm/s] Ground Y Speed (Longitude)
  558. */
  559. static inline int16_t mavlink_msg_hil_state_get_vy(const mavlink_message_t* msg)
  560. {
  561. return _MAV_RETURN_int16_t(msg, 46);
  562. }
  563. /**
  564. * @brief Get field vz from hil_state message
  565. *
  566. * @return [cm/s] Ground Z Speed (Altitude)
  567. */
  568. static inline int16_t mavlink_msg_hil_state_get_vz(const mavlink_message_t* msg)
  569. {
  570. return _MAV_RETURN_int16_t(msg, 48);
  571. }
  572. /**
  573. * @brief Get field xacc from hil_state message
  574. *
  575. * @return [mG] X acceleration
  576. */
  577. static inline int16_t mavlink_msg_hil_state_get_xacc(const mavlink_message_t* msg)
  578. {
  579. return _MAV_RETURN_int16_t(msg, 50);
  580. }
  581. /**
  582. * @brief Get field yacc from hil_state message
  583. *
  584. * @return [mG] Y acceleration
  585. */
  586. static inline int16_t mavlink_msg_hil_state_get_yacc(const mavlink_message_t* msg)
  587. {
  588. return _MAV_RETURN_int16_t(msg, 52);
  589. }
  590. /**
  591. * @brief Get field zacc from hil_state message
  592. *
  593. * @return [mG] Z acceleration
  594. */
  595. static inline int16_t mavlink_msg_hil_state_get_zacc(const mavlink_message_t* msg)
  596. {
  597. return _MAV_RETURN_int16_t(msg, 54);
  598. }
  599. /**
  600. * @brief Decode a hil_state message into a struct
  601. *
  602. * @param msg The message to decode
  603. * @param hil_state C-struct to decode the message contents into
  604. */
  605. static inline void mavlink_msg_hil_state_decode(const mavlink_message_t* msg, mavlink_hil_state_t* hil_state)
  606. {
  607. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  608. hil_state->time_usec = mavlink_msg_hil_state_get_time_usec(msg);
  609. hil_state->roll = mavlink_msg_hil_state_get_roll(msg);
  610. hil_state->pitch = mavlink_msg_hil_state_get_pitch(msg);
  611. hil_state->yaw = mavlink_msg_hil_state_get_yaw(msg);
  612. hil_state->rollspeed = mavlink_msg_hil_state_get_rollspeed(msg);
  613. hil_state->pitchspeed = mavlink_msg_hil_state_get_pitchspeed(msg);
  614. hil_state->yawspeed = mavlink_msg_hil_state_get_yawspeed(msg);
  615. hil_state->lat = mavlink_msg_hil_state_get_lat(msg);
  616. hil_state->lon = mavlink_msg_hil_state_get_lon(msg);
  617. hil_state->alt = mavlink_msg_hil_state_get_alt(msg);
  618. hil_state->vx = mavlink_msg_hil_state_get_vx(msg);
  619. hil_state->vy = mavlink_msg_hil_state_get_vy(msg);
  620. hil_state->vz = mavlink_msg_hil_state_get_vz(msg);
  621. hil_state->xacc = mavlink_msg_hil_state_get_xacc(msg);
  622. hil_state->yacc = mavlink_msg_hil_state_get_yacc(msg);
  623. hil_state->zacc = mavlink_msg_hil_state_get_zacc(msg);
  624. #else
  625. uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_STATE_LEN? msg->len : MAVLINK_MSG_ID_HIL_STATE_LEN;
  626. memset(hil_state, 0, MAVLINK_MSG_ID_HIL_STATE_LEN);
  627. memcpy(hil_state, _MAV_PAYLOAD(msg), len);
  628. #endif
  629. }