/libs/mavlink/include/mavlink/v1.0/common/mavlink_msg_manual_control.h

https://bitbucket.org/nikhil/qgc · C Header · 254 lines · 139 code · 30 blank · 85 comment · 3 complexity · 0e062f48a933dca6dca53ebb900aec08 MD5 · raw file

  1. // MESSAGE MANUAL_CONTROL PACKING
  2. #define MAVLINK_MSG_ID_MANUAL_CONTROL 69
  3. typedef struct __mavlink_manual_control_t
  4. {
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. uint8_t target; ///< The system to be controlled.
  11. } mavlink_manual_control_t;
  12. #define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 11
  13. #define MAVLINK_MSG_ID_69_LEN 11
  14. #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
  15. "MANUAL_CONTROL", \
  16. 6, \
  17. { { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
  18. { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
  19. { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
  20. { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
  21. { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
  22. { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
  23. } \
  24. }
  25. /**
  26. * @brief Pack a manual_control message
  27. * @param system_id ID of this system
  28. * @param component_id ID of this component (e.g. 200 for IMU)
  29. * @param msg The MAVLink message to compress the data into
  30. *
  31. * @param target The system to be controlled.
  32. * @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.
  33. * @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.
  34. * @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.
  35. * @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.
  36. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  37. * @return length of the message in bytes (excluding serial stream start sign)
  38. */
  39. static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  40. uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons)
  41. {
  42. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  43. char buf[11];
  44. _mav_put_int16_t(buf, 0, x);
  45. _mav_put_int16_t(buf, 2, y);
  46. _mav_put_int16_t(buf, 4, z);
  47. _mav_put_int16_t(buf, 6, r);
  48. _mav_put_uint16_t(buf, 8, buttons);
  49. _mav_put_uint8_t(buf, 10, target);
  50. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 11);
  51. #else
  52. mavlink_manual_control_t packet;
  53. packet.x = x;
  54. packet.y = y;
  55. packet.z = z;
  56. packet.r = r;
  57. packet.buttons = buttons;
  58. packet.target = target;
  59. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 11);
  60. #endif
  61. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  62. return mavlink_finalize_message(msg, system_id, component_id, 11, 243);
  63. }
  64. /**
  65. * @brief Pack a manual_control message on a channel
  66. * @param system_id ID of this system
  67. * @param component_id ID of this component (e.g. 200 for IMU)
  68. * @param chan The MAVLink channel this message was sent over
  69. * @param msg The MAVLink message to compress the data into
  70. * @param target The system to be controlled.
  71. * @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.
  72. * @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.
  73. * @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.
  74. * @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.
  75. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  76. * @return length of the message in bytes (excluding serial stream start sign)
  77. */
  78. static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  79. mavlink_message_t* msg,
  80. uint8_t target,int16_t x,int16_t y,int16_t z,int16_t r,uint16_t buttons)
  81. {
  82. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  83. char buf[11];
  84. _mav_put_int16_t(buf, 0, x);
  85. _mav_put_int16_t(buf, 2, y);
  86. _mav_put_int16_t(buf, 4, z);
  87. _mav_put_int16_t(buf, 6, r);
  88. _mav_put_uint16_t(buf, 8, buttons);
  89. _mav_put_uint8_t(buf, 10, target);
  90. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 11);
  91. #else
  92. mavlink_manual_control_t packet;
  93. packet.x = x;
  94. packet.y = y;
  95. packet.z = z;
  96. packet.r = r;
  97. packet.buttons = buttons;
  98. packet.target = target;
  99. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 11);
  100. #endif
  101. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  102. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 11, 243);
  103. }
  104. /**
  105. * @brief Encode a manual_control struct into a message
  106. *
  107. * @param system_id ID of this system
  108. * @param component_id ID of this component (e.g. 200 for IMU)
  109. * @param msg The MAVLink message to compress the data into
  110. * @param manual_control C-struct to read the message contents from
  111. */
  112. 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)
  113. {
  114. 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);
  115. }
  116. /**
  117. * @brief Send a manual_control message
  118. * @param chan MAVLink channel to send the message
  119. *
  120. * @param target The system to be controlled.
  121. * @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.
  122. * @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.
  123. * @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.
  124. * @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.
  125. * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  126. */
  127. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  128. 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)
  129. {
  130. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  131. char buf[11];
  132. _mav_put_int16_t(buf, 0, x);
  133. _mav_put_int16_t(buf, 2, y);
  134. _mav_put_int16_t(buf, 4, z);
  135. _mav_put_int16_t(buf, 6, r);
  136. _mav_put_uint16_t(buf, 8, buttons);
  137. _mav_put_uint8_t(buf, 10, target);
  138. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, 11, 243);
  139. #else
  140. mavlink_manual_control_t packet;
  141. packet.x = x;
  142. packet.y = y;
  143. packet.z = z;
  144. packet.r = r;
  145. packet.buttons = buttons;
  146. packet.target = target;
  147. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)&packet, 11, 243);
  148. #endif
  149. }
  150. #endif
  151. // MESSAGE MANUAL_CONTROL UNPACKING
  152. /**
  153. * @brief Get field target from manual_control message
  154. *
  155. * @return The system to be controlled.
  156. */
  157. static inline uint8_t mavlink_msg_manual_control_get_target(const mavlink_message_t* msg)
  158. {
  159. return _MAV_RETURN_uint8_t(msg, 10);
  160. }
  161. /**
  162. * @brief Get field x from manual_control message
  163. *
  164. * @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.
  165. */
  166. static inline int16_t mavlink_msg_manual_control_get_x(const mavlink_message_t* msg)
  167. {
  168. return _MAV_RETURN_int16_t(msg, 0);
  169. }
  170. /**
  171. * @brief Get field y from manual_control message
  172. *
  173. * @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.
  174. */
  175. static inline int16_t mavlink_msg_manual_control_get_y(const mavlink_message_t* msg)
  176. {
  177. return _MAV_RETURN_int16_t(msg, 2);
  178. }
  179. /**
  180. * @brief Get field z from manual_control message
  181. *
  182. * @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.
  183. */
  184. static inline int16_t mavlink_msg_manual_control_get_z(const mavlink_message_t* msg)
  185. {
  186. return _MAV_RETURN_int16_t(msg, 4);
  187. }
  188. /**
  189. * @brief Get field r from manual_control message
  190. *
  191. * @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.
  192. */
  193. static inline int16_t mavlink_msg_manual_control_get_r(const mavlink_message_t* msg)
  194. {
  195. return _MAV_RETURN_int16_t(msg, 6);
  196. }
  197. /**
  198. * @brief Get field buttons from manual_control message
  199. *
  200. * @return A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  201. */
  202. static inline uint16_t mavlink_msg_manual_control_get_buttons(const mavlink_message_t* msg)
  203. {
  204. return _MAV_RETURN_uint16_t(msg, 8);
  205. }
  206. /**
  207. * @brief Decode a manual_control message into a struct
  208. *
  209. * @param msg The message to decode
  210. * @param manual_control C-struct to decode the message contents into
  211. */
  212. static inline void mavlink_msg_manual_control_decode(const mavlink_message_t* msg, mavlink_manual_control_t* manual_control)
  213. {
  214. #if MAVLINK_NEED_BYTE_SWAP
  215. manual_control->x = mavlink_msg_manual_control_get_x(msg);
  216. manual_control->y = mavlink_msg_manual_control_get_y(msg);
  217. manual_control->z = mavlink_msg_manual_control_get_z(msg);
  218. manual_control->r = mavlink_msg_manual_control_get_r(msg);
  219. manual_control->buttons = mavlink_msg_manual_control_get_buttons(msg);
  220. manual_control->target = mavlink_msg_manual_control_get_target(msg);
  221. #else
  222. memcpy(manual_control, _MAV_PAYLOAD(msg), 11);
  223. #endif
  224. }