You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
14 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE AHRS PACKING
  3. #define MAVLINK_MSG_ID_AHRS 163
  4. MAVPACKED(
  5. typedef struct __mavlink_ahrs_t {
  6. float omegaIx; /*< [rad/s] X gyro drift estimate.*/
  7. float omegaIy; /*< [rad/s] Y gyro drift estimate.*/
  8. float omegaIz; /*< [rad/s] Z gyro drift estimate.*/
  9. float accel_weight; /*< Average accel_weight.*/
  10. float renorm_val; /*< Average renormalisation value.*/
  11. float error_rp; /*< Average error_roll_pitch value.*/
  12. float error_yaw; /*< Average error_yaw value.*/
  13. }) mavlink_ahrs_t;
  14. #define MAVLINK_MSG_ID_AHRS_LEN 28
  15. #define MAVLINK_MSG_ID_AHRS_MIN_LEN 28
  16. #define MAVLINK_MSG_ID_163_LEN 28
  17. #define MAVLINK_MSG_ID_163_MIN_LEN 28
  18. #define MAVLINK_MSG_ID_AHRS_CRC 127
  19. #define MAVLINK_MSG_ID_163_CRC 127
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_AHRS { \
  22. 163, \
  23. "AHRS", \
  24. 7, \
  25. { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \
  26. { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \
  27. { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \
  28. { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \
  29. { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \
  30. { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \
  31. { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \
  32. } \
  33. }
  34. #else
  35. #define MAVLINK_MESSAGE_INFO_AHRS { \
  36. "AHRS", \
  37. 7, \
  38. { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \
  39. { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \
  40. { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \
  41. { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \
  42. { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \
  43. { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \
  44. { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \
  45. } \
  46. }
  47. #endif
  48. /**
  49. * @brief Pack a ahrs message
  50. * @param system_id ID of this system
  51. * @param component_id ID of this component (e.g. 200 for IMU)
  52. * @param msg The MAVLink message to compress the data into
  53. *
  54. * @param omegaIx [rad/s] X gyro drift estimate.
  55. * @param omegaIy [rad/s] Y gyro drift estimate.
  56. * @param omegaIz [rad/s] Z gyro drift estimate.
  57. * @param accel_weight Average accel_weight.
  58. * @param renorm_val Average renormalisation value.
  59. * @param error_rp Average error_roll_pitch value.
  60. * @param error_yaw Average error_yaw value.
  61. * @return length of the message in bytes (excluding serial stream start sign)
  62. */
  63. static inline uint16_t mavlink_msg_ahrs_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  64. float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
  65. {
  66. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  67. char buf[MAVLINK_MSG_ID_AHRS_LEN];
  68. _mav_put_float(buf, 0, omegaIx);
  69. _mav_put_float(buf, 4, omegaIy);
  70. _mav_put_float(buf, 8, omegaIz);
  71. _mav_put_float(buf, 12, accel_weight);
  72. _mav_put_float(buf, 16, renorm_val);
  73. _mav_put_float(buf, 20, error_rp);
  74. _mav_put_float(buf, 24, error_yaw);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS_LEN);
  76. #else
  77. mavlink_ahrs_t packet;
  78. packet.omegaIx = omegaIx;
  79. packet.omegaIy = omegaIy;
  80. packet.omegaIz = omegaIz;
  81. packet.accel_weight = accel_weight;
  82. packet.renorm_val = renorm_val;
  83. packet.error_rp = error_rp;
  84. packet.error_yaw = error_yaw;
  85. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS_LEN);
  86. #endif
  87. msg->msgid = MAVLINK_MSG_ID_AHRS;
  88. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  89. }
  90. /**
  91. * @brief Pack a ahrs message on a channel
  92. * @param system_id ID of this system
  93. * @param component_id ID of this component (e.g. 200 for IMU)
  94. * @param chan The MAVLink channel this message will be sent over
  95. * @param msg The MAVLink message to compress the data into
  96. * @param omegaIx [rad/s] X gyro drift estimate.
  97. * @param omegaIy [rad/s] Y gyro drift estimate.
  98. * @param omegaIz [rad/s] Z gyro drift estimate.
  99. * @param accel_weight Average accel_weight.
  100. * @param renorm_val Average renormalisation value.
  101. * @param error_rp Average error_roll_pitch value.
  102. * @param error_yaw Average error_yaw value.
  103. * @return length of the message in bytes (excluding serial stream start sign)
  104. */
  105. static inline uint16_t mavlink_msg_ahrs_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  106. mavlink_message_t* msg,
  107. float omegaIx,float omegaIy,float omegaIz,float accel_weight,float renorm_val,float error_rp,float error_yaw)
  108. {
  109. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  110. char buf[MAVLINK_MSG_ID_AHRS_LEN];
  111. _mav_put_float(buf, 0, omegaIx);
  112. _mav_put_float(buf, 4, omegaIy);
  113. _mav_put_float(buf, 8, omegaIz);
  114. _mav_put_float(buf, 12, accel_weight);
  115. _mav_put_float(buf, 16, renorm_val);
  116. _mav_put_float(buf, 20, error_rp);
  117. _mav_put_float(buf, 24, error_yaw);
  118. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS_LEN);
  119. #else
  120. mavlink_ahrs_t packet;
  121. packet.omegaIx = omegaIx;
  122. packet.omegaIy = omegaIy;
  123. packet.omegaIz = omegaIz;
  124. packet.accel_weight = accel_weight;
  125. packet.renorm_val = renorm_val;
  126. packet.error_rp = error_rp;
  127. packet.error_yaw = error_yaw;
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_AHRS;
  131. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  132. }
  133. /**
  134. * @brief Encode a ahrs struct
  135. *
  136. * @param system_id ID of this system
  137. * @param component_id ID of this component (e.g. 200 for IMU)
  138. * @param msg The MAVLink message to compress the data into
  139. * @param ahrs C-struct to read the message contents from
  140. */
  141. static inline uint16_t mavlink_msg_ahrs_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs)
  142. {
  143. return mavlink_msg_ahrs_pack(system_id, component_id, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
  144. }
  145. /**
  146. * @brief Encode a ahrs struct on a channel
  147. *
  148. * @param system_id ID of this system
  149. * @param component_id ID of this component (e.g. 200 for IMU)
  150. * @param chan The MAVLink channel this message will be sent over
  151. * @param msg The MAVLink message to compress the data into
  152. * @param ahrs C-struct to read the message contents from
  153. */
  154. static inline uint16_t mavlink_msg_ahrs_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs)
  155. {
  156. return mavlink_msg_ahrs_pack_chan(system_id, component_id, chan, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
  157. }
  158. /**
  159. * @brief Send a ahrs message
  160. * @param chan MAVLink channel to send the message
  161. *
  162. * @param omegaIx [rad/s] X gyro drift estimate.
  163. * @param omegaIy [rad/s] Y gyro drift estimate.
  164. * @param omegaIz [rad/s] Z gyro drift estimate.
  165. * @param accel_weight Average accel_weight.
  166. * @param renorm_val Average renormalisation value.
  167. * @param error_rp Average error_roll_pitch value.
  168. * @param error_yaw Average error_yaw value.
  169. */
  170. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  171. static inline void mavlink_msg_ahrs_send(mavlink_channel_t chan, float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
  172. {
  173. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  174. char buf[MAVLINK_MSG_ID_AHRS_LEN];
  175. _mav_put_float(buf, 0, omegaIx);
  176. _mav_put_float(buf, 4, omegaIy);
  177. _mav_put_float(buf, 8, omegaIz);
  178. _mav_put_float(buf, 12, accel_weight);
  179. _mav_put_float(buf, 16, renorm_val);
  180. _mav_put_float(buf, 20, error_rp);
  181. _mav_put_float(buf, 24, error_yaw);
  182. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  183. #else
  184. mavlink_ahrs_t packet;
  185. packet.omegaIx = omegaIx;
  186. packet.omegaIy = omegaIy;
  187. packet.omegaIz = omegaIz;
  188. packet.accel_weight = accel_weight;
  189. packet.renorm_val = renorm_val;
  190. packet.error_rp = error_rp;
  191. packet.error_yaw = error_yaw;
  192. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)&packet, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  193. #endif
  194. }
  195. /**
  196. * @brief Send a ahrs message
  197. * @param chan MAVLink channel to send the message
  198. * @param struct The MAVLink struct to serialize
  199. */
  200. static inline void mavlink_msg_ahrs_send_struct(mavlink_channel_t chan, const mavlink_ahrs_t* ahrs)
  201. {
  202. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  203. mavlink_msg_ahrs_send(chan, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
  204. #else
  205. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)ahrs, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  206. #endif
  207. }
  208. #if MAVLINK_MSG_ID_AHRS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  209. /*
  210. This varient of _send() can be used to save stack space by re-using
  211. memory from the receive buffer. The caller provides a
  212. mavlink_message_t which is the size of a full mavlink message. This
  213. is usually the receive buffer for the channel, and allows a reply to an
  214. incoming message with minimum stack space usage.
  215. */
  216. static inline void mavlink_msg_ahrs_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  219. char *buf = (char *)msgbuf;
  220. _mav_put_float(buf, 0, omegaIx);
  221. _mav_put_float(buf, 4, omegaIy);
  222. _mav_put_float(buf, 8, omegaIz);
  223. _mav_put_float(buf, 12, accel_weight);
  224. _mav_put_float(buf, 16, renorm_val);
  225. _mav_put_float(buf, 20, error_rp);
  226. _mav_put_float(buf, 24, error_yaw);
  227. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  228. #else
  229. mavlink_ahrs_t *packet = (mavlink_ahrs_t *)msgbuf;
  230. packet->omegaIx = omegaIx;
  231. packet->omegaIy = omegaIy;
  232. packet->omegaIz = omegaIz;
  233. packet->accel_weight = accel_weight;
  234. packet->renorm_val = renorm_val;
  235. packet->error_rp = error_rp;
  236. packet->error_yaw = error_yaw;
  237. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)packet, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
  238. #endif
  239. }
  240. #endif
  241. #endif
  242. // MESSAGE AHRS UNPACKING
  243. /**
  244. * @brief Get field omegaIx from ahrs message
  245. *
  246. * @return [rad/s] X gyro drift estimate.
  247. */
  248. static inline float mavlink_msg_ahrs_get_omegaIx(const mavlink_message_t* msg)
  249. {
  250. return _MAV_RETURN_float(msg, 0);
  251. }
  252. /**
  253. * @brief Get field omegaIy from ahrs message
  254. *
  255. * @return [rad/s] Y gyro drift estimate.
  256. */
  257. static inline float mavlink_msg_ahrs_get_omegaIy(const mavlink_message_t* msg)
  258. {
  259. return _MAV_RETURN_float(msg, 4);
  260. }
  261. /**
  262. * @brief Get field omegaIz from ahrs message
  263. *
  264. * @return [rad/s] Z gyro drift estimate.
  265. */
  266. static inline float mavlink_msg_ahrs_get_omegaIz(const mavlink_message_t* msg)
  267. {
  268. return _MAV_RETURN_float(msg, 8);
  269. }
  270. /**
  271. * @brief Get field accel_weight from ahrs message
  272. *
  273. * @return Average accel_weight.
  274. */
  275. static inline float mavlink_msg_ahrs_get_accel_weight(const mavlink_message_t* msg)
  276. {
  277. return _MAV_RETURN_float(msg, 12);
  278. }
  279. /**
  280. * @brief Get field renorm_val from ahrs message
  281. *
  282. * @return Average renormalisation value.
  283. */
  284. static inline float mavlink_msg_ahrs_get_renorm_val(const mavlink_message_t* msg)
  285. {
  286. return _MAV_RETURN_float(msg, 16);
  287. }
  288. /**
  289. * @brief Get field error_rp from ahrs message
  290. *
  291. * @return Average error_roll_pitch value.
  292. */
  293. static inline float mavlink_msg_ahrs_get_error_rp(const mavlink_message_t* msg)
  294. {
  295. return _MAV_RETURN_float(msg, 20);
  296. }
  297. /**
  298. * @brief Get field error_yaw from ahrs message
  299. *
  300. * @return Average error_yaw value.
  301. */
  302. static inline float mavlink_msg_ahrs_get_error_yaw(const mavlink_message_t* msg)
  303. {
  304. return _MAV_RETURN_float(msg, 24);
  305. }
  306. /**
  307. * @brief Decode a ahrs message into a struct
  308. *
  309. * @param msg The message to decode
  310. * @param ahrs C-struct to decode the message contents into
  311. */
  312. static inline void mavlink_msg_ahrs_decode(const mavlink_message_t* msg, mavlink_ahrs_t* ahrs)
  313. {
  314. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  315. ahrs->omegaIx = mavlink_msg_ahrs_get_omegaIx(msg);
  316. ahrs->omegaIy = mavlink_msg_ahrs_get_omegaIy(msg);
  317. ahrs->omegaIz = mavlink_msg_ahrs_get_omegaIz(msg);
  318. ahrs->accel_weight = mavlink_msg_ahrs_get_accel_weight(msg);
  319. ahrs->renorm_val = mavlink_msg_ahrs_get_renorm_val(msg);
  320. ahrs->error_rp = mavlink_msg_ahrs_get_error_rp(msg);
  321. ahrs->error_yaw = mavlink_msg_ahrs_get_error_yaw(msg);
  322. #else
  323. uint8_t len = msg->len < MAVLINK_MSG_ID_AHRS_LEN? msg->len : MAVLINK_MSG_ID_AHRS_LEN;
  324. memset(ahrs, 0, MAVLINK_MSG_ID_AHRS_LEN);
  325. memcpy(ahrs, _MAV_PAYLOAD(msg), len);
  326. #endif
  327. }