mavlink_msg_actuator_control_target.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. #pragma once
  2. // MESSAGE ACTUATOR_CONTROL_TARGET PACKING
  3. #define MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET 140
  4. typedef struct __mavlink_actuator_control_target_t {
  5. uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
  6. float controls[8]; /*< Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.*/
  7. uint8_t group_mlx; /*< Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.*/
  8. } mavlink_actuator_control_target_t;
  9. #define MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN 41
  10. #define MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN 41
  11. #define MAVLINK_MSG_ID_140_LEN 41
  12. #define MAVLINK_MSG_ID_140_MIN_LEN 41
  13. #define MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC 181
  14. #define MAVLINK_MSG_ID_140_CRC 181
  15. #define MAVLINK_MSG_ACTUATOR_CONTROL_TARGET_FIELD_CONTROLS_LEN 8
  16. #if MAVLINK_COMMAND_24BIT
  17. #define MAVLINK_MESSAGE_INFO_ACTUATOR_CONTROL_TARGET { \
  18. 140, \
  19. "ACTUATOR_CONTROL_TARGET", \
  20. 3, \
  21. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_actuator_control_target_t, time_usec) }, \
  22. { "group_mlx", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_actuator_control_target_t, group_mlx) }, \
  23. { "controls", NULL, MAVLINK_TYPE_FLOAT, 8, 8, offsetof(mavlink_actuator_control_target_t, controls) }, \
  24. } \
  25. }
  26. #else
  27. #define MAVLINK_MESSAGE_INFO_ACTUATOR_CONTROL_TARGET { \
  28. "ACTUATOR_CONTROL_TARGET", \
  29. 3, \
  30. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_actuator_control_target_t, time_usec) }, \
  31. { "group_mlx", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_actuator_control_target_t, group_mlx) }, \
  32. { "controls", NULL, MAVLINK_TYPE_FLOAT, 8, 8, offsetof(mavlink_actuator_control_target_t, controls) }, \
  33. } \
  34. }
  35. #endif
  36. /**
  37. * @brief Pack a actuator_control_target message
  38. * @param system_id ID of this system
  39. * @param component_id ID of this component (e.g. 200 for IMU)
  40. * @param msg The MAVLink message to compress the data into
  41. *
  42. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  43. * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.
  44. * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
  45. * @return length of the message in bytes (excluding serial stream start sign)
  46. */
  47. static inline uint16_t mavlink_msg_actuator_control_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  48. uint64_t time_usec, uint8_t group_mlx, const float *controls)
  49. {
  50. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  51. char buf[MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN];
  52. _mav_put_uint64_t(buf, 0, time_usec);
  53. _mav_put_uint8_t(buf, 40, group_mlx);
  54. _mav_put_float_array(buf, 8, controls, 8);
  55. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  56. #else
  57. mavlink_actuator_control_target_t packet;
  58. packet.time_usec = time_usec;
  59. packet.group_mlx = group_mlx;
  60. mav_array_memcpy(packet.controls, controls, sizeof(float)*8);
  61. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  62. #endif
  63. msg->msgid = MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET;
  64. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  65. }
  66. /**
  67. * @brief Pack a actuator_control_target message
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param status MAVLink status structure
  71. * @param msg The MAVLink message to compress the data into
  72. *
  73. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  74. * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.
  75. * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
  76. * @return length of the message in bytes (excluding serial stream start sign)
  77. */
  78. static inline uint16_t mavlink_msg_actuator_control_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  79. uint64_t time_usec, uint8_t group_mlx, const float *controls)
  80. {
  81. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  82. char buf[MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN];
  83. _mav_put_uint64_t(buf, 0, time_usec);
  84. _mav_put_uint8_t(buf, 40, group_mlx);
  85. _mav_put_float_array(buf, 8, controls, 8);
  86. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  87. #else
  88. mavlink_actuator_control_target_t packet;
  89. packet.time_usec = time_usec;
  90. packet.group_mlx = group_mlx;
  91. mav_array_memcpy(packet.controls, controls, sizeof(float)*8);
  92. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  93. #endif
  94. msg->msgid = MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET;
  95. #if MAVLINK_CRC_EXTRA
  96. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  97. #else
  98. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  99. #endif
  100. }
  101. /**
  102. * @brief Pack a actuator_control_target message on a channel
  103. * @param system_id ID of this system
  104. * @param component_id ID of this component (e.g. 200 for IMU)
  105. * @param chan The MAVLink channel this message will be sent over
  106. * @param msg The MAVLink message to compress the data into
  107. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  108. * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.
  109. * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
  110. * @return length of the message in bytes (excluding serial stream start sign)
  111. */
  112. static inline uint16_t mavlink_msg_actuator_control_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  113. mavlink_message_t* msg,
  114. uint64_t time_usec,uint8_t group_mlx,const float *controls)
  115. {
  116. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  117. char buf[MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN];
  118. _mav_put_uint64_t(buf, 0, time_usec);
  119. _mav_put_uint8_t(buf, 40, group_mlx);
  120. _mav_put_float_array(buf, 8, controls, 8);
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  122. #else
  123. mavlink_actuator_control_target_t packet;
  124. packet.time_usec = time_usec;
  125. packet.group_mlx = group_mlx;
  126. mav_array_memcpy(packet.controls, controls, sizeof(float)*8);
  127. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  128. #endif
  129. msg->msgid = MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET;
  130. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  131. }
  132. /**
  133. * @brief Encode a actuator_control_target struct
  134. *
  135. * @param system_id ID of this system
  136. * @param component_id ID of this component (e.g. 200 for IMU)
  137. * @param msg The MAVLink message to compress the data into
  138. * @param actuator_control_target C-struct to read the message contents from
  139. */
  140. static inline uint16_t mavlink_msg_actuator_control_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_actuator_control_target_t* actuator_control_target)
  141. {
  142. return mavlink_msg_actuator_control_target_pack(system_id, component_id, msg, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls);
  143. }
  144. /**
  145. * @brief Encode a actuator_control_target struct on a channel
  146. *
  147. * @param system_id ID of this system
  148. * @param component_id ID of this component (e.g. 200 for IMU)
  149. * @param chan The MAVLink channel this message will be sent over
  150. * @param msg The MAVLink message to compress the data into
  151. * @param actuator_control_target C-struct to read the message contents from
  152. */
  153. static inline uint16_t mavlink_msg_actuator_control_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_actuator_control_target_t* actuator_control_target)
  154. {
  155. return mavlink_msg_actuator_control_target_pack_chan(system_id, component_id, chan, msg, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls);
  156. }
  157. /**
  158. * @brief Encode a actuator_control_target struct with provided status structure
  159. *
  160. * @param system_id ID of this system
  161. * @param component_id ID of this component (e.g. 200 for IMU)
  162. * @param status MAVLink status structure
  163. * @param msg The MAVLink message to compress the data into
  164. * @param actuator_control_target C-struct to read the message contents from
  165. */
  166. static inline uint16_t mavlink_msg_actuator_control_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_actuator_control_target_t* actuator_control_target)
  167. {
  168. return mavlink_msg_actuator_control_target_pack_status(system_id, component_id, _status, msg, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls);
  169. }
  170. /**
  171. * @brief Send a actuator_control_target message
  172. * @param chan MAVLink channel to send the message
  173. *
  174. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  175. * @param group_mlx Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.
  176. * @param controls Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
  177. */
  178. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  179. static inline void mavlink_msg_actuator_control_target_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t group_mlx, const float *controls)
  180. {
  181. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  182. char buf[MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN];
  183. _mav_put_uint64_t(buf, 0, time_usec);
  184. _mav_put_uint8_t(buf, 40, group_mlx);
  185. _mav_put_float_array(buf, 8, controls, 8);
  186. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET, buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  187. #else
  188. mavlink_actuator_control_target_t packet;
  189. packet.time_usec = time_usec;
  190. packet.group_mlx = group_mlx;
  191. mav_array_memcpy(packet.controls, controls, sizeof(float)*8);
  192. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET, (const char *)&packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  193. #endif
  194. }
  195. /**
  196. * @brief Send a actuator_control_target message
  197. * @param chan MAVLink channel to send the message
  198. * @param struct The MAVLink struct to serialize
  199. */
  200. static inline void mavlink_msg_actuator_control_target_send_struct(mavlink_channel_t chan, const mavlink_actuator_control_target_t* actuator_control_target)
  201. {
  202. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  203. mavlink_msg_actuator_control_target_send(chan, actuator_control_target->time_usec, actuator_control_target->group_mlx, actuator_control_target->controls);
  204. #else
  205. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET, (const char *)actuator_control_target, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  206. #endif
  207. }
  208. #if MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  209. /*
  210. This variant of _send() can be used to save stack space by re-using
  211. memory from the receive buffer. The caller provides a
  212. mavlink_message_t which is the size of a full mavlink message. This
  213. is usually the receive buffer for the channel, and allows a reply to an
  214. incoming message with minimum stack space usage.
  215. */
  216. static inline void mavlink_msg_actuator_control_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t group_mlx, const float *controls)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  219. char *buf = (char *)msgbuf;
  220. _mav_put_uint64_t(buf, 0, time_usec);
  221. _mav_put_uint8_t(buf, 40, group_mlx);
  222. _mav_put_float_array(buf, 8, controls, 8);
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET, buf, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  224. #else
  225. mavlink_actuator_control_target_t *packet = (mavlink_actuator_control_target_t *)msgbuf;
  226. packet->time_usec = time_usec;
  227. packet->group_mlx = group_mlx;
  228. mav_array_memcpy(packet->controls, controls, sizeof(float)*8);
  229. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET, (const char *)packet, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_MIN_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_CRC);
  230. #endif
  231. }
  232. #endif
  233. #endif
  234. // MESSAGE ACTUATOR_CONTROL_TARGET UNPACKING
  235. /**
  236. * @brief Get field time_usec from actuator_control_target message
  237. *
  238. * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  239. */
  240. static inline uint64_t mavlink_msg_actuator_control_target_get_time_usec(const mavlink_message_t* msg)
  241. {
  242. return _MAV_RETURN_uint64_t(msg, 0);
  243. }
  244. /**
  245. * @brief Get field group_mlx from actuator_control_target message
  246. *
  247. * @return Actuator group. The "_mlx" indicates this is a multi-instance message and a MAVLink parser should use this field to difference between instances.
  248. */
  249. static inline uint8_t mavlink_msg_actuator_control_target_get_group_mlx(const mavlink_message_t* msg)
  250. {
  251. return _MAV_RETURN_uint8_t(msg, 40);
  252. }
  253. /**
  254. * @brief Get field controls from actuator_control_target message
  255. *
  256. * @return Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
  257. */
  258. static inline uint16_t mavlink_msg_actuator_control_target_get_controls(const mavlink_message_t* msg, float *controls)
  259. {
  260. return _MAV_RETURN_float_array(msg, controls, 8, 8);
  261. }
  262. /**
  263. * @brief Decode a actuator_control_target message into a struct
  264. *
  265. * @param msg The message to decode
  266. * @param actuator_control_target C-struct to decode the message contents into
  267. */
  268. static inline void mavlink_msg_actuator_control_target_decode(const mavlink_message_t* msg, mavlink_actuator_control_target_t* actuator_control_target)
  269. {
  270. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  271. actuator_control_target->time_usec = mavlink_msg_actuator_control_target_get_time_usec(msg);
  272. mavlink_msg_actuator_control_target_get_controls(msg, actuator_control_target->controls);
  273. actuator_control_target->group_mlx = mavlink_msg_actuator_control_target_get_group_mlx(msg);
  274. #else
  275. uint8_t len = msg->len < MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN? msg->len : MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN;
  276. memset(actuator_control_target, 0, MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET_LEN);
  277. memcpy(actuator_control_target, _MAV_PAYLOAD(msg), len);
  278. #endif
  279. }