/libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/mavlink_msg_ahrs.h

https://github.com/pchickey/purple-ardupilot-mega · C Header · 276 lines · 152 code · 31 blank · 93 comment · 3 complexity · 7e492b8af835e0fe2b6fdfc30fb01d17 MD5 · raw file

  1. // MESSAGE AHRS PACKING
  2. #define MAVLINK_MSG_ID_AHRS 163
  3. typedef struct __mavlink_ahrs_t
  4. {
  5. float omegaIx; ///< X gyro drift estimate rad/s
  6. float omegaIy; ///< Y gyro drift estimate rad/s
  7. float omegaIz; ///< Z gyro drift estimate rad/s
  8. float accel_weight; ///< average accel_weight
  9. float renorm_val; ///< average renormalisation value
  10. float error_rp; ///< average error_roll_pitch value
  11. float error_yaw; ///< average error_yaw value
  12. } mavlink_ahrs_t;
  13. #define MAVLINK_MSG_ID_AHRS_LEN 28
  14. #define MAVLINK_MSG_ID_163_LEN 28
  15. #define MAVLINK_MESSAGE_INFO_AHRS { \
  16. "AHRS", \
  17. 7, \
  18. { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \
  19. { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \
  20. { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \
  21. { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \
  22. { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \
  23. { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \
  24. { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \
  25. } \
  26. }
  27. /**
  28. * @brief Pack a ahrs message
  29. * @param system_id ID of this system
  30. * @param component_id ID of this component (e.g. 200 for IMU)
  31. * @param msg The MAVLink message to compress the data into
  32. *
  33. * @param omegaIx X gyro drift estimate rad/s
  34. * @param omegaIy Y gyro drift estimate rad/s
  35. * @param omegaIz Z gyro drift estimate rad/s
  36. * @param accel_weight average accel_weight
  37. * @param renorm_val average renormalisation value
  38. * @param error_rp average error_roll_pitch value
  39. * @param error_yaw average error_yaw value
  40. * @return length of the message in bytes (excluding serial stream start sign)
  41. */
  42. static inline uint16_t mavlink_msg_ahrs_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  43. float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
  44. {
  45. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  46. char buf[28];
  47. _mav_put_float(buf, 0, omegaIx);
  48. _mav_put_float(buf, 4, omegaIy);
  49. _mav_put_float(buf, 8, omegaIz);
  50. _mav_put_float(buf, 12, accel_weight);
  51. _mav_put_float(buf, 16, renorm_val);
  52. _mav_put_float(buf, 20, error_rp);
  53. _mav_put_float(buf, 24, error_yaw);
  54. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
  55. #else
  56. mavlink_ahrs_t packet;
  57. packet.omegaIx = omegaIx;
  58. packet.omegaIy = omegaIy;
  59. packet.omegaIz = omegaIz;
  60. packet.accel_weight = accel_weight;
  61. packet.renorm_val = renorm_val;
  62. packet.error_rp = error_rp;
  63. packet.error_yaw = error_yaw;
  64. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
  65. #endif
  66. msg->msgid = MAVLINK_MSG_ID_AHRS;
  67. return mavlink_finalize_message(msg, system_id, component_id, 28);
  68. }
  69. /**
  70. * @brief Pack a ahrs message on a channel
  71. * @param system_id ID of this system
  72. * @param component_id ID of this component (e.g. 200 for IMU)
  73. * @param chan The MAVLink channel this message was sent over
  74. * @param msg The MAVLink message to compress the data into
  75. * @param omegaIx X gyro drift estimate rad/s
  76. * @param omegaIy Y gyro drift estimate rad/s
  77. * @param omegaIz Z gyro drift estimate rad/s
  78. * @param accel_weight average accel_weight
  79. * @param renorm_val average renormalisation value
  80. * @param error_rp average error_roll_pitch value
  81. * @param error_yaw average error_yaw value
  82. * @return length of the message in bytes (excluding serial stream start sign)
  83. */
  84. static inline uint16_t mavlink_msg_ahrs_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  85. mavlink_message_t* msg,
  86. float omegaIx,float omegaIy,float omegaIz,float accel_weight,float renorm_val,float error_rp,float error_yaw)
  87. {
  88. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  89. char buf[28];
  90. _mav_put_float(buf, 0, omegaIx);
  91. _mav_put_float(buf, 4, omegaIy);
  92. _mav_put_float(buf, 8, omegaIz);
  93. _mav_put_float(buf, 12, accel_weight);
  94. _mav_put_float(buf, 16, renorm_val);
  95. _mav_put_float(buf, 20, error_rp);
  96. _mav_put_float(buf, 24, error_yaw);
  97. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28);
  98. #else
  99. mavlink_ahrs_t packet;
  100. packet.omegaIx = omegaIx;
  101. packet.omegaIy = omegaIy;
  102. packet.omegaIz = omegaIz;
  103. packet.accel_weight = accel_weight;
  104. packet.renorm_val = renorm_val;
  105. packet.error_rp = error_rp;
  106. packet.error_yaw = error_yaw;
  107. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28);
  108. #endif
  109. msg->msgid = MAVLINK_MSG_ID_AHRS;
  110. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28);
  111. }
  112. /**
  113. * @brief Encode a ahrs struct into a message
  114. *
  115. * @param system_id ID of this system
  116. * @param component_id ID of this component (e.g. 200 for IMU)
  117. * @param msg The MAVLink message to compress the data into
  118. * @param ahrs C-struct to read the message contents from
  119. */
  120. 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)
  121. {
  122. 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);
  123. }
  124. /**
  125. * @brief Send a ahrs message
  126. * @param chan MAVLink channel to send the message
  127. *
  128. * @param omegaIx X gyro drift estimate rad/s
  129. * @param omegaIy Y gyro drift estimate rad/s
  130. * @param omegaIz Z gyro drift estimate rad/s
  131. * @param accel_weight average accel_weight
  132. * @param renorm_val average renormalisation value
  133. * @param error_rp average error_roll_pitch value
  134. * @param error_yaw average error_yaw value
  135. */
  136. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  137. 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)
  138. {
  139. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  140. char buf[28];
  141. _mav_put_float(buf, 0, omegaIx);
  142. _mav_put_float(buf, 4, omegaIy);
  143. _mav_put_float(buf, 8, omegaIz);
  144. _mav_put_float(buf, 12, accel_weight);
  145. _mav_put_float(buf, 16, renorm_val);
  146. _mav_put_float(buf, 20, error_rp);
  147. _mav_put_float(buf, 24, error_yaw);
  148. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, 28);
  149. #else
  150. mavlink_ahrs_t packet;
  151. packet.omegaIx = omegaIx;
  152. packet.omegaIy = omegaIy;
  153. packet.omegaIz = omegaIz;
  154. packet.accel_weight = accel_weight;
  155. packet.renorm_val = renorm_val;
  156. packet.error_rp = error_rp;
  157. packet.error_yaw = error_yaw;
  158. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)&packet, 28);
  159. #endif
  160. }
  161. #endif
  162. // MESSAGE AHRS UNPACKING
  163. /**
  164. * @brief Get field omegaIx from ahrs message
  165. *
  166. * @return X gyro drift estimate rad/s
  167. */
  168. static inline float mavlink_msg_ahrs_get_omegaIx(const mavlink_message_t* msg)
  169. {
  170. return _MAV_RETURN_float(msg, 0);
  171. }
  172. /**
  173. * @brief Get field omegaIy from ahrs message
  174. *
  175. * @return Y gyro drift estimate rad/s
  176. */
  177. static inline float mavlink_msg_ahrs_get_omegaIy(const mavlink_message_t* msg)
  178. {
  179. return _MAV_RETURN_float(msg, 4);
  180. }
  181. /**
  182. * @brief Get field omegaIz from ahrs message
  183. *
  184. * @return Z gyro drift estimate rad/s
  185. */
  186. static inline float mavlink_msg_ahrs_get_omegaIz(const mavlink_message_t* msg)
  187. {
  188. return _MAV_RETURN_float(msg, 8);
  189. }
  190. /**
  191. * @brief Get field accel_weight from ahrs message
  192. *
  193. * @return average accel_weight
  194. */
  195. static inline float mavlink_msg_ahrs_get_accel_weight(const mavlink_message_t* msg)
  196. {
  197. return _MAV_RETURN_float(msg, 12);
  198. }
  199. /**
  200. * @brief Get field renorm_val from ahrs message
  201. *
  202. * @return average renormalisation value
  203. */
  204. static inline float mavlink_msg_ahrs_get_renorm_val(const mavlink_message_t* msg)
  205. {
  206. return _MAV_RETURN_float(msg, 16);
  207. }
  208. /**
  209. * @brief Get field error_rp from ahrs message
  210. *
  211. * @return average error_roll_pitch value
  212. */
  213. static inline float mavlink_msg_ahrs_get_error_rp(const mavlink_message_t* msg)
  214. {
  215. return _MAV_RETURN_float(msg, 20);
  216. }
  217. /**
  218. * @brief Get field error_yaw from ahrs message
  219. *
  220. * @return average error_yaw value
  221. */
  222. static inline float mavlink_msg_ahrs_get_error_yaw(const mavlink_message_t* msg)
  223. {
  224. return _MAV_RETURN_float(msg, 24);
  225. }
  226. /**
  227. * @brief Decode a ahrs message into a struct
  228. *
  229. * @param msg The message to decode
  230. * @param ahrs C-struct to decode the message contents into
  231. */
  232. static inline void mavlink_msg_ahrs_decode(const mavlink_message_t* msg, mavlink_ahrs_t* ahrs)
  233. {
  234. #if MAVLINK_NEED_BYTE_SWAP
  235. ahrs->omegaIx = mavlink_msg_ahrs_get_omegaIx(msg);
  236. ahrs->omegaIy = mavlink_msg_ahrs_get_omegaIy(msg);
  237. ahrs->omegaIz = mavlink_msg_ahrs_get_omegaIz(msg);
  238. ahrs->accel_weight = mavlink_msg_ahrs_get_accel_weight(msg);
  239. ahrs->renorm_val = mavlink_msg_ahrs_get_renorm_val(msg);
  240. ahrs->error_rp = mavlink_msg_ahrs_get_error_rp(msg);
  241. ahrs->error_yaw = mavlink_msg_ahrs_get_error_yaw(msg);
  242. #else
  243. memcpy(ahrs, _MAV_PAYLOAD(msg), 28);
  244. #endif
  245. }