You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

338 lines
18 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE MANUAL_CONTROL PACKING
  3. #define MAVLINK_MSG_ID_MANUAL_CONTROL 69
  4. MAVPACKED(
  5. typedef struct __mavlink_manual_control_t {
  6. int16_t x; /*< X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.*/
  7. int16_t y; /*< Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.*/
  8. int16_t z; /*< Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.*/
  9. int16_t r; /*< R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.*/
  10. uint16_t buttons; /*< A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.*/
  11. uint8_t target; /*< The system to be controlled.*/
  12. }) mavlink_manual_control_t;
  13. #define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 11
  14. #define MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN 11
  15. #define MAVLINK_MSG_ID_69_LEN 11
  16. #define MAVLINK_MSG_ID_69_MIN_LEN 11
  17. #define MAVLINK_MSG_ID_MANUAL_CONTROL_CRC 243
  18. #define MAVLINK_MSG_ID_69_CRC 243
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
  21. 69, \
  22. "MANUAL_CONTROL", \
  23. 6, \
  24. { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
  25. { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
  26. { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
  27. { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
  28. { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
  29. { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
  34. "MANUAL_CONTROL", \
  35. 6, \
  36. { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
  37. { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
  38. { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
  39. { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
  40. { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
  41. { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a manual_control message
  47. * @param system_id ID of this system
  48. * @param component_id ID of this component (e.g. 200 for IMU)
  49. * @param msg The MAVLink message to compress the data into
  50. *
  51. * @param target The system to be controlled.
  52. * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
  53. * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
  54. * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
  55. * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
  56. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
  64. _mav_put_int16_t(buf, 0, x);
  65. _mav_put_int16_t(buf, 2, y);
  66. _mav_put_int16_t(buf, 4, z);
  67. _mav_put_int16_t(buf, 6, r);
  68. _mav_put_uint16_t(buf, 8, buttons);
  69. _mav_put_uint8_t(buf, 10, target);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  71. #else
  72. mavlink_manual_control_t packet;
  73. packet.x = x;
  74. packet.y = y;
  75. packet.z = z;
  76. packet.r = r;
  77. packet.buttons = buttons;
  78. packet.target = target;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  83. }
  84. /**
  85. * @brief Pack a manual_control message on a channel
  86. * @param system_id ID of this system
  87. * @param component_id ID of this component (e.g. 200 for IMU)
  88. * @param chan The MAVLink channel this message will be sent over
  89. * @param msg The MAVLink message to compress the data into
  90. * @param target The system to be controlled.
  91. * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
  92. * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
  93. * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
  94. * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
  95. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. uint8_t target,int16_t x,int16_t y,int16_t z,int16_t r,uint16_t buttons)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
  104. _mav_put_int16_t(buf, 0, x);
  105. _mav_put_int16_t(buf, 2, y);
  106. _mav_put_int16_t(buf, 4, z);
  107. _mav_put_int16_t(buf, 6, r);
  108. _mav_put_uint16_t(buf, 8, buttons);
  109. _mav_put_uint8_t(buf, 10, target);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  111. #else
  112. mavlink_manual_control_t packet;
  113. packet.x = x;
  114. packet.y = y;
  115. packet.z = z;
  116. packet.r = r;
  117. packet.buttons = buttons;
  118. packet.target = target;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  123. }
  124. /**
  125. * @brief Encode a manual_control struct
  126. *
  127. * @param system_id ID of this system
  128. * @param component_id ID of this component (e.g. 200 for IMU)
  129. * @param msg The MAVLink message to compress the data into
  130. * @param manual_control C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_manual_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control)
  133. {
  134. return mavlink_msg_manual_control_pack(system_id, component_id, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
  135. }
  136. /**
  137. * @brief Encode a manual_control struct on a channel
  138. *
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param chan The MAVLink channel this message will be sent over
  142. * @param msg The MAVLink message to compress the data into
  143. * @param manual_control C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_manual_control_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control)
  146. {
  147. return mavlink_msg_manual_control_pack_chan(system_id, component_id, chan, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
  148. }
  149. /**
  150. * @brief Send a manual_control message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param target The system to be controlled.
  154. * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
  155. * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
  156. * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
  157. * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
  158. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_manual_control_send(mavlink_channel_t chan, uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
  165. _mav_put_int16_t(buf, 0, x);
  166. _mav_put_int16_t(buf, 2, y);
  167. _mav_put_int16_t(buf, 4, z);
  168. _mav_put_int16_t(buf, 6, r);
  169. _mav_put_uint16_t(buf, 8, buttons);
  170. _mav_put_uint8_t(buf, 10, target);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  172. #else
  173. mavlink_manual_control_t packet;
  174. packet.x = x;
  175. packet.y = y;
  176. packet.z = z;
  177. packet.r = r;
  178. packet.buttons = buttons;
  179. packet.target = target;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)&packet, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a manual_control message
  185. * @param chan MAVLink channel to send the message
  186. * @param struct The MAVLink struct to serialize
  187. */
  188. static inline void mavlink_msg_manual_control_send_struct(mavlink_channel_t chan, const mavlink_manual_control_t* manual_control)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_manual_control_send(chan, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)manual_control, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_MANUAL_CONTROL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  197. /*
  198. This varient of _send() can be used to save stack space by re-using
  199. memory from the receive buffer. The caller provides a
  200. mavlink_message_t which is the size of a full mavlink message. This
  201. is usually the receive buffer for the channel, and allows a reply to an
  202. incoming message with minimum stack space usage.
  203. */
  204. static inline void mavlink_msg_manual_control_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_int16_t(buf, 0, x);
  209. _mav_put_int16_t(buf, 2, y);
  210. _mav_put_int16_t(buf, 4, z);
  211. _mav_put_int16_t(buf, 6, r);
  212. _mav_put_uint16_t(buf, 8, buttons);
  213. _mav_put_uint8_t(buf, 10, target);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  215. #else
  216. mavlink_manual_control_t *packet = (mavlink_manual_control_t *)msgbuf;
  217. packet->x = x;
  218. packet->y = y;
  219. packet->z = z;
  220. packet->r = r;
  221. packet->buttons = buttons;
  222. packet->target = target;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)packet, MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN, MAVLINK_MSG_ID_MANUAL_CONTROL_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE MANUAL_CONTROL UNPACKING
  229. /**
  230. * @brief Get field target from manual_control message
  231. *
  232. * @return The system to be controlled.
  233. */
  234. static inline uint8_t mavlink_msg_manual_control_get_target(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_uint8_t(msg, 10);
  237. }
  238. /**
  239. * @brief Get field x from manual_control message
  240. *
  241. * @return X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle.
  242. */
  243. static inline int16_t mavlink_msg_manual_control_get_x(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_int16_t(msg, 0);
  246. }
  247. /**
  248. * @brief Get field y from manual_control message
  249. *
  250. * @return Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle.
  251. */
  252. static inline int16_t mavlink_msg_manual_control_get_y(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_int16_t(msg, 2);
  255. }
  256. /**
  257. * @brief Get field z from manual_control message
  258. *
  259. * @return Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. Positive values are positive thrust, negative values are negative thrust.
  260. */
  261. static inline int16_t mavlink_msg_manual_control_get_z(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_int16_t(msg, 4);
  264. }
  265. /**
  266. * @brief Get field r from manual_control message
  267. *
  268. * @return R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle.
  269. */
  270. static inline int16_t mavlink_msg_manual_control_get_r(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_int16_t(msg, 6);
  273. }
  274. /**
  275. * @brief Get field buttons from manual_control message
  276. *
  277. * @return A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  278. */
  279. static inline uint16_t mavlink_msg_manual_control_get_buttons(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_uint16_t(msg, 8);
  282. }
  283. /**
  284. * @brief Decode a manual_control message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param manual_control C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_manual_control_decode(const mavlink_message_t* msg, mavlink_manual_control_t* manual_control)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. manual_control->x = mavlink_msg_manual_control_get_x(msg);
  293. manual_control->y = mavlink_msg_manual_control_get_y(msg);
  294. manual_control->z = mavlink_msg_manual_control_get_z(msg);
  295. manual_control->r = mavlink_msg_manual_control_get_r(msg);
  296. manual_control->buttons = mavlink_msg_manual_control_get_buttons(msg);
  297. manual_control->target = mavlink_msg_manual_control_get_target(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_MANUAL_CONTROL_LEN? msg->len : MAVLINK_MSG_ID_MANUAL_CONTROL_LEN;
  300. memset(manual_control, 0, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  301. memcpy(manual_control, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }