2
0

mavlink_msg_set_attitude_target.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. #pragma once
  2. // MESSAGE SET_ATTITUDE_TARGET PACKING
  3. #define MAVLINK_MSG_ID_SET_ATTITUDE_TARGET 82
  4. MAVPACKED(
  5. typedef struct __mavlink_set_attitude_target_t {
  6. uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
  7. float q[4]; /*< Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD*/
  8. float body_roll_rate; /*< [rad/s] Body roll rate*/
  9. float body_pitch_rate; /*< [rad/s] Body pitch rate*/
  10. float body_yaw_rate; /*< [rad/s] Body yaw rate*/
  11. float thrust; /*< Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)*/
  12. uint8_t target_system; /*< System ID*/
  13. uint8_t target_component; /*< Component ID*/
  14. uint8_t type_mask; /*< Bitmap to indicate which dimensions should be ignored by the vehicle.*/
  15. float thrust_body[3]; /*< 3D thrust setpoint in the body NED frame, normalized to -1 .. 1*/
  16. }) mavlink_set_attitude_target_t;
  17. #define MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN 51
  18. #define MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN 39
  19. #define MAVLINK_MSG_ID_82_LEN 51
  20. #define MAVLINK_MSG_ID_82_MIN_LEN 39
  21. #define MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC 49
  22. #define MAVLINK_MSG_ID_82_CRC 49
  23. #define MAVLINK_MSG_SET_ATTITUDE_TARGET_FIELD_Q_LEN 4
  24. #define MAVLINK_MSG_SET_ATTITUDE_TARGET_FIELD_THRUST_BODY_LEN 3
  25. #if MAVLINK_COMMAND_24BIT
  26. #define MAVLINK_MESSAGE_INFO_SET_ATTITUDE_TARGET { \
  27. 82, \
  28. "SET_ATTITUDE_TARGET", \
  29. 10, \
  30. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_attitude_target_t, time_boot_ms) }, \
  31. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_set_attitude_target_t, target_system) }, \
  32. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_set_attitude_target_t, target_component) }, \
  33. { "type_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 38, offsetof(mavlink_set_attitude_target_t, type_mask) }, \
  34. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 4, offsetof(mavlink_set_attitude_target_t, q) }, \
  35. { "body_roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_set_attitude_target_t, body_roll_rate) }, \
  36. { "body_pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_set_attitude_target_t, body_pitch_rate) }, \
  37. { "body_yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_set_attitude_target_t, body_yaw_rate) }, \
  38. { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_set_attitude_target_t, thrust) }, \
  39. { "thrust_body", NULL, MAVLINK_TYPE_FLOAT, 3, 39, offsetof(mavlink_set_attitude_target_t, thrust_body) }, \
  40. } \
  41. }
  42. #else
  43. #define MAVLINK_MESSAGE_INFO_SET_ATTITUDE_TARGET { \
  44. "SET_ATTITUDE_TARGET", \
  45. 10, \
  46. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_set_attitude_target_t, time_boot_ms) }, \
  47. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_set_attitude_target_t, target_system) }, \
  48. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_set_attitude_target_t, target_component) }, \
  49. { "type_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 38, offsetof(mavlink_set_attitude_target_t, type_mask) }, \
  50. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 4, offsetof(mavlink_set_attitude_target_t, q) }, \
  51. { "body_roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_set_attitude_target_t, body_roll_rate) }, \
  52. { "body_pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_set_attitude_target_t, body_pitch_rate) }, \
  53. { "body_yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_set_attitude_target_t, body_yaw_rate) }, \
  54. { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_set_attitude_target_t, thrust) }, \
  55. { "thrust_body", NULL, MAVLINK_TYPE_FLOAT, 3, 39, offsetof(mavlink_set_attitude_target_t, thrust_body) }, \
  56. } \
  57. }
  58. #endif
  59. /**
  60. * @brief Pack a set_attitude_target message
  61. * @param system_id ID of this system
  62. * @param component_id ID of this component (e.g. 200 for IMU)
  63. * @param msg The MAVLink message to compress the data into
  64. *
  65. * @param time_boot_ms [ms] Timestamp (time since system boot).
  66. * @param target_system System ID
  67. * @param target_component Component ID
  68. * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle.
  69. * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
  70. * @param body_roll_rate [rad/s] Body roll rate
  71. * @param body_pitch_rate [rad/s] Body pitch rate
  72. * @param body_yaw_rate [rad/s] Body yaw rate
  73. * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
  74. * @param thrust_body 3D thrust setpoint in the body NED frame, normalized to -1 .. 1
  75. * @return length of the message in bytes (excluding serial stream start sign)
  76. */
  77. static inline uint16_t mavlink_msg_set_attitude_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  78. uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust, const float *thrust_body)
  79. {
  80. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  81. char buf[MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN];
  82. _mav_put_uint32_t(buf, 0, time_boot_ms);
  83. _mav_put_float(buf, 20, body_roll_rate);
  84. _mav_put_float(buf, 24, body_pitch_rate);
  85. _mav_put_float(buf, 28, body_yaw_rate);
  86. _mav_put_float(buf, 32, thrust);
  87. _mav_put_uint8_t(buf, 36, target_system);
  88. _mav_put_uint8_t(buf, 37, target_component);
  89. _mav_put_uint8_t(buf, 38, type_mask);
  90. _mav_put_float_array(buf, 4, q, 4);
  91. _mav_put_float_array(buf, 39, thrust_body, 3);
  92. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  93. #else
  94. mavlink_set_attitude_target_t packet;
  95. packet.time_boot_ms = time_boot_ms;
  96. packet.body_roll_rate = body_roll_rate;
  97. packet.body_pitch_rate = body_pitch_rate;
  98. packet.body_yaw_rate = body_yaw_rate;
  99. packet.thrust = thrust;
  100. packet.target_system = target_system;
  101. packet.target_component = target_component;
  102. packet.type_mask = type_mask;
  103. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  104. mav_array_memcpy(packet.thrust_body, thrust_body, sizeof(float)*3);
  105. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  106. #endif
  107. msg->msgid = MAVLINK_MSG_ID_SET_ATTITUDE_TARGET;
  108. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  109. }
  110. /**
  111. * @brief Pack a set_attitude_target message
  112. * @param system_id ID of this system
  113. * @param component_id ID of this component (e.g. 200 for IMU)
  114. * @param status MAVLink status structure
  115. * @param msg The MAVLink message to compress the data into
  116. *
  117. * @param time_boot_ms [ms] Timestamp (time since system boot).
  118. * @param target_system System ID
  119. * @param target_component Component ID
  120. * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle.
  121. * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
  122. * @param body_roll_rate [rad/s] Body roll rate
  123. * @param body_pitch_rate [rad/s] Body pitch rate
  124. * @param body_yaw_rate [rad/s] Body yaw rate
  125. * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
  126. * @param thrust_body 3D thrust setpoint in the body NED frame, normalized to -1 .. 1
  127. * @return length of the message in bytes (excluding serial stream start sign)
  128. */
  129. static inline uint16_t mavlink_msg_set_attitude_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  130. uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust, const float *thrust_body)
  131. {
  132. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  133. char buf[MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN];
  134. _mav_put_uint32_t(buf, 0, time_boot_ms);
  135. _mav_put_float(buf, 20, body_roll_rate);
  136. _mav_put_float(buf, 24, body_pitch_rate);
  137. _mav_put_float(buf, 28, body_yaw_rate);
  138. _mav_put_float(buf, 32, thrust);
  139. _mav_put_uint8_t(buf, 36, target_system);
  140. _mav_put_uint8_t(buf, 37, target_component);
  141. _mav_put_uint8_t(buf, 38, type_mask);
  142. _mav_put_float_array(buf, 4, q, 4);
  143. _mav_put_float_array(buf, 39, thrust_body, 3);
  144. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  145. #else
  146. mavlink_set_attitude_target_t packet;
  147. packet.time_boot_ms = time_boot_ms;
  148. packet.body_roll_rate = body_roll_rate;
  149. packet.body_pitch_rate = body_pitch_rate;
  150. packet.body_yaw_rate = body_yaw_rate;
  151. packet.thrust = thrust;
  152. packet.target_system = target_system;
  153. packet.target_component = target_component;
  154. packet.type_mask = type_mask;
  155. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  156. mav_array_memcpy(packet.thrust_body, thrust_body, sizeof(float)*3);
  157. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  158. #endif
  159. msg->msgid = MAVLINK_MSG_ID_SET_ATTITUDE_TARGET;
  160. #if MAVLINK_CRC_EXTRA
  161. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  162. #else
  163. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  164. #endif
  165. }
  166. /**
  167. * @brief Pack a set_attitude_target message on a channel
  168. * @param system_id ID of this system
  169. * @param component_id ID of this component (e.g. 200 for IMU)
  170. * @param chan The MAVLink channel this message will be sent over
  171. * @param msg The MAVLink message to compress the data into
  172. * @param time_boot_ms [ms] Timestamp (time since system boot).
  173. * @param target_system System ID
  174. * @param target_component Component ID
  175. * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle.
  176. * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
  177. * @param body_roll_rate [rad/s] Body roll rate
  178. * @param body_pitch_rate [rad/s] Body pitch rate
  179. * @param body_yaw_rate [rad/s] Body yaw rate
  180. * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
  181. * @param thrust_body 3D thrust setpoint in the body NED frame, normalized to -1 .. 1
  182. * @return length of the message in bytes (excluding serial stream start sign)
  183. */
  184. static inline uint16_t mavlink_msg_set_attitude_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  185. mavlink_message_t* msg,
  186. uint32_t time_boot_ms,uint8_t target_system,uint8_t target_component,uint8_t type_mask,const float *q,float body_roll_rate,float body_pitch_rate,float body_yaw_rate,float thrust,const float *thrust_body)
  187. {
  188. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  189. char buf[MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN];
  190. _mav_put_uint32_t(buf, 0, time_boot_ms);
  191. _mav_put_float(buf, 20, body_roll_rate);
  192. _mav_put_float(buf, 24, body_pitch_rate);
  193. _mav_put_float(buf, 28, body_yaw_rate);
  194. _mav_put_float(buf, 32, thrust);
  195. _mav_put_uint8_t(buf, 36, target_system);
  196. _mav_put_uint8_t(buf, 37, target_component);
  197. _mav_put_uint8_t(buf, 38, type_mask);
  198. _mav_put_float_array(buf, 4, q, 4);
  199. _mav_put_float_array(buf, 39, thrust_body, 3);
  200. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  201. #else
  202. mavlink_set_attitude_target_t packet;
  203. packet.time_boot_ms = time_boot_ms;
  204. packet.body_roll_rate = body_roll_rate;
  205. packet.body_pitch_rate = body_pitch_rate;
  206. packet.body_yaw_rate = body_yaw_rate;
  207. packet.thrust = thrust;
  208. packet.target_system = target_system;
  209. packet.target_component = target_component;
  210. packet.type_mask = type_mask;
  211. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  212. mav_array_memcpy(packet.thrust_body, thrust_body, sizeof(float)*3);
  213. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  214. #endif
  215. msg->msgid = MAVLINK_MSG_ID_SET_ATTITUDE_TARGET;
  216. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  217. }
  218. /**
  219. * @brief Encode a set_attitude_target struct
  220. *
  221. * @param system_id ID of this system
  222. * @param component_id ID of this component (e.g. 200 for IMU)
  223. * @param msg The MAVLink message to compress the data into
  224. * @param set_attitude_target C-struct to read the message contents from
  225. */
  226. static inline uint16_t mavlink_msg_set_attitude_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_attitude_target_t* set_attitude_target)
  227. {
  228. return mavlink_msg_set_attitude_target_pack(system_id, component_id, msg, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body);
  229. }
  230. /**
  231. * @brief Encode a set_attitude_target struct on a channel
  232. *
  233. * @param system_id ID of this system
  234. * @param component_id ID of this component (e.g. 200 for IMU)
  235. * @param chan The MAVLink channel this message will be sent over
  236. * @param msg The MAVLink message to compress the data into
  237. * @param set_attitude_target C-struct to read the message contents from
  238. */
  239. static inline uint16_t mavlink_msg_set_attitude_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_set_attitude_target_t* set_attitude_target)
  240. {
  241. return mavlink_msg_set_attitude_target_pack_chan(system_id, component_id, chan, msg, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body);
  242. }
  243. /**
  244. * @brief Encode a set_attitude_target struct with provided status structure
  245. *
  246. * @param system_id ID of this system
  247. * @param component_id ID of this component (e.g. 200 for IMU)
  248. * @param status MAVLink status structure
  249. * @param msg The MAVLink message to compress the data into
  250. * @param set_attitude_target C-struct to read the message contents from
  251. */
  252. static inline uint16_t mavlink_msg_set_attitude_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_set_attitude_target_t* set_attitude_target)
  253. {
  254. return mavlink_msg_set_attitude_target_pack_status(system_id, component_id, _status, msg, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body);
  255. }
  256. /**
  257. * @brief Send a set_attitude_target message
  258. * @param chan MAVLink channel to send the message
  259. *
  260. * @param time_boot_ms [ms] Timestamp (time since system boot).
  261. * @param target_system System ID
  262. * @param target_component Component ID
  263. * @param type_mask Bitmap to indicate which dimensions should be ignored by the vehicle.
  264. * @param q Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
  265. * @param body_roll_rate [rad/s] Body roll rate
  266. * @param body_pitch_rate [rad/s] Body pitch rate
  267. * @param body_yaw_rate [rad/s] Body yaw rate
  268. * @param thrust Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
  269. * @param thrust_body 3D thrust setpoint in the body NED frame, normalized to -1 .. 1
  270. */
  271. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  272. static inline void mavlink_msg_set_attitude_target_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust, const float *thrust_body)
  273. {
  274. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  275. char buf[MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN];
  276. _mav_put_uint32_t(buf, 0, time_boot_ms);
  277. _mav_put_float(buf, 20, body_roll_rate);
  278. _mav_put_float(buf, 24, body_pitch_rate);
  279. _mav_put_float(buf, 28, body_yaw_rate);
  280. _mav_put_float(buf, 32, thrust);
  281. _mav_put_uint8_t(buf, 36, target_system);
  282. _mav_put_uint8_t(buf, 37, target_component);
  283. _mav_put_uint8_t(buf, 38, type_mask);
  284. _mav_put_float_array(buf, 4, q, 4);
  285. _mav_put_float_array(buf, 39, thrust_body, 3);
  286. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET, buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  287. #else
  288. mavlink_set_attitude_target_t packet;
  289. packet.time_boot_ms = time_boot_ms;
  290. packet.body_roll_rate = body_roll_rate;
  291. packet.body_pitch_rate = body_pitch_rate;
  292. packet.body_yaw_rate = body_yaw_rate;
  293. packet.thrust = thrust;
  294. packet.target_system = target_system;
  295. packet.target_component = target_component;
  296. packet.type_mask = type_mask;
  297. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  298. mav_array_memcpy(packet.thrust_body, thrust_body, sizeof(float)*3);
  299. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET, (const char *)&packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  300. #endif
  301. }
  302. /**
  303. * @brief Send a set_attitude_target message
  304. * @param chan MAVLink channel to send the message
  305. * @param struct The MAVLink struct to serialize
  306. */
  307. static inline void mavlink_msg_set_attitude_target_send_struct(mavlink_channel_t chan, const mavlink_set_attitude_target_t* set_attitude_target)
  308. {
  309. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  310. mavlink_msg_set_attitude_target_send(chan, set_attitude_target->time_boot_ms, set_attitude_target->target_system, set_attitude_target->target_component, set_attitude_target->type_mask, set_attitude_target->q, set_attitude_target->body_roll_rate, set_attitude_target->body_pitch_rate, set_attitude_target->body_yaw_rate, set_attitude_target->thrust, set_attitude_target->thrust_body);
  311. #else
  312. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET, (const char *)set_attitude_target, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  313. #endif
  314. }
  315. #if MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  316. /*
  317. This variant of _send() can be used to save stack space by re-using
  318. memory from the receive buffer. The caller provides a
  319. mavlink_message_t which is the size of a full mavlink message. This
  320. is usually the receive buffer for the channel, and allows a reply to an
  321. incoming message with minimum stack space usage.
  322. */
  323. static inline void mavlink_msg_set_attitude_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t target_system, uint8_t target_component, uint8_t type_mask, const float *q, float body_roll_rate, float body_pitch_rate, float body_yaw_rate, float thrust, const float *thrust_body)
  324. {
  325. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  326. char *buf = (char *)msgbuf;
  327. _mav_put_uint32_t(buf, 0, time_boot_ms);
  328. _mav_put_float(buf, 20, body_roll_rate);
  329. _mav_put_float(buf, 24, body_pitch_rate);
  330. _mav_put_float(buf, 28, body_yaw_rate);
  331. _mav_put_float(buf, 32, thrust);
  332. _mav_put_uint8_t(buf, 36, target_system);
  333. _mav_put_uint8_t(buf, 37, target_component);
  334. _mav_put_uint8_t(buf, 38, type_mask);
  335. _mav_put_float_array(buf, 4, q, 4);
  336. _mav_put_float_array(buf, 39, thrust_body, 3);
  337. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET, buf, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  338. #else
  339. mavlink_set_attitude_target_t *packet = (mavlink_set_attitude_target_t *)msgbuf;
  340. packet->time_boot_ms = time_boot_ms;
  341. packet->body_roll_rate = body_roll_rate;
  342. packet->body_pitch_rate = body_pitch_rate;
  343. packet->body_yaw_rate = body_yaw_rate;
  344. packet->thrust = thrust;
  345. packet->target_system = target_system;
  346. packet->target_component = target_component;
  347. packet->type_mask = type_mask;
  348. mav_array_memcpy(packet->q, q, sizeof(float)*4);
  349. mav_array_memcpy(packet->thrust_body, thrust_body, sizeof(float)*3);
  350. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET, (const char *)packet, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_MIN_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_CRC);
  351. #endif
  352. }
  353. #endif
  354. #endif
  355. // MESSAGE SET_ATTITUDE_TARGET UNPACKING
  356. /**
  357. * @brief Get field time_boot_ms from set_attitude_target message
  358. *
  359. * @return [ms] Timestamp (time since system boot).
  360. */
  361. static inline uint32_t mavlink_msg_set_attitude_target_get_time_boot_ms(const mavlink_message_t* msg)
  362. {
  363. return _MAV_RETURN_uint32_t(msg, 0);
  364. }
  365. /**
  366. * @brief Get field target_system from set_attitude_target message
  367. *
  368. * @return System ID
  369. */
  370. static inline uint8_t mavlink_msg_set_attitude_target_get_target_system(const mavlink_message_t* msg)
  371. {
  372. return _MAV_RETURN_uint8_t(msg, 36);
  373. }
  374. /**
  375. * @brief Get field target_component from set_attitude_target message
  376. *
  377. * @return Component ID
  378. */
  379. static inline uint8_t mavlink_msg_set_attitude_target_get_target_component(const mavlink_message_t* msg)
  380. {
  381. return _MAV_RETURN_uint8_t(msg, 37);
  382. }
  383. /**
  384. * @brief Get field type_mask from set_attitude_target message
  385. *
  386. * @return Bitmap to indicate which dimensions should be ignored by the vehicle.
  387. */
  388. static inline uint8_t mavlink_msg_set_attitude_target_get_type_mask(const mavlink_message_t* msg)
  389. {
  390. return _MAV_RETURN_uint8_t(msg, 38);
  391. }
  392. /**
  393. * @brief Get field q from set_attitude_target message
  394. *
  395. * @return Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
  396. */
  397. static inline uint16_t mavlink_msg_set_attitude_target_get_q(const mavlink_message_t* msg, float *q)
  398. {
  399. return _MAV_RETURN_float_array(msg, q, 4, 4);
  400. }
  401. /**
  402. * @brief Get field body_roll_rate from set_attitude_target message
  403. *
  404. * @return [rad/s] Body roll rate
  405. */
  406. static inline float mavlink_msg_set_attitude_target_get_body_roll_rate(const mavlink_message_t* msg)
  407. {
  408. return _MAV_RETURN_float(msg, 20);
  409. }
  410. /**
  411. * @brief Get field body_pitch_rate from set_attitude_target message
  412. *
  413. * @return [rad/s] Body pitch rate
  414. */
  415. static inline float mavlink_msg_set_attitude_target_get_body_pitch_rate(const mavlink_message_t* msg)
  416. {
  417. return _MAV_RETURN_float(msg, 24);
  418. }
  419. /**
  420. * @brief Get field body_yaw_rate from set_attitude_target message
  421. *
  422. * @return [rad/s] Body yaw rate
  423. */
  424. static inline float mavlink_msg_set_attitude_target_get_body_yaw_rate(const mavlink_message_t* msg)
  425. {
  426. return _MAV_RETURN_float(msg, 28);
  427. }
  428. /**
  429. * @brief Get field thrust from set_attitude_target message
  430. *
  431. * @return Collective thrust, normalized to 0 .. 1 (-1 .. 1 for vehicles capable of reverse trust)
  432. */
  433. static inline float mavlink_msg_set_attitude_target_get_thrust(const mavlink_message_t* msg)
  434. {
  435. return _MAV_RETURN_float(msg, 32);
  436. }
  437. /**
  438. * @brief Get field thrust_body from set_attitude_target message
  439. *
  440. * @return 3D thrust setpoint in the body NED frame, normalized to -1 .. 1
  441. */
  442. static inline uint16_t mavlink_msg_set_attitude_target_get_thrust_body(const mavlink_message_t* msg, float *thrust_body)
  443. {
  444. return _MAV_RETURN_float_array(msg, thrust_body, 3, 39);
  445. }
  446. /**
  447. * @brief Decode a set_attitude_target message into a struct
  448. *
  449. * @param msg The message to decode
  450. * @param set_attitude_target C-struct to decode the message contents into
  451. */
  452. static inline void mavlink_msg_set_attitude_target_decode(const mavlink_message_t* msg, mavlink_set_attitude_target_t* set_attitude_target)
  453. {
  454. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  455. set_attitude_target->time_boot_ms = mavlink_msg_set_attitude_target_get_time_boot_ms(msg);
  456. mavlink_msg_set_attitude_target_get_q(msg, set_attitude_target->q);
  457. set_attitude_target->body_roll_rate = mavlink_msg_set_attitude_target_get_body_roll_rate(msg);
  458. set_attitude_target->body_pitch_rate = mavlink_msg_set_attitude_target_get_body_pitch_rate(msg);
  459. set_attitude_target->body_yaw_rate = mavlink_msg_set_attitude_target_get_body_yaw_rate(msg);
  460. set_attitude_target->thrust = mavlink_msg_set_attitude_target_get_thrust(msg);
  461. set_attitude_target->target_system = mavlink_msg_set_attitude_target_get_target_system(msg);
  462. set_attitude_target->target_component = mavlink_msg_set_attitude_target_get_target_component(msg);
  463. set_attitude_target->type_mask = mavlink_msg_set_attitude_target_get_type_mask(msg);
  464. mavlink_msg_set_attitude_target_get_thrust_body(msg, set_attitude_target->thrust_body);
  465. #else
  466. uint8_t len = msg->len < MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN? msg->len : MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN;
  467. memset(set_attitude_target, 0, MAVLINK_MSG_ID_SET_ATTITUDE_TARGET_LEN);
  468. memcpy(set_attitude_target, _MAV_PAYLOAD(msg), len);
  469. #endif
  470. }