mavlink_msg_highres_imu.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. #pragma once
  2. // MESSAGE HIGHRES_IMU PACKING
  3. #define MAVLINK_MSG_ID_HIGHRES_IMU 105
  4. typedef struct __mavlink_highres_imu_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 xacc; /*< [m/s/s] X acceleration*/
  7. float yacc; /*< [m/s/s] Y acceleration*/
  8. float zacc; /*< [m/s/s] Z acceleration*/
  9. float xgyro; /*< [rad/s] Angular speed around X axis*/
  10. float ygyro; /*< [rad/s] Angular speed around Y axis*/
  11. float zgyro; /*< [rad/s] Angular speed around Z axis*/
  12. float xmag; /*< [gauss] X Magnetic field*/
  13. float ymag; /*< [gauss] Y Magnetic field*/
  14. float zmag; /*< [gauss] Z Magnetic field*/
  15. float abs_pressure; /*< [hPa] Absolute pressure*/
  16. float diff_pressure; /*< [hPa] Differential pressure*/
  17. float pressure_alt; /*< Altitude calculated from pressure*/
  18. float temperature; /*< [degC] Temperature*/
  19. uint16_t fields_updated; /*< Bitmap for fields that have updated since last message*/
  20. uint8_t id; /*< Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)*/
  21. } mavlink_highres_imu_t;
  22. #define MAVLINK_MSG_ID_HIGHRES_IMU_LEN 63
  23. #define MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN 62
  24. #define MAVLINK_MSG_ID_105_LEN 63
  25. #define MAVLINK_MSG_ID_105_MIN_LEN 62
  26. #define MAVLINK_MSG_ID_HIGHRES_IMU_CRC 93
  27. #define MAVLINK_MSG_ID_105_CRC 93
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_HIGHRES_IMU { \
  30. 105, \
  31. "HIGHRES_IMU", \
  32. 16, \
  33. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_highres_imu_t, time_usec) }, \
  34. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_highres_imu_t, xacc) }, \
  35. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_highres_imu_t, yacc) }, \
  36. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_highres_imu_t, zacc) }, \
  37. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_highres_imu_t, xgyro) }, \
  38. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_highres_imu_t, ygyro) }, \
  39. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_highres_imu_t, zgyro) }, \
  40. { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_highres_imu_t, xmag) }, \
  41. { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_highres_imu_t, ymag) }, \
  42. { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_highres_imu_t, zmag) }, \
  43. { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_highres_imu_t, abs_pressure) }, \
  44. { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_highres_imu_t, diff_pressure) }, \
  45. { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_highres_imu_t, pressure_alt) }, \
  46. { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_highres_imu_t, temperature) }, \
  47. { "fields_updated", NULL, MAVLINK_TYPE_UINT16_T, 0, 60, offsetof(mavlink_highres_imu_t, fields_updated) }, \
  48. { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 62, offsetof(mavlink_highres_imu_t, id) }, \
  49. } \
  50. }
  51. #else
  52. #define MAVLINK_MESSAGE_INFO_HIGHRES_IMU { \
  53. "HIGHRES_IMU", \
  54. 16, \
  55. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_highres_imu_t, time_usec) }, \
  56. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_highres_imu_t, xacc) }, \
  57. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_highres_imu_t, yacc) }, \
  58. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_highres_imu_t, zacc) }, \
  59. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_highres_imu_t, xgyro) }, \
  60. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_highres_imu_t, ygyro) }, \
  61. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_highres_imu_t, zgyro) }, \
  62. { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_highres_imu_t, xmag) }, \
  63. { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_highres_imu_t, ymag) }, \
  64. { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_highres_imu_t, zmag) }, \
  65. { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_highres_imu_t, abs_pressure) }, \
  66. { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_highres_imu_t, diff_pressure) }, \
  67. { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_highres_imu_t, pressure_alt) }, \
  68. { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_highres_imu_t, temperature) }, \
  69. { "fields_updated", NULL, MAVLINK_TYPE_UINT16_T, 0, 60, offsetof(mavlink_highres_imu_t, fields_updated) }, \
  70. { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 62, offsetof(mavlink_highres_imu_t, id) }, \
  71. } \
  72. }
  73. #endif
  74. /**
  75. * @brief Pack a highres_imu 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 xacc [m/s/s] X acceleration
  82. * @param yacc [m/s/s] Y acceleration
  83. * @param zacc [m/s/s] Z acceleration
  84. * @param xgyro [rad/s] Angular speed around X axis
  85. * @param ygyro [rad/s] Angular speed around Y axis
  86. * @param zgyro [rad/s] Angular speed around Z axis
  87. * @param xmag [gauss] X Magnetic field
  88. * @param ymag [gauss] Y Magnetic field
  89. * @param zmag [gauss] Z Magnetic field
  90. * @param abs_pressure [hPa] Absolute pressure
  91. * @param diff_pressure [hPa] Differential pressure
  92. * @param pressure_alt Altitude calculated from pressure
  93. * @param temperature [degC] Temperature
  94. * @param fields_updated Bitmap for fields that have updated since last message
  95. * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_highres_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  99. uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated, uint8_t id)
  100. {
  101. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  102. char buf[MAVLINK_MSG_ID_HIGHRES_IMU_LEN];
  103. _mav_put_uint64_t(buf, 0, time_usec);
  104. _mav_put_float(buf, 8, xacc);
  105. _mav_put_float(buf, 12, yacc);
  106. _mav_put_float(buf, 16, zacc);
  107. _mav_put_float(buf, 20, xgyro);
  108. _mav_put_float(buf, 24, ygyro);
  109. _mav_put_float(buf, 28, zgyro);
  110. _mav_put_float(buf, 32, xmag);
  111. _mav_put_float(buf, 36, ymag);
  112. _mav_put_float(buf, 40, zmag);
  113. _mav_put_float(buf, 44, abs_pressure);
  114. _mav_put_float(buf, 48, diff_pressure);
  115. _mav_put_float(buf, 52, pressure_alt);
  116. _mav_put_float(buf, 56, temperature);
  117. _mav_put_uint16_t(buf, 60, fields_updated);
  118. _mav_put_uint8_t(buf, 62, id);
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  120. #else
  121. mavlink_highres_imu_t packet;
  122. packet.time_usec = time_usec;
  123. packet.xacc = xacc;
  124. packet.yacc = yacc;
  125. packet.zacc = zacc;
  126. packet.xgyro = xgyro;
  127. packet.ygyro = ygyro;
  128. packet.zgyro = zgyro;
  129. packet.xmag = xmag;
  130. packet.ymag = ymag;
  131. packet.zmag = zmag;
  132. packet.abs_pressure = abs_pressure;
  133. packet.diff_pressure = diff_pressure;
  134. packet.pressure_alt = pressure_alt;
  135. packet.temperature = temperature;
  136. packet.fields_updated = fields_updated;
  137. packet.id = id;
  138. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  139. #endif
  140. msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU;
  141. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  142. }
  143. /**
  144. * @brief Pack a highres_imu 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 xacc [m/s/s] X acceleration
  152. * @param yacc [m/s/s] Y acceleration
  153. * @param zacc [m/s/s] Z acceleration
  154. * @param xgyro [rad/s] Angular speed around X axis
  155. * @param ygyro [rad/s] Angular speed around Y axis
  156. * @param zgyro [rad/s] Angular speed around Z axis
  157. * @param xmag [gauss] X Magnetic field
  158. * @param ymag [gauss] Y Magnetic field
  159. * @param zmag [gauss] Z Magnetic field
  160. * @param abs_pressure [hPa] Absolute pressure
  161. * @param diff_pressure [hPa] Differential pressure
  162. * @param pressure_alt Altitude calculated from pressure
  163. * @param temperature [degC] Temperature
  164. * @param fields_updated Bitmap for fields that have updated since last message
  165. * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
  166. * @return length of the message in bytes (excluding serial stream start sign)
  167. */
  168. static inline uint16_t mavlink_msg_highres_imu_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  169. uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated, uint8_t id)
  170. {
  171. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  172. char buf[MAVLINK_MSG_ID_HIGHRES_IMU_LEN];
  173. _mav_put_uint64_t(buf, 0, time_usec);
  174. _mav_put_float(buf, 8, xacc);
  175. _mav_put_float(buf, 12, yacc);
  176. _mav_put_float(buf, 16, zacc);
  177. _mav_put_float(buf, 20, xgyro);
  178. _mav_put_float(buf, 24, ygyro);
  179. _mav_put_float(buf, 28, zgyro);
  180. _mav_put_float(buf, 32, xmag);
  181. _mav_put_float(buf, 36, ymag);
  182. _mav_put_float(buf, 40, zmag);
  183. _mav_put_float(buf, 44, abs_pressure);
  184. _mav_put_float(buf, 48, diff_pressure);
  185. _mav_put_float(buf, 52, pressure_alt);
  186. _mav_put_float(buf, 56, temperature);
  187. _mav_put_uint16_t(buf, 60, fields_updated);
  188. _mav_put_uint8_t(buf, 62, id);
  189. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  190. #else
  191. mavlink_highres_imu_t packet;
  192. packet.time_usec = time_usec;
  193. packet.xacc = xacc;
  194. packet.yacc = yacc;
  195. packet.zacc = zacc;
  196. packet.xgyro = xgyro;
  197. packet.ygyro = ygyro;
  198. packet.zgyro = zgyro;
  199. packet.xmag = xmag;
  200. packet.ymag = ymag;
  201. packet.zmag = zmag;
  202. packet.abs_pressure = abs_pressure;
  203. packet.diff_pressure = diff_pressure;
  204. packet.pressure_alt = pressure_alt;
  205. packet.temperature = temperature;
  206. packet.fields_updated = fields_updated;
  207. packet.id = id;
  208. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  209. #endif
  210. msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU;
  211. #if MAVLINK_CRC_EXTRA
  212. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  213. #else
  214. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  215. #endif
  216. }
  217. /**
  218. * @brief Pack a highres_imu 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 xacc [m/s/s] X acceleration
  225. * @param yacc [m/s/s] Y acceleration
  226. * @param zacc [m/s/s] Z acceleration
  227. * @param xgyro [rad/s] Angular speed around X axis
  228. * @param ygyro [rad/s] Angular speed around Y axis
  229. * @param zgyro [rad/s] Angular speed around Z axis
  230. * @param xmag [gauss] X Magnetic field
  231. * @param ymag [gauss] Y Magnetic field
  232. * @param zmag [gauss] Z Magnetic field
  233. * @param abs_pressure [hPa] Absolute pressure
  234. * @param diff_pressure [hPa] Differential pressure
  235. * @param pressure_alt Altitude calculated from pressure
  236. * @param temperature [degC] Temperature
  237. * @param fields_updated Bitmap for fields that have updated since last message
  238. * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
  239. * @return length of the message in bytes (excluding serial stream start sign)
  240. */
  241. static inline uint16_t mavlink_msg_highres_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  242. mavlink_message_t* msg,
  243. uint64_t time_usec,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,float xmag,float ymag,float zmag,float abs_pressure,float diff_pressure,float pressure_alt,float temperature,uint16_t fields_updated,uint8_t id)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. char buf[MAVLINK_MSG_ID_HIGHRES_IMU_LEN];
  247. _mav_put_uint64_t(buf, 0, time_usec);
  248. _mav_put_float(buf, 8, xacc);
  249. _mav_put_float(buf, 12, yacc);
  250. _mav_put_float(buf, 16, zacc);
  251. _mav_put_float(buf, 20, xgyro);
  252. _mav_put_float(buf, 24, ygyro);
  253. _mav_put_float(buf, 28, zgyro);
  254. _mav_put_float(buf, 32, xmag);
  255. _mav_put_float(buf, 36, ymag);
  256. _mav_put_float(buf, 40, zmag);
  257. _mav_put_float(buf, 44, abs_pressure);
  258. _mav_put_float(buf, 48, diff_pressure);
  259. _mav_put_float(buf, 52, pressure_alt);
  260. _mav_put_float(buf, 56, temperature);
  261. _mav_put_uint16_t(buf, 60, fields_updated);
  262. _mav_put_uint8_t(buf, 62, id);
  263. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  264. #else
  265. mavlink_highres_imu_t packet;
  266. packet.time_usec = time_usec;
  267. packet.xacc = xacc;
  268. packet.yacc = yacc;
  269. packet.zacc = zacc;
  270. packet.xgyro = xgyro;
  271. packet.ygyro = ygyro;
  272. packet.zgyro = zgyro;
  273. packet.xmag = xmag;
  274. packet.ymag = ymag;
  275. packet.zmag = zmag;
  276. packet.abs_pressure = abs_pressure;
  277. packet.diff_pressure = diff_pressure;
  278. packet.pressure_alt = pressure_alt;
  279. packet.temperature = temperature;
  280. packet.fields_updated = fields_updated;
  281. packet.id = id;
  282. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  283. #endif
  284. msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU;
  285. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  286. }
  287. /**
  288. * @brief Encode a highres_imu 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 highres_imu C-struct to read the message contents from
  294. */
  295. static inline uint16_t mavlink_msg_highres_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_highres_imu_t* highres_imu)
  296. {
  297. return mavlink_msg_highres_imu_pack(system_id, component_id, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id);
  298. }
  299. /**
  300. * @brief Encode a highres_imu 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 highres_imu C-struct to read the message contents from
  307. */
  308. static inline uint16_t mavlink_msg_highres_imu_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_highres_imu_t* highres_imu)
  309. {
  310. return mavlink_msg_highres_imu_pack_chan(system_id, component_id, chan, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id);
  311. }
  312. /**
  313. * @brief Encode a highres_imu 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 highres_imu C-struct to read the message contents from
  320. */
  321. static inline uint16_t mavlink_msg_highres_imu_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_highres_imu_t* highres_imu)
  322. {
  323. return mavlink_msg_highres_imu_pack_status(system_id, component_id, _status, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id);
  324. }
  325. /**
  326. * @brief Send a highres_imu 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 xacc [m/s/s] X acceleration
  331. * @param yacc [m/s/s] Y acceleration
  332. * @param zacc [m/s/s] Z acceleration
  333. * @param xgyro [rad/s] Angular speed around X axis
  334. * @param ygyro [rad/s] Angular speed around Y axis
  335. * @param zgyro [rad/s] Angular speed around Z axis
  336. * @param xmag [gauss] X Magnetic field
  337. * @param ymag [gauss] Y Magnetic field
  338. * @param zmag [gauss] Z Magnetic field
  339. * @param abs_pressure [hPa] Absolute pressure
  340. * @param diff_pressure [hPa] Differential pressure
  341. * @param pressure_alt Altitude calculated from pressure
  342. * @param temperature [degC] Temperature
  343. * @param fields_updated Bitmap for fields that have updated since last message
  344. * @param id Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
  345. */
  346. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  347. static inline void mavlink_msg_highres_imu_send(mavlink_channel_t chan, uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated, uint8_t id)
  348. {
  349. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  350. char buf[MAVLINK_MSG_ID_HIGHRES_IMU_LEN];
  351. _mav_put_uint64_t(buf, 0, time_usec);
  352. _mav_put_float(buf, 8, xacc);
  353. _mav_put_float(buf, 12, yacc);
  354. _mav_put_float(buf, 16, zacc);
  355. _mav_put_float(buf, 20, xgyro);
  356. _mav_put_float(buf, 24, ygyro);
  357. _mav_put_float(buf, 28, zgyro);
  358. _mav_put_float(buf, 32, xmag);
  359. _mav_put_float(buf, 36, ymag);
  360. _mav_put_float(buf, 40, zmag);
  361. _mav_put_float(buf, 44, abs_pressure);
  362. _mav_put_float(buf, 48, diff_pressure);
  363. _mav_put_float(buf, 52, pressure_alt);
  364. _mav_put_float(buf, 56, temperature);
  365. _mav_put_uint16_t(buf, 60, fields_updated);
  366. _mav_put_uint8_t(buf, 62, id);
  367. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, buf, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  368. #else
  369. mavlink_highres_imu_t packet;
  370. packet.time_usec = time_usec;
  371. packet.xacc = xacc;
  372. packet.yacc = yacc;
  373. packet.zacc = zacc;
  374. packet.xgyro = xgyro;
  375. packet.ygyro = ygyro;
  376. packet.zgyro = zgyro;
  377. packet.xmag = xmag;
  378. packet.ymag = ymag;
  379. packet.zmag = zmag;
  380. packet.abs_pressure = abs_pressure;
  381. packet.diff_pressure = diff_pressure;
  382. packet.pressure_alt = pressure_alt;
  383. packet.temperature = temperature;
  384. packet.fields_updated = fields_updated;
  385. packet.id = id;
  386. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, (const char *)&packet, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  387. #endif
  388. }
  389. /**
  390. * @brief Send a highres_imu 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_highres_imu_send_struct(mavlink_channel_t chan, const mavlink_highres_imu_t* highres_imu)
  395. {
  396. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  397. mavlink_msg_highres_imu_send(chan, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated, highres_imu->id);
  398. #else
  399. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, (const char *)highres_imu, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  400. #endif
  401. }
  402. #if MAVLINK_MSG_ID_HIGHRES_IMU_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_highres_imu_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated, uint8_t id)
  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, xacc);
  416. _mav_put_float(buf, 12, yacc);
  417. _mav_put_float(buf, 16, zacc);
  418. _mav_put_float(buf, 20, xgyro);
  419. _mav_put_float(buf, 24, ygyro);
  420. _mav_put_float(buf, 28, zgyro);
  421. _mav_put_float(buf, 32, xmag);
  422. _mav_put_float(buf, 36, ymag);
  423. _mav_put_float(buf, 40, zmag);
  424. _mav_put_float(buf, 44, abs_pressure);
  425. _mav_put_float(buf, 48, diff_pressure);
  426. _mav_put_float(buf, 52, pressure_alt);
  427. _mav_put_float(buf, 56, temperature);
  428. _mav_put_uint16_t(buf, 60, fields_updated);
  429. _mav_put_uint8_t(buf, 62, id);
  430. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, buf, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  431. #else
  432. mavlink_highres_imu_t *packet = (mavlink_highres_imu_t *)msgbuf;
  433. packet->time_usec = time_usec;
  434. packet->xacc = xacc;
  435. packet->yacc = yacc;
  436. packet->zacc = zacc;
  437. packet->xgyro = xgyro;
  438. packet->ygyro = ygyro;
  439. packet->zgyro = zgyro;
  440. packet->xmag = xmag;
  441. packet->ymag = ymag;
  442. packet->zmag = zmag;
  443. packet->abs_pressure = abs_pressure;
  444. packet->diff_pressure = diff_pressure;
  445. packet->pressure_alt = pressure_alt;
  446. packet->temperature = temperature;
  447. packet->fields_updated = fields_updated;
  448. packet->id = id;
  449. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, (const char *)packet, MAVLINK_MSG_ID_HIGHRES_IMU_MIN_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_LEN, MAVLINK_MSG_ID_HIGHRES_IMU_CRC);
  450. #endif
  451. }
  452. #endif
  453. #endif
  454. // MESSAGE HIGHRES_IMU UNPACKING
  455. /**
  456. * @brief Get field time_usec from highres_imu 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_highres_imu_get_time_usec(const mavlink_message_t* msg)
  461. {
  462. return _MAV_RETURN_uint64_t(msg, 0);
  463. }
  464. /**
  465. * @brief Get field xacc from highres_imu message
  466. *
  467. * @return [m/s/s] X acceleration
  468. */
  469. static inline float mavlink_msg_highres_imu_get_xacc(const mavlink_message_t* msg)
  470. {
  471. return _MAV_RETURN_float(msg, 8);
  472. }
  473. /**
  474. * @brief Get field yacc from highres_imu message
  475. *
  476. * @return [m/s/s] Y acceleration
  477. */
  478. static inline float mavlink_msg_highres_imu_get_yacc(const mavlink_message_t* msg)
  479. {
  480. return _MAV_RETURN_float(msg, 12);
  481. }
  482. /**
  483. * @brief Get field zacc from highres_imu message
  484. *
  485. * @return [m/s/s] Z acceleration
  486. */
  487. static inline float mavlink_msg_highres_imu_get_zacc(const mavlink_message_t* msg)
  488. {
  489. return _MAV_RETURN_float(msg, 16);
  490. }
  491. /**
  492. * @brief Get field xgyro from highres_imu message
  493. *
  494. * @return [rad/s] Angular speed around X axis
  495. */
  496. static inline float mavlink_msg_highres_imu_get_xgyro(const mavlink_message_t* msg)
  497. {
  498. return _MAV_RETURN_float(msg, 20);
  499. }
  500. /**
  501. * @brief Get field ygyro from highres_imu message
  502. *
  503. * @return [rad/s] Angular speed around Y axis
  504. */
  505. static inline float mavlink_msg_highres_imu_get_ygyro(const mavlink_message_t* msg)
  506. {
  507. return _MAV_RETURN_float(msg, 24);
  508. }
  509. /**
  510. * @brief Get field zgyro from highres_imu message
  511. *
  512. * @return [rad/s] Angular speed around Z axis
  513. */
  514. static inline float mavlink_msg_highres_imu_get_zgyro(const mavlink_message_t* msg)
  515. {
  516. return _MAV_RETURN_float(msg, 28);
  517. }
  518. /**
  519. * @brief Get field xmag from highres_imu message
  520. *
  521. * @return [gauss] X Magnetic field
  522. */
  523. static inline float mavlink_msg_highres_imu_get_xmag(const mavlink_message_t* msg)
  524. {
  525. return _MAV_RETURN_float(msg, 32);
  526. }
  527. /**
  528. * @brief Get field ymag from highres_imu message
  529. *
  530. * @return [gauss] Y Magnetic field
  531. */
  532. static inline float mavlink_msg_highres_imu_get_ymag(const mavlink_message_t* msg)
  533. {
  534. return _MAV_RETURN_float(msg, 36);
  535. }
  536. /**
  537. * @brief Get field zmag from highres_imu message
  538. *
  539. * @return [gauss] Z Magnetic field
  540. */
  541. static inline float mavlink_msg_highres_imu_get_zmag(const mavlink_message_t* msg)
  542. {
  543. return _MAV_RETURN_float(msg, 40);
  544. }
  545. /**
  546. * @brief Get field abs_pressure from highres_imu message
  547. *
  548. * @return [hPa] Absolute pressure
  549. */
  550. static inline float mavlink_msg_highres_imu_get_abs_pressure(const mavlink_message_t* msg)
  551. {
  552. return _MAV_RETURN_float(msg, 44);
  553. }
  554. /**
  555. * @brief Get field diff_pressure from highres_imu message
  556. *
  557. * @return [hPa] Differential pressure
  558. */
  559. static inline float mavlink_msg_highres_imu_get_diff_pressure(const mavlink_message_t* msg)
  560. {
  561. return _MAV_RETURN_float(msg, 48);
  562. }
  563. /**
  564. * @brief Get field pressure_alt from highres_imu message
  565. *
  566. * @return Altitude calculated from pressure
  567. */
  568. static inline float mavlink_msg_highres_imu_get_pressure_alt(const mavlink_message_t* msg)
  569. {
  570. return _MAV_RETURN_float(msg, 52);
  571. }
  572. /**
  573. * @brief Get field temperature from highres_imu message
  574. *
  575. * @return [degC] Temperature
  576. */
  577. static inline float mavlink_msg_highres_imu_get_temperature(const mavlink_message_t* msg)
  578. {
  579. return _MAV_RETURN_float(msg, 56);
  580. }
  581. /**
  582. * @brief Get field fields_updated from highres_imu message
  583. *
  584. * @return Bitmap for fields that have updated since last message
  585. */
  586. static inline uint16_t mavlink_msg_highres_imu_get_fields_updated(const mavlink_message_t* msg)
  587. {
  588. return _MAV_RETURN_uint16_t(msg, 60);
  589. }
  590. /**
  591. * @brief Get field id from highres_imu message
  592. *
  593. * @return Id. Ids are numbered from 0 and map to IMUs numbered from 1 (e.g. IMU1 will have a message with id=0)
  594. */
  595. static inline uint8_t mavlink_msg_highres_imu_get_id(const mavlink_message_t* msg)
  596. {
  597. return _MAV_RETURN_uint8_t(msg, 62);
  598. }
  599. /**
  600. * @brief Decode a highres_imu message into a struct
  601. *
  602. * @param msg The message to decode
  603. * @param highres_imu C-struct to decode the message contents into
  604. */
  605. static inline void mavlink_msg_highres_imu_decode(const mavlink_message_t* msg, mavlink_highres_imu_t* highres_imu)
  606. {
  607. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  608. highres_imu->time_usec = mavlink_msg_highres_imu_get_time_usec(msg);
  609. highres_imu->xacc = mavlink_msg_highres_imu_get_xacc(msg);
  610. highres_imu->yacc = mavlink_msg_highres_imu_get_yacc(msg);
  611. highres_imu->zacc = mavlink_msg_highres_imu_get_zacc(msg);
  612. highres_imu->xgyro = mavlink_msg_highres_imu_get_xgyro(msg);
  613. highres_imu->ygyro = mavlink_msg_highres_imu_get_ygyro(msg);
  614. highres_imu->zgyro = mavlink_msg_highres_imu_get_zgyro(msg);
  615. highres_imu->xmag = mavlink_msg_highres_imu_get_xmag(msg);
  616. highres_imu->ymag = mavlink_msg_highres_imu_get_ymag(msg);
  617. highres_imu->zmag = mavlink_msg_highres_imu_get_zmag(msg);
  618. highres_imu->abs_pressure = mavlink_msg_highres_imu_get_abs_pressure(msg);
  619. highres_imu->diff_pressure = mavlink_msg_highres_imu_get_diff_pressure(msg);
  620. highres_imu->pressure_alt = mavlink_msg_highres_imu_get_pressure_alt(msg);
  621. highres_imu->temperature = mavlink_msg_highres_imu_get_temperature(msg);
  622. highres_imu->fields_updated = mavlink_msg_highres_imu_get_fields_updated(msg);
  623. highres_imu->id = mavlink_msg_highres_imu_get_id(msg);
  624. #else
  625. uint8_t len = msg->len < MAVLINK_MSG_ID_HIGHRES_IMU_LEN? msg->len : MAVLINK_MSG_ID_HIGHRES_IMU_LEN;
  626. memset(highres_imu, 0, MAVLINK_MSG_ID_HIGHRES_IMU_LEN);
  627. memcpy(highres_imu, _MAV_PAYLOAD(msg), len);
  628. #endif
  629. }