/mavlink/include/common/mavlink_msg_scaled_imu.h

https://github.com/flixr/mavlink-ivy-interface · C Header · 342 lines · 191 code · 34 blank · 117 comment · 3 complexity · 4dc1552471ec1056720d6b3ebe571d20 MD5 · raw file

  1. // MESSAGE SCALED_IMU PACKING
  2. #define MAVLINK_MSG_ID_SCALED_IMU 26
  3. typedef struct __mavlink_scaled_imu_t
  4. {
  5. uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot)
  6. int16_t xacc; ///< X acceleration (mg)
  7. int16_t yacc; ///< Y acceleration (mg)
  8. int16_t zacc; ///< Z acceleration (mg)
  9. int16_t xgyro; ///< Angular speed around X axis (millirad /sec)
  10. int16_t ygyro; ///< Angular speed around Y axis (millirad /sec)
  11. int16_t zgyro; ///< Angular speed around Z axis (millirad /sec)
  12. int16_t xmag; ///< X Magnetic field (milli tesla)
  13. int16_t ymag; ///< Y Magnetic field (milli tesla)
  14. int16_t zmag; ///< Z Magnetic field (milli tesla)
  15. } mavlink_scaled_imu_t;
  16. #define MAVLINK_MSG_ID_SCALED_IMU_LEN 22
  17. #define MAVLINK_MSG_ID_26_LEN 22
  18. #define MAVLINK_MESSAGE_INFO_SCALED_IMU { \
  19. "SCALED_IMU", \
  20. 10, \
  21. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_scaled_imu_t, time_boot_ms) }, \
  22. { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_scaled_imu_t, xacc) }, \
  23. { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_scaled_imu_t, yacc) }, \
  24. { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 8, offsetof(mavlink_scaled_imu_t, zacc) }, \
  25. { "xgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 10, offsetof(mavlink_scaled_imu_t, xgyro) }, \
  26. { "ygyro", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_scaled_imu_t, ygyro) }, \
  27. { "zgyro", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_scaled_imu_t, zgyro) }, \
  28. { "xmag", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_scaled_imu_t, xmag) }, \
  29. { "ymag", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_scaled_imu_t, ymag) }, \
  30. { "zmag", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_scaled_imu_t, zmag) }, \
  31. } \
  32. }
  33. /**
  34. * @brief Pack a scaled_imu message
  35. * @param system_id ID of this system
  36. * @param component_id ID of this component (e.g. 200 for IMU)
  37. * @param msg The MAVLink message to compress the data into
  38. *
  39. * @param time_boot_ms Timestamp (milliseconds since system boot)
  40. * @param xacc X acceleration (mg)
  41. * @param yacc Y acceleration (mg)
  42. * @param zacc Z acceleration (mg)
  43. * @param xgyro Angular speed around X axis (millirad /sec)
  44. * @param ygyro Angular speed around Y axis (millirad /sec)
  45. * @param zgyro Angular speed around Z axis (millirad /sec)
  46. * @param xmag X Magnetic field (milli tesla)
  47. * @param ymag Y Magnetic field (milli tesla)
  48. * @param zmag Z Magnetic field (milli tesla)
  49. * @return length of the message in bytes (excluding serial stream start sign)
  50. */
  51. static inline uint16_t mavlink_msg_scaled_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  52. uint32_t time_boot_ms, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag)
  53. {
  54. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  55. char buf[22];
  56. _mav_put_uint32_t(buf, 0, time_boot_ms);
  57. _mav_put_int16_t(buf, 4, xacc);
  58. _mav_put_int16_t(buf, 6, yacc);
  59. _mav_put_int16_t(buf, 8, zacc);
  60. _mav_put_int16_t(buf, 10, xgyro);
  61. _mav_put_int16_t(buf, 12, ygyro);
  62. _mav_put_int16_t(buf, 14, zgyro);
  63. _mav_put_int16_t(buf, 16, xmag);
  64. _mav_put_int16_t(buf, 18, ymag);
  65. _mav_put_int16_t(buf, 20, zmag);
  66. memcpy(_MAV_PAYLOAD(msg), buf, 22);
  67. #else
  68. mavlink_scaled_imu_t packet;
  69. packet.time_boot_ms = time_boot_ms;
  70. packet.xacc = xacc;
  71. packet.yacc = yacc;
  72. packet.zacc = zacc;
  73. packet.xgyro = xgyro;
  74. packet.ygyro = ygyro;
  75. packet.zgyro = zgyro;
  76. packet.xmag = xmag;
  77. packet.ymag = ymag;
  78. packet.zmag = zmag;
  79. memcpy(_MAV_PAYLOAD(msg), &packet, 22);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_SCALED_IMU;
  82. return mavlink_finalize_message(msg, system_id, component_id, 22, 170);
  83. }
  84. /**
  85. * @brief Pack a scaled_imu message on a channel
  86. * @param system_id ID of this system
  87. * @param component_id ID of this component (e.g. 200 for IMU)
  88. * @param chan The MAVLink channel this message was sent over
  89. * @param msg The MAVLink message to compress the data into
  90. * @param time_boot_ms Timestamp (milliseconds since system boot)
  91. * @param xacc X acceleration (mg)
  92. * @param yacc Y acceleration (mg)
  93. * @param zacc Z acceleration (mg)
  94. * @param xgyro Angular speed around X axis (millirad /sec)
  95. * @param ygyro Angular speed around Y axis (millirad /sec)
  96. * @param zgyro Angular speed around Z axis (millirad /sec)
  97. * @param xmag X Magnetic field (milli tesla)
  98. * @param ymag Y Magnetic field (milli tesla)
  99. * @param zmag Z Magnetic field (milli tesla)
  100. * @return length of the message in bytes (excluding serial stream start sign)
  101. */
  102. static inline uint16_t mavlink_msg_scaled_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  103. mavlink_message_t* msg,
  104. uint32_t time_boot_ms,int16_t xacc,int16_t yacc,int16_t zacc,int16_t xgyro,int16_t ygyro,int16_t zgyro,int16_t xmag,int16_t ymag,int16_t zmag)
  105. {
  106. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  107. char buf[22];
  108. _mav_put_uint32_t(buf, 0, time_boot_ms);
  109. _mav_put_int16_t(buf, 4, xacc);
  110. _mav_put_int16_t(buf, 6, yacc);
  111. _mav_put_int16_t(buf, 8, zacc);
  112. _mav_put_int16_t(buf, 10, xgyro);
  113. _mav_put_int16_t(buf, 12, ygyro);
  114. _mav_put_int16_t(buf, 14, zgyro);
  115. _mav_put_int16_t(buf, 16, xmag);
  116. _mav_put_int16_t(buf, 18, ymag);
  117. _mav_put_int16_t(buf, 20, zmag);
  118. memcpy(_MAV_PAYLOAD(msg), buf, 22);
  119. #else
  120. mavlink_scaled_imu_t packet;
  121. packet.time_boot_ms = time_boot_ms;
  122. packet.xacc = xacc;
  123. packet.yacc = yacc;
  124. packet.zacc = zacc;
  125. packet.xgyro = xgyro;
  126. packet.ygyro = ygyro;
  127. packet.zgyro = zgyro;
  128. packet.xmag = xmag;
  129. packet.ymag = ymag;
  130. packet.zmag = zmag;
  131. memcpy(_MAV_PAYLOAD(msg), &packet, 22);
  132. #endif
  133. msg->msgid = MAVLINK_MSG_ID_SCALED_IMU;
  134. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 22, 170);
  135. }
  136. /**
  137. * @brief Encode a scaled_imu struct into a message
  138. *
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param msg The MAVLink message to compress the data into
  142. * @param scaled_imu C-struct to read the message contents from
  143. */
  144. static inline uint16_t mavlink_msg_scaled_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_scaled_imu_t* scaled_imu)
  145. {
  146. return mavlink_msg_scaled_imu_pack(system_id, component_id, msg, scaled_imu->time_boot_ms, scaled_imu->xacc, scaled_imu->yacc, scaled_imu->zacc, scaled_imu->xgyro, scaled_imu->ygyro, scaled_imu->zgyro, scaled_imu->xmag, scaled_imu->ymag, scaled_imu->zmag);
  147. }
  148. /**
  149. * @brief Send a scaled_imu message
  150. * @param chan MAVLink channel to send the message
  151. *
  152. * @param time_boot_ms Timestamp (milliseconds since system boot)
  153. * @param xacc X acceleration (mg)
  154. * @param yacc Y acceleration (mg)
  155. * @param zacc Z acceleration (mg)
  156. * @param xgyro Angular speed around X axis (millirad /sec)
  157. * @param ygyro Angular speed around Y axis (millirad /sec)
  158. * @param zgyro Angular speed around Z axis (millirad /sec)
  159. * @param xmag X Magnetic field (milli tesla)
  160. * @param ymag Y Magnetic field (milli tesla)
  161. * @param zmag Z Magnetic field (milli tesla)
  162. */
  163. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  164. static inline void mavlink_msg_scaled_imu_send(mavlink_channel_t chan, uint32_t time_boot_ms, int16_t xacc, int16_t yacc, int16_t zacc, int16_t xgyro, int16_t ygyro, int16_t zgyro, int16_t xmag, int16_t ymag, int16_t zmag)
  165. {
  166. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  167. char buf[22];
  168. _mav_put_uint32_t(buf, 0, time_boot_ms);
  169. _mav_put_int16_t(buf, 4, xacc);
  170. _mav_put_int16_t(buf, 6, yacc);
  171. _mav_put_int16_t(buf, 8, zacc);
  172. _mav_put_int16_t(buf, 10, xgyro);
  173. _mav_put_int16_t(buf, 12, ygyro);
  174. _mav_put_int16_t(buf, 14, zgyro);
  175. _mav_put_int16_t(buf, 16, xmag);
  176. _mav_put_int16_t(buf, 18, ymag);
  177. _mav_put_int16_t(buf, 20, zmag);
  178. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_IMU, buf, 22, 170);
  179. #else
  180. mavlink_scaled_imu_t packet;
  181. packet.time_boot_ms = time_boot_ms;
  182. packet.xacc = xacc;
  183. packet.yacc = yacc;
  184. packet.zacc = zacc;
  185. packet.xgyro = xgyro;
  186. packet.ygyro = ygyro;
  187. packet.zgyro = zgyro;
  188. packet.xmag = xmag;
  189. packet.ymag = ymag;
  190. packet.zmag = zmag;
  191. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SCALED_IMU, (const char *)&packet, 22, 170);
  192. #endif
  193. }
  194. #endif
  195. // MESSAGE SCALED_IMU UNPACKING
  196. /**
  197. * @brief Get field time_boot_ms from scaled_imu message
  198. *
  199. * @return Timestamp (milliseconds since system boot)
  200. */
  201. static inline uint32_t mavlink_msg_scaled_imu_get_time_boot_ms(const mavlink_message_t* msg)
  202. {
  203. return _MAV_RETURN_uint32_t(msg, 0);
  204. }
  205. /**
  206. * @brief Get field xacc from scaled_imu message
  207. *
  208. * @return X acceleration (mg)
  209. */
  210. static inline int16_t mavlink_msg_scaled_imu_get_xacc(const mavlink_message_t* msg)
  211. {
  212. return _MAV_RETURN_int16_t(msg, 4);
  213. }
  214. /**
  215. * @brief Get field yacc from scaled_imu message
  216. *
  217. * @return Y acceleration (mg)
  218. */
  219. static inline int16_t mavlink_msg_scaled_imu_get_yacc(const mavlink_message_t* msg)
  220. {
  221. return _MAV_RETURN_int16_t(msg, 6);
  222. }
  223. /**
  224. * @brief Get field zacc from scaled_imu message
  225. *
  226. * @return Z acceleration (mg)
  227. */
  228. static inline int16_t mavlink_msg_scaled_imu_get_zacc(const mavlink_message_t* msg)
  229. {
  230. return _MAV_RETURN_int16_t(msg, 8);
  231. }
  232. /**
  233. * @brief Get field xgyro from scaled_imu message
  234. *
  235. * @return Angular speed around X axis (millirad /sec)
  236. */
  237. static inline int16_t mavlink_msg_scaled_imu_get_xgyro(const mavlink_message_t* msg)
  238. {
  239. return _MAV_RETURN_int16_t(msg, 10);
  240. }
  241. /**
  242. * @brief Get field ygyro from scaled_imu message
  243. *
  244. * @return Angular speed around Y axis (millirad /sec)
  245. */
  246. static inline int16_t mavlink_msg_scaled_imu_get_ygyro(const mavlink_message_t* msg)
  247. {
  248. return _MAV_RETURN_int16_t(msg, 12);
  249. }
  250. /**
  251. * @brief Get field zgyro from scaled_imu message
  252. *
  253. * @return Angular speed around Z axis (millirad /sec)
  254. */
  255. static inline int16_t mavlink_msg_scaled_imu_get_zgyro(const mavlink_message_t* msg)
  256. {
  257. return _MAV_RETURN_int16_t(msg, 14);
  258. }
  259. /**
  260. * @brief Get field xmag from scaled_imu message
  261. *
  262. * @return X Magnetic field (milli tesla)
  263. */
  264. static inline int16_t mavlink_msg_scaled_imu_get_xmag(const mavlink_message_t* msg)
  265. {
  266. return _MAV_RETURN_int16_t(msg, 16);
  267. }
  268. /**
  269. * @brief Get field ymag from scaled_imu message
  270. *
  271. * @return Y Magnetic field (milli tesla)
  272. */
  273. static inline int16_t mavlink_msg_scaled_imu_get_ymag(const mavlink_message_t* msg)
  274. {
  275. return _MAV_RETURN_int16_t(msg, 18);
  276. }
  277. /**
  278. * @brief Get field zmag from scaled_imu message
  279. *
  280. * @return Z Magnetic field (milli tesla)
  281. */
  282. static inline int16_t mavlink_msg_scaled_imu_get_zmag(const mavlink_message_t* msg)
  283. {
  284. return _MAV_RETURN_int16_t(msg, 20);
  285. }
  286. /**
  287. * @brief Decode a scaled_imu message into a struct
  288. *
  289. * @param msg The message to decode
  290. * @param scaled_imu C-struct to decode the message contents into
  291. */
  292. static inline void mavlink_msg_scaled_imu_decode(const mavlink_message_t* msg, mavlink_scaled_imu_t* scaled_imu)
  293. {
  294. #if MAVLINK_NEED_BYTE_SWAP
  295. scaled_imu->time_boot_ms = mavlink_msg_scaled_imu_get_time_boot_ms(msg);
  296. scaled_imu->xacc = mavlink_msg_scaled_imu_get_xacc(msg);
  297. scaled_imu->yacc = mavlink_msg_scaled_imu_get_yacc(msg);
  298. scaled_imu->zacc = mavlink_msg_scaled_imu_get_zacc(msg);
  299. scaled_imu->xgyro = mavlink_msg_scaled_imu_get_xgyro(msg);
  300. scaled_imu->ygyro = mavlink_msg_scaled_imu_get_ygyro(msg);
  301. scaled_imu->zgyro = mavlink_msg_scaled_imu_get_zgyro(msg);
  302. scaled_imu->xmag = mavlink_msg_scaled_imu_get_xmag(msg);
  303. scaled_imu->ymag = mavlink_msg_scaled_imu_get_ymag(msg);
  304. scaled_imu->zmag = mavlink_msg_scaled_imu_get_zmag(msg);
  305. #else
  306. memcpy(scaled_imu, _MAV_PAYLOAD(msg), 22);
  307. #endif
  308. }