mavlink_msg_hil_state_quaternion.h 32 KB

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