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.

405 lines
21 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE ATTITUDE_QUATERNION PACKING
  3. #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION 31
  4. MAVPACKED(
  5. typedef struct __mavlink_attitude_quaternion_t {
  6. uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
  7. float q1; /*< Quaternion component 1, w (1 in null-rotation)*/
  8. float q2; /*< Quaternion component 2, x (0 in null-rotation)*/
  9. float q3; /*< Quaternion component 3, y (0 in null-rotation)*/
  10. float q4; /*< Quaternion component 4, z (0 in null-rotation)*/
  11. float rollspeed; /*< [rad/s] Roll angular speed*/
  12. float pitchspeed; /*< [rad/s] Pitch angular speed*/
  13. float yawspeed; /*< [rad/s] Yaw angular speed*/
  14. float repr_offset_q[4]; /*< Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.*/
  15. }) mavlink_attitude_quaternion_t;
  16. #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN 48
  17. #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN 32
  18. #define MAVLINK_MSG_ID_31_LEN 48
  19. #define MAVLINK_MSG_ID_31_MIN_LEN 32
  20. #define MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC 246
  21. #define MAVLINK_MSG_ID_31_CRC 246
  22. #define MAVLINK_MSG_ATTITUDE_QUATERNION_FIELD_REPR_OFFSET_Q_LEN 4
  23. #if MAVLINK_COMMAND_24BIT
  24. #define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \
  25. 31, \
  26. "ATTITUDE_QUATERNION", \
  27. 9, \
  28. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \
  29. { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \
  30. { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \
  31. { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \
  32. { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \
  33. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \
  34. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \
  35. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \
  36. { "repr_offset_q", NULL, MAVLINK_TYPE_FLOAT, 4, 32, offsetof(mavlink_attitude_quaternion_t, repr_offset_q) }, \
  37. } \
  38. }
  39. #else
  40. #define MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION { \
  41. "ATTITUDE_QUATERNION", \
  42. 9, \
  43. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_attitude_quaternion_t, time_boot_ms) }, \
  44. { "q1", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_attitude_quaternion_t, q1) }, \
  45. { "q2", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_attitude_quaternion_t, q2) }, \
  46. { "q3", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_attitude_quaternion_t, q3) }, \
  47. { "q4", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_attitude_quaternion_t, q4) }, \
  48. { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_attitude_quaternion_t, rollspeed) }, \
  49. { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_attitude_quaternion_t, pitchspeed) }, \
  50. { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_attitude_quaternion_t, yawspeed) }, \
  51. { "repr_offset_q", NULL, MAVLINK_TYPE_FLOAT, 4, 32, offsetof(mavlink_attitude_quaternion_t, repr_offset_q) }, \
  52. } \
  53. }
  54. #endif
  55. /**
  56. * @brief Pack a attitude_quaternion message
  57. * @param system_id ID of this system
  58. * @param component_id ID of this component (e.g. 200 for IMU)
  59. * @param msg The MAVLink message to compress the data into
  60. *
  61. * @param time_boot_ms [ms] Timestamp (time since system boot).
  62. * @param q1 Quaternion component 1, w (1 in null-rotation)
  63. * @param q2 Quaternion component 2, x (0 in null-rotation)
  64. * @param q3 Quaternion component 3, y (0 in null-rotation)
  65. * @param q4 Quaternion component 4, z (0 in null-rotation)
  66. * @param rollspeed [rad/s] Roll angular speed
  67. * @param pitchspeed [rad/s] Pitch angular speed
  68. * @param yawspeed [rad/s] Yaw angular speed
  69. * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
  70. * @return length of the message in bytes (excluding serial stream start sign)
  71. */
  72. static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  73. uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q)
  74. {
  75. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  76. char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
  77. _mav_put_uint32_t(buf, 0, time_boot_ms);
  78. _mav_put_float(buf, 4, q1);
  79. _mav_put_float(buf, 8, q2);
  80. _mav_put_float(buf, 12, q3);
  81. _mav_put_float(buf, 16, q4);
  82. _mav_put_float(buf, 20, rollspeed);
  83. _mav_put_float(buf, 24, pitchspeed);
  84. _mav_put_float(buf, 28, yawspeed);
  85. _mav_put_float_array(buf, 32, repr_offset_q, 4);
  86. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
  87. #else
  88. mavlink_attitude_quaternion_t packet;
  89. packet.time_boot_ms = time_boot_ms;
  90. packet.q1 = q1;
  91. packet.q2 = q2;
  92. packet.q3 = q3;
  93. packet.q4 = q4;
  94. packet.rollspeed = rollspeed;
  95. packet.pitchspeed = pitchspeed;
  96. packet.yawspeed = yawspeed;
  97. mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
  98. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
  99. #endif
  100. msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION;
  101. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  102. }
  103. /**
  104. * @brief Pack a attitude_quaternion message on a channel
  105. * @param system_id ID of this system
  106. * @param component_id ID of this component (e.g. 200 for IMU)
  107. * @param chan The MAVLink channel this message will be sent over
  108. * @param msg The MAVLink message to compress the data into
  109. * @param time_boot_ms [ms] Timestamp (time since system boot).
  110. * @param q1 Quaternion component 1, w (1 in null-rotation)
  111. * @param q2 Quaternion component 2, x (0 in null-rotation)
  112. * @param q3 Quaternion component 3, y (0 in null-rotation)
  113. * @param q4 Quaternion component 4, z (0 in null-rotation)
  114. * @param rollspeed [rad/s] Roll angular speed
  115. * @param pitchspeed [rad/s] Pitch angular speed
  116. * @param yawspeed [rad/s] Yaw angular speed
  117. * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
  118. * @return length of the message in bytes (excluding serial stream start sign)
  119. */
  120. static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  121. mavlink_message_t* msg,
  122. uint32_t time_boot_ms,float q1,float q2,float q3,float q4,float rollspeed,float pitchspeed,float yawspeed,const float *repr_offset_q)
  123. {
  124. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  125. char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
  126. _mav_put_uint32_t(buf, 0, time_boot_ms);
  127. _mav_put_float(buf, 4, q1);
  128. _mav_put_float(buf, 8, q2);
  129. _mav_put_float(buf, 12, q3);
  130. _mav_put_float(buf, 16, q4);
  131. _mav_put_float(buf, 20, rollspeed);
  132. _mav_put_float(buf, 24, pitchspeed);
  133. _mav_put_float(buf, 28, yawspeed);
  134. _mav_put_float_array(buf, 32, repr_offset_q, 4);
  135. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
  136. #else
  137. mavlink_attitude_quaternion_t packet;
  138. packet.time_boot_ms = time_boot_ms;
  139. packet.q1 = q1;
  140. packet.q2 = q2;
  141. packet.q3 = q3;
  142. packet.q4 = q4;
  143. packet.rollspeed = rollspeed;
  144. packet.pitchspeed = pitchspeed;
  145. packet.yawspeed = yawspeed;
  146. mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
  147. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
  148. #endif
  149. msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION;
  150. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  151. }
  152. /**
  153. * @brief Encode a attitude_quaternion struct
  154. *
  155. * @param system_id ID of this system
  156. * @param component_id ID of this component (e.g. 200 for IMU)
  157. * @param msg The MAVLink message to compress the data into
  158. * @param attitude_quaternion C-struct to read the message contents from
  159. */
  160. static inline uint16_t mavlink_msg_attitude_quaternion_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion)
  161. {
  162. return mavlink_msg_attitude_quaternion_pack(system_id, component_id, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed, attitude_quaternion->repr_offset_q);
  163. }
  164. /**
  165. * @brief Encode a attitude_quaternion struct on a channel
  166. *
  167. * @param system_id ID of this system
  168. * @param component_id ID of this component (e.g. 200 for IMU)
  169. * @param chan The MAVLink channel this message will be sent over
  170. * @param msg The MAVLink message to compress the data into
  171. * @param attitude_quaternion C-struct to read the message contents from
  172. */
  173. static inline uint16_t mavlink_msg_attitude_quaternion_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_attitude_quaternion_t* attitude_quaternion)
  174. {
  175. return mavlink_msg_attitude_quaternion_pack_chan(system_id, component_id, chan, msg, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed, attitude_quaternion->repr_offset_q);
  176. }
  177. /**
  178. * @brief Send a attitude_quaternion message
  179. * @param chan MAVLink channel to send the message
  180. *
  181. * @param time_boot_ms [ms] Timestamp (time since system boot).
  182. * @param q1 Quaternion component 1, w (1 in null-rotation)
  183. * @param q2 Quaternion component 2, x (0 in null-rotation)
  184. * @param q3 Quaternion component 3, y (0 in null-rotation)
  185. * @param q4 Quaternion component 4, z (0 in null-rotation)
  186. * @param rollspeed [rad/s] Roll angular speed
  187. * @param pitchspeed [rad/s] Pitch angular speed
  188. * @param yawspeed [rad/s] Yaw angular speed
  189. * @param repr_offset_q Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
  190. */
  191. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  192. static inline void mavlink_msg_attitude_quaternion_send(mavlink_channel_t chan, uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q)
  193. {
  194. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  195. char buf[MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN];
  196. _mav_put_uint32_t(buf, 0, time_boot_ms);
  197. _mav_put_float(buf, 4, q1);
  198. _mav_put_float(buf, 8, q2);
  199. _mav_put_float(buf, 12, q3);
  200. _mav_put_float(buf, 16, q4);
  201. _mav_put_float(buf, 20, rollspeed);
  202. _mav_put_float(buf, 24, pitchspeed);
  203. _mav_put_float(buf, 28, yawspeed);
  204. _mav_put_float_array(buf, 32, repr_offset_q, 4);
  205. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  206. #else
  207. mavlink_attitude_quaternion_t packet;
  208. packet.time_boot_ms = time_boot_ms;
  209. packet.q1 = q1;
  210. packet.q2 = q2;
  211. packet.q3 = q3;
  212. packet.q4 = q4;
  213. packet.rollspeed = rollspeed;
  214. packet.pitchspeed = pitchspeed;
  215. packet.yawspeed = yawspeed;
  216. mav_array_memcpy(packet.repr_offset_q, repr_offset_q, sizeof(float)*4);
  217. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)&packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  218. #endif
  219. }
  220. /**
  221. * @brief Send a attitude_quaternion message
  222. * @param chan MAVLink channel to send the message
  223. * @param struct The MAVLink struct to serialize
  224. */
  225. static inline void mavlink_msg_attitude_quaternion_send_struct(mavlink_channel_t chan, const mavlink_attitude_quaternion_t* attitude_quaternion)
  226. {
  227. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  228. mavlink_msg_attitude_quaternion_send(chan, attitude_quaternion->time_boot_ms, attitude_quaternion->q1, attitude_quaternion->q2, attitude_quaternion->q3, attitude_quaternion->q4, attitude_quaternion->rollspeed, attitude_quaternion->pitchspeed, attitude_quaternion->yawspeed, attitude_quaternion->repr_offset_q);
  229. #else
  230. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)attitude_quaternion, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  231. #endif
  232. }
  233. #if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  234. /*
  235. This varient of _send() can be used to save stack space by re-using
  236. memory from the receive buffer. The caller provides a
  237. mavlink_message_t which is the size of a full mavlink message. This
  238. is usually the receive buffer for the channel, and allows a reply to an
  239. incoming message with minimum stack space usage.
  240. */
  241. static inline void mavlink_msg_attitude_quaternion_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, float q1, float q2, float q3, float q4, float rollspeed, float pitchspeed, float yawspeed, const float *repr_offset_q)
  242. {
  243. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  244. char *buf = (char *)msgbuf;
  245. _mav_put_uint32_t(buf, 0, time_boot_ms);
  246. _mav_put_float(buf, 4, q1);
  247. _mav_put_float(buf, 8, q2);
  248. _mav_put_float(buf, 12, q3);
  249. _mav_put_float(buf, 16, q4);
  250. _mav_put_float(buf, 20, rollspeed);
  251. _mav_put_float(buf, 24, pitchspeed);
  252. _mav_put_float(buf, 28, yawspeed);
  253. _mav_put_float_array(buf, 32, repr_offset_q, 4);
  254. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, buf, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  255. #else
  256. mavlink_attitude_quaternion_t *packet = (mavlink_attitude_quaternion_t *)msgbuf;
  257. packet->time_boot_ms = time_boot_ms;
  258. packet->q1 = q1;
  259. packet->q2 = q2;
  260. packet->q3 = q3;
  261. packet->q4 = q4;
  262. packet->rollspeed = rollspeed;
  263. packet->pitchspeed = pitchspeed;
  264. packet->yawspeed = yawspeed;
  265. mav_array_memcpy(packet->repr_offset_q, repr_offset_q, sizeof(float)*4);
  266. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ATTITUDE_QUATERNION, (const char *)packet, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_MIN_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_CRC);
  267. #endif
  268. }
  269. #endif
  270. #endif
  271. // MESSAGE ATTITUDE_QUATERNION UNPACKING
  272. /**
  273. * @brief Get field time_boot_ms from attitude_quaternion message
  274. *
  275. * @return [ms] Timestamp (time since system boot).
  276. */
  277. static inline uint32_t mavlink_msg_attitude_quaternion_get_time_boot_ms(const mavlink_message_t* msg)
  278. {
  279. return _MAV_RETURN_uint32_t(msg, 0);
  280. }
  281. /**
  282. * @brief Get field q1 from attitude_quaternion message
  283. *
  284. * @return Quaternion component 1, w (1 in null-rotation)
  285. */
  286. static inline float mavlink_msg_attitude_quaternion_get_q1(const mavlink_message_t* msg)
  287. {
  288. return _MAV_RETURN_float(msg, 4);
  289. }
  290. /**
  291. * @brief Get field q2 from attitude_quaternion message
  292. *
  293. * @return Quaternion component 2, x (0 in null-rotation)
  294. */
  295. static inline float mavlink_msg_attitude_quaternion_get_q2(const mavlink_message_t* msg)
  296. {
  297. return _MAV_RETURN_float(msg, 8);
  298. }
  299. /**
  300. * @brief Get field q3 from attitude_quaternion message
  301. *
  302. * @return Quaternion component 3, y (0 in null-rotation)
  303. */
  304. static inline float mavlink_msg_attitude_quaternion_get_q3(const mavlink_message_t* msg)
  305. {
  306. return _MAV_RETURN_float(msg, 12);
  307. }
  308. /**
  309. * @brief Get field q4 from attitude_quaternion message
  310. *
  311. * @return Quaternion component 4, z (0 in null-rotation)
  312. */
  313. static inline float mavlink_msg_attitude_quaternion_get_q4(const mavlink_message_t* msg)
  314. {
  315. return _MAV_RETURN_float(msg, 16);
  316. }
  317. /**
  318. * @brief Get field rollspeed from attitude_quaternion message
  319. *
  320. * @return [rad/s] Roll angular speed
  321. */
  322. static inline float mavlink_msg_attitude_quaternion_get_rollspeed(const mavlink_message_t* msg)
  323. {
  324. return _MAV_RETURN_float(msg, 20);
  325. }
  326. /**
  327. * @brief Get field pitchspeed from attitude_quaternion message
  328. *
  329. * @return [rad/s] Pitch angular speed
  330. */
  331. static inline float mavlink_msg_attitude_quaternion_get_pitchspeed(const mavlink_message_t* msg)
  332. {
  333. return _MAV_RETURN_float(msg, 24);
  334. }
  335. /**
  336. * @brief Get field yawspeed from attitude_quaternion message
  337. *
  338. * @return [rad/s] Yaw angular speed
  339. */
  340. static inline float mavlink_msg_attitude_quaternion_get_yawspeed(const mavlink_message_t* msg)
  341. {
  342. return _MAV_RETURN_float(msg, 28);
  343. }
  344. /**
  345. * @brief Get field repr_offset_q from attitude_quaternion message
  346. *
  347. * @return Rotation offset by which the attitude quaternion and angular speed vector should be rotated for user display (quaternion with [w, x, y, z] order, zero-rotation is [1, 0, 0, 0], send [0, 0, 0, 0] if field not supported). This field is intended for systems in which the reference attitude may change during flight. For example, tailsitters VTOLs rotate their reference attitude by 90 degrees between hover mode and fixed wing mode, thus repr_offset_q is equal to [1, 0, 0, 0] in hover mode and equal to [0.7071, 0, 0.7071, 0] in fixed wing mode.
  348. */
  349. static inline uint16_t mavlink_msg_attitude_quaternion_get_repr_offset_q(const mavlink_message_t* msg, float *repr_offset_q)
  350. {
  351. return _MAV_RETURN_float_array(msg, repr_offset_q, 4, 32);
  352. }
  353. /**
  354. * @brief Decode a attitude_quaternion message into a struct
  355. *
  356. * @param msg The message to decode
  357. * @param attitude_quaternion C-struct to decode the message contents into
  358. */
  359. static inline void mavlink_msg_attitude_quaternion_decode(const mavlink_message_t* msg, mavlink_attitude_quaternion_t* attitude_quaternion)
  360. {
  361. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  362. attitude_quaternion->time_boot_ms = mavlink_msg_attitude_quaternion_get_time_boot_ms(msg);
  363. attitude_quaternion->q1 = mavlink_msg_attitude_quaternion_get_q1(msg);
  364. attitude_quaternion->q2 = mavlink_msg_attitude_quaternion_get_q2(msg);
  365. attitude_quaternion->q3 = mavlink_msg_attitude_quaternion_get_q3(msg);
  366. attitude_quaternion->q4 = mavlink_msg_attitude_quaternion_get_q4(msg);
  367. attitude_quaternion->rollspeed = mavlink_msg_attitude_quaternion_get_rollspeed(msg);
  368. attitude_quaternion->pitchspeed = mavlink_msg_attitude_quaternion_get_pitchspeed(msg);
  369. attitude_quaternion->yawspeed = mavlink_msg_attitude_quaternion_get_yawspeed(msg);
  370. mavlink_msg_attitude_quaternion_get_repr_offset_q(msg, attitude_quaternion->repr_offset_q);
  371. #else
  372. uint8_t len = msg->len < MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN? msg->len : MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN;
  373. memset(attitude_quaternion, 0, MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN);
  374. memcpy(attitude_quaternion, _MAV_PAYLOAD(msg), len);
  375. #endif
  376. }