mavlink_msg_attitude_quaternion.h 25 KB

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