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.

338 lines
12 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE AHRS2 PACKING
  3. #define MAVLINK_MSG_ID_AHRS2 178
  4. MAVPACKED(
  5. typedef struct __mavlink_ahrs2_t {
  6. float roll; /*< [rad] Roll angle.*/
  7. float pitch; /*< [rad] Pitch angle.*/
  8. float yaw; /*< [rad] Yaw angle.*/
  9. float altitude; /*< [m] Altitude (MSL).*/
  10. int32_t lat; /*< [degE7] Latitude.*/
  11. int32_t lng; /*< [degE7] Longitude.*/
  12. }) mavlink_ahrs2_t;
  13. #define MAVLINK_MSG_ID_AHRS2_LEN 24
  14. #define MAVLINK_MSG_ID_AHRS2_MIN_LEN 24
  15. #define MAVLINK_MSG_ID_178_LEN 24
  16. #define MAVLINK_MSG_ID_178_MIN_LEN 24
  17. #define MAVLINK_MSG_ID_AHRS2_CRC 47
  18. #define MAVLINK_MSG_ID_178_CRC 47
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_AHRS2 { \
  21. 178, \
  22. "AHRS2", \
  23. 6, \
  24. { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs2_t, roll) }, \
  25. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs2_t, pitch) }, \
  26. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs2_t, yaw) }, \
  27. { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs2_t, altitude) }, \
  28. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_ahrs2_t, lat) }, \
  29. { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_ahrs2_t, lng) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_AHRS2 { \
  34. "AHRS2", \
  35. 6, \
  36. { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs2_t, roll) }, \
  37. { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs2_t, pitch) }, \
  38. { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs2_t, yaw) }, \
  39. { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs2_t, altitude) }, \
  40. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_ahrs2_t, lat) }, \
  41. { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_ahrs2_t, lng) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a ahrs2 message
  47. * @param system_id ID of this system
  48. * @param component_id ID of this component (e.g. 200 for IMU)
  49. * @param msg The MAVLink message to compress the data into
  50. *
  51. * @param roll [rad] Roll angle.
  52. * @param pitch [rad] Pitch angle.
  53. * @param yaw [rad] Yaw angle.
  54. * @param altitude [m] Altitude (MSL).
  55. * @param lat [degE7] Latitude.
  56. * @param lng [degE7] Longitude.
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_ahrs2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_AHRS2_LEN];
  64. _mav_put_float(buf, 0, roll);
  65. _mav_put_float(buf, 4, pitch);
  66. _mav_put_float(buf, 8, yaw);
  67. _mav_put_float(buf, 12, altitude);
  68. _mav_put_int32_t(buf, 16, lat);
  69. _mav_put_int32_t(buf, 20, lng);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS2_LEN);
  71. #else
  72. mavlink_ahrs2_t packet;
  73. packet.roll = roll;
  74. packet.pitch = pitch;
  75. packet.yaw = yaw;
  76. packet.altitude = altitude;
  77. packet.lat = lat;
  78. packet.lng = lng;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_AHRS2;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  83. }
  84. /**
  85. * @brief Pack a ahrs2 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 will be sent over
  89. * @param msg The MAVLink message to compress the data into
  90. * @param roll [rad] Roll angle.
  91. * @param pitch [rad] Pitch angle.
  92. * @param yaw [rad] Yaw angle.
  93. * @param altitude [m] Altitude (MSL).
  94. * @param lat [degE7] Latitude.
  95. * @param lng [degE7] Longitude.
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_ahrs2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. float roll,float pitch,float yaw,float altitude,int32_t lat,int32_t lng)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_AHRS2_LEN];
  104. _mav_put_float(buf, 0, roll);
  105. _mav_put_float(buf, 4, pitch);
  106. _mav_put_float(buf, 8, yaw);
  107. _mav_put_float(buf, 12, altitude);
  108. _mav_put_int32_t(buf, 16, lat);
  109. _mav_put_int32_t(buf, 20, lng);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS2_LEN);
  111. #else
  112. mavlink_ahrs2_t packet;
  113. packet.roll = roll;
  114. packet.pitch = pitch;
  115. packet.yaw = yaw;
  116. packet.altitude = altitude;
  117. packet.lat = lat;
  118. packet.lng = lng;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_AHRS2;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  123. }
  124. /**
  125. * @brief Encode a ahrs2 struct
  126. *
  127. * @param system_id ID of this system
  128. * @param component_id ID of this component (e.g. 200 for IMU)
  129. * @param msg The MAVLink message to compress the data into
  130. * @param ahrs2 C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_ahrs2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2)
  133. {
  134. return mavlink_msg_ahrs2_pack(system_id, component_id, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
  135. }
  136. /**
  137. * @brief Encode a ahrs2 struct on a channel
  138. *
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param chan The MAVLink channel this message will be sent over
  142. * @param msg The MAVLink message to compress the data into
  143. * @param ahrs2 C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_ahrs2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2)
  146. {
  147. return mavlink_msg_ahrs2_pack_chan(system_id, component_id, chan, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
  148. }
  149. /**
  150. * @brief Send a ahrs2 message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param roll [rad] Roll angle.
  154. * @param pitch [rad] Pitch angle.
  155. * @param yaw [rad] Yaw angle.
  156. * @param altitude [m] Altitude (MSL).
  157. * @param lat [degE7] Latitude.
  158. * @param lng [degE7] Longitude.
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_ahrs2_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_AHRS2_LEN];
  165. _mav_put_float(buf, 0, roll);
  166. _mav_put_float(buf, 4, pitch);
  167. _mav_put_float(buf, 8, yaw);
  168. _mav_put_float(buf, 12, altitude);
  169. _mav_put_int32_t(buf, 16, lat);
  170. _mav_put_int32_t(buf, 20, lng);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  172. #else
  173. mavlink_ahrs2_t packet;
  174. packet.roll = roll;
  175. packet.pitch = pitch;
  176. packet.yaw = yaw;
  177. packet.altitude = altitude;
  178. packet.lat = lat;
  179. packet.lng = lng;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)&packet, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a ahrs2 message
  185. * @param chan MAVLink channel to send the message
  186. * @param struct The MAVLink struct to serialize
  187. */
  188. static inline void mavlink_msg_ahrs2_send_struct(mavlink_channel_t chan, const mavlink_ahrs2_t* ahrs2)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_ahrs2_send(chan, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)ahrs2, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_AHRS2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  197. /*
  198. This varient of _send() can be used to save stack space by re-using
  199. memory from the receive buffer. The caller provides a
  200. mavlink_message_t which is the size of a full mavlink message. This
  201. is usually the receive buffer for the channel, and allows a reply to an
  202. incoming message with minimum stack space usage.
  203. */
  204. static inline void mavlink_msg_ahrs2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_float(buf, 0, roll);
  209. _mav_put_float(buf, 4, pitch);
  210. _mav_put_float(buf, 8, yaw);
  211. _mav_put_float(buf, 12, altitude);
  212. _mav_put_int32_t(buf, 16, lat);
  213. _mav_put_int32_t(buf, 20, lng);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  215. #else
  216. mavlink_ahrs2_t *packet = (mavlink_ahrs2_t *)msgbuf;
  217. packet->roll = roll;
  218. packet->pitch = pitch;
  219. packet->yaw = yaw;
  220. packet->altitude = altitude;
  221. packet->lat = lat;
  222. packet->lng = lng;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)packet, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE AHRS2 UNPACKING
  229. /**
  230. * @brief Get field roll from ahrs2 message
  231. *
  232. * @return [rad] Roll angle.
  233. */
  234. static inline float mavlink_msg_ahrs2_get_roll(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_float(msg, 0);
  237. }
  238. /**
  239. * @brief Get field pitch from ahrs2 message
  240. *
  241. * @return [rad] Pitch angle.
  242. */
  243. static inline float mavlink_msg_ahrs2_get_pitch(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_float(msg, 4);
  246. }
  247. /**
  248. * @brief Get field yaw from ahrs2 message
  249. *
  250. * @return [rad] Yaw angle.
  251. */
  252. static inline float mavlink_msg_ahrs2_get_yaw(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_float(msg, 8);
  255. }
  256. /**
  257. * @brief Get field altitude from ahrs2 message
  258. *
  259. * @return [m] Altitude (MSL).
  260. */
  261. static inline float mavlink_msg_ahrs2_get_altitude(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_float(msg, 12);
  264. }
  265. /**
  266. * @brief Get field lat from ahrs2 message
  267. *
  268. * @return [degE7] Latitude.
  269. */
  270. static inline int32_t mavlink_msg_ahrs2_get_lat(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_int32_t(msg, 16);
  273. }
  274. /**
  275. * @brief Get field lng from ahrs2 message
  276. *
  277. * @return [degE7] Longitude.
  278. */
  279. static inline int32_t mavlink_msg_ahrs2_get_lng(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_int32_t(msg, 20);
  282. }
  283. /**
  284. * @brief Decode a ahrs2 message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param ahrs2 C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_ahrs2_decode(const mavlink_message_t* msg, mavlink_ahrs2_t* ahrs2)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. ahrs2->roll = mavlink_msg_ahrs2_get_roll(msg);
  293. ahrs2->pitch = mavlink_msg_ahrs2_get_pitch(msg);
  294. ahrs2->yaw = mavlink_msg_ahrs2_get_yaw(msg);
  295. ahrs2->altitude = mavlink_msg_ahrs2_get_altitude(msg);
  296. ahrs2->lat = mavlink_msg_ahrs2_get_lat(msg);
  297. ahrs2->lng = mavlink_msg_ahrs2_get_lng(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_AHRS2_LEN? msg->len : MAVLINK_MSG_ID_AHRS2_LEN;
  300. memset(ahrs2, 0, MAVLINK_MSG_ID_AHRS2_LEN);
  301. memcpy(ahrs2, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }