mavlink_msg_manual_control.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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' 0-15 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. uint16_t buttons2; /*< A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16.*/
  13. uint8_t enabled_extensions; /*< Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6*/
  14. int16_t s; /*< Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid.*/
  15. int16_t t; /*< Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid.*/
  16. int16_t aux1; /*< Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset.*/
  17. int16_t aux2; /*< Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset.*/
  18. int16_t aux3; /*< Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset.*/
  19. int16_t aux4; /*< Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset.*/
  20. int16_t aux5; /*< Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset.*/
  21. int16_t aux6; /*< Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset.*/
  22. }) mavlink_manual_control_t;
  23. #define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 30
  24. #define MAVLINK_MSG_ID_MANUAL_CONTROL_MIN_LEN 11
  25. #define MAVLINK_MSG_ID_69_LEN 30
  26. #define MAVLINK_MSG_ID_69_MIN_LEN 11
  27. #define MAVLINK_MSG_ID_MANUAL_CONTROL_CRC 243
  28. #define MAVLINK_MSG_ID_69_CRC 243
  29. #if MAVLINK_COMMAND_24BIT
  30. #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
  31. 69, \
  32. "MANUAL_CONTROL", \
  33. 16, \
  34. { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
  35. { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
  36. { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
  37. { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
  38. { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
  39. { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
  40. { "buttons2", NULL, MAVLINK_TYPE_UINT16_T, 0, 11, offsetof(mavlink_manual_control_t, buttons2) }, \
  41. { "enabled_extensions", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_manual_control_t, enabled_extensions) }, \
  42. { "s", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_manual_control_t, s) }, \
  43. { "t", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_manual_control_t, t) }, \
  44. { "aux1", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_manual_control_t, aux1) }, \
  45. { "aux2", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_manual_control_t, aux2) }, \
  46. { "aux3", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_manual_control_t, aux3) }, \
  47. { "aux4", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_manual_control_t, aux4) }, \
  48. { "aux5", NULL, MAVLINK_TYPE_INT16_T, 0, 26, offsetof(mavlink_manual_control_t, aux5) }, \
  49. { "aux6", NULL, MAVLINK_TYPE_INT16_T, 0, 28, offsetof(mavlink_manual_control_t, aux6) }, \
  50. } \
  51. }
  52. #else
  53. #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \
  54. "MANUAL_CONTROL", \
  55. 16, \
  56. { { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \
  57. { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \
  58. { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \
  59. { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \
  60. { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \
  61. { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \
  62. { "buttons2", NULL, MAVLINK_TYPE_UINT16_T, 0, 11, offsetof(mavlink_manual_control_t, buttons2) }, \
  63. { "enabled_extensions", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_manual_control_t, enabled_extensions) }, \
  64. { "s", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_manual_control_t, s) }, \
  65. { "t", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_manual_control_t, t) }, \
  66. { "aux1", NULL, MAVLINK_TYPE_INT16_T, 0, 18, offsetof(mavlink_manual_control_t, aux1) }, \
  67. { "aux2", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_manual_control_t, aux2) }, \
  68. { "aux3", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_manual_control_t, aux3) }, \
  69. { "aux4", NULL, MAVLINK_TYPE_INT16_T, 0, 24, offsetof(mavlink_manual_control_t, aux4) }, \
  70. { "aux5", NULL, MAVLINK_TYPE_INT16_T, 0, 26, offsetof(mavlink_manual_control_t, aux5) }, \
  71. { "aux6", NULL, MAVLINK_TYPE_INT16_T, 0, 28, offsetof(mavlink_manual_control_t, aux6) }, \
  72. } \
  73. }
  74. #endif
  75. /**
  76. * @brief Pack a manual_control message
  77. * @param system_id ID of this system
  78. * @param component_id ID of this component (e.g. 200 for IMU)
  79. * @param msg The MAVLink message to compress the data into
  80. *
  81. * @param target The system to be controlled.
  82. * @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.
  83. * @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.
  84. * @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.
  85. * @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.
  86. * @param buttons A bitfield corresponding to the joystick buttons' 0-15 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  87. * @param buttons2 A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16.
  88. * @param enabled_extensions Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6
  89. * @param s Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid.
  90. * @param t Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid.
  91. * @param aux1 Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset.
  92. * @param aux2 Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset.
  93. * @param aux3 Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset.
  94. * @param aux4 Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset.
  95. * @param aux5 Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset.
  96. * @param aux6 Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset.
  97. * @return length of the message in bytes (excluding serial stream start sign)
  98. */
  99. static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  100. uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons, uint16_t buttons2, uint8_t enabled_extensions, int16_t s, int16_t t, int16_t aux1, int16_t aux2, int16_t aux3, int16_t aux4, int16_t aux5, int16_t aux6)
  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. _mav_put_uint16_t(buf, 11, buttons2);
  111. _mav_put_uint8_t(buf, 13, enabled_extensions);
  112. _mav_put_int16_t(buf, 14, s);
  113. _mav_put_int16_t(buf, 16, t);
  114. _mav_put_int16_t(buf, 18, aux1);
  115. _mav_put_int16_t(buf, 20, aux2);
  116. _mav_put_int16_t(buf, 22, aux3);
  117. _mav_put_int16_t(buf, 24, aux4);
  118. _mav_put_int16_t(buf, 26, aux5);
  119. _mav_put_int16_t(buf, 28, aux6);
  120. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  121. #else
  122. mavlink_manual_control_t packet;
  123. packet.x = x;
  124. packet.y = y;
  125. packet.z = z;
  126. packet.r = r;
  127. packet.buttons = buttons;
  128. packet.target = target;
  129. packet.buttons2 = buttons2;
  130. packet.enabled_extensions = enabled_extensions;
  131. packet.s = s;
  132. packet.t = t;
  133. packet.aux1 = aux1;
  134. packet.aux2 = aux2;
  135. packet.aux3 = aux3;
  136. packet.aux4 = aux4;
  137. packet.aux5 = aux5;
  138. packet.aux6 = aux6;
  139. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  140. #endif
  141. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  142. 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);
  143. }
  144. /**
  145. * @brief Pack a manual_control message on a channel
  146. * @param system_id ID of this system
  147. * @param component_id ID of this component (e.g. 200 for IMU)
  148. * @param chan The MAVLink channel this message will be sent over
  149. * @param msg The MAVLink message to compress the data into
  150. * @param target The system to be controlled.
  151. * @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.
  152. * @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.
  153. * @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.
  154. * @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.
  155. * @param buttons A bitfield corresponding to the joystick buttons' 0-15 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  156. * @param buttons2 A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16.
  157. * @param enabled_extensions Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6
  158. * @param s Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid.
  159. * @param t Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid.
  160. * @param aux1 Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset.
  161. * @param aux2 Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset.
  162. * @param aux3 Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset.
  163. * @param aux4 Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset.
  164. * @param aux5 Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset.
  165. * @param aux6 Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset.
  166. * @return length of the message in bytes (excluding serial stream start sign)
  167. */
  168. static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  169. mavlink_message_t* msg,
  170. uint8_t target,int16_t x,int16_t y,int16_t z,int16_t r,uint16_t buttons,uint16_t buttons2,uint8_t enabled_extensions,int16_t s,int16_t t,int16_t aux1,int16_t aux2,int16_t aux3,int16_t aux4,int16_t aux5,int16_t aux6)
  171. {
  172. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  173. char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
  174. _mav_put_int16_t(buf, 0, x);
  175. _mav_put_int16_t(buf, 2, y);
  176. _mav_put_int16_t(buf, 4, z);
  177. _mav_put_int16_t(buf, 6, r);
  178. _mav_put_uint16_t(buf, 8, buttons);
  179. _mav_put_uint8_t(buf, 10, target);
  180. _mav_put_uint16_t(buf, 11, buttons2);
  181. _mav_put_uint8_t(buf, 13, enabled_extensions);
  182. _mav_put_int16_t(buf, 14, s);
  183. _mav_put_int16_t(buf, 16, t);
  184. _mav_put_int16_t(buf, 18, aux1);
  185. _mav_put_int16_t(buf, 20, aux2);
  186. _mav_put_int16_t(buf, 22, aux3);
  187. _mav_put_int16_t(buf, 24, aux4);
  188. _mav_put_int16_t(buf, 26, aux5);
  189. _mav_put_int16_t(buf, 28, aux6);
  190. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  191. #else
  192. mavlink_manual_control_t packet;
  193. packet.x = x;
  194. packet.y = y;
  195. packet.z = z;
  196. packet.r = r;
  197. packet.buttons = buttons;
  198. packet.target = target;
  199. packet.buttons2 = buttons2;
  200. packet.enabled_extensions = enabled_extensions;
  201. packet.s = s;
  202. packet.t = t;
  203. packet.aux1 = aux1;
  204. packet.aux2 = aux2;
  205. packet.aux3 = aux3;
  206. packet.aux4 = aux4;
  207. packet.aux5 = aux5;
  208. packet.aux6 = aux6;
  209. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  210. #endif
  211. msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL;
  212. 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);
  213. }
  214. /**
  215. * @brief Encode a manual_control struct
  216. *
  217. * @param system_id ID of this system
  218. * @param component_id ID of this component (e.g. 200 for IMU)
  219. * @param msg The MAVLink message to compress the data into
  220. * @param manual_control C-struct to read the message contents from
  221. */
  222. 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)
  223. {
  224. 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, manual_control->buttons2, manual_control->enabled_extensions, manual_control->s, manual_control->t, manual_control->aux1, manual_control->aux2, manual_control->aux3, manual_control->aux4, manual_control->aux5, manual_control->aux6);
  225. }
  226. /**
  227. * @brief Encode a manual_control struct on a channel
  228. *
  229. * @param system_id ID of this system
  230. * @param component_id ID of this component (e.g. 200 for IMU)
  231. * @param chan The MAVLink channel this message will be sent over
  232. * @param msg The MAVLink message to compress the data into
  233. * @param manual_control C-struct to read the message contents from
  234. */
  235. 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)
  236. {
  237. 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, manual_control->buttons2, manual_control->enabled_extensions, manual_control->s, manual_control->t, manual_control->aux1, manual_control->aux2, manual_control->aux3, manual_control->aux4, manual_control->aux5, manual_control->aux6);
  238. }
  239. /**
  240. * @brief Send a manual_control message
  241. * @param chan MAVLink channel to send the message
  242. *
  243. * @param target The system to be controlled.
  244. * @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.
  245. * @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.
  246. * @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.
  247. * @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.
  248. * @param buttons A bitfield corresponding to the joystick buttons' 0-15 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  249. * @param buttons2 A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16.
  250. * @param enabled_extensions Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6
  251. * @param s Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid.
  252. * @param t Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid.
  253. * @param aux1 Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset.
  254. * @param aux2 Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset.
  255. * @param aux3 Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset.
  256. * @param aux4 Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset.
  257. * @param aux5 Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset.
  258. * @param aux6 Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset.
  259. */
  260. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  261. 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, uint16_t buttons2, uint8_t enabled_extensions, int16_t s, int16_t t, int16_t aux1, int16_t aux2, int16_t aux3, int16_t aux4, int16_t aux5, int16_t aux6)
  262. {
  263. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  264. char buf[MAVLINK_MSG_ID_MANUAL_CONTROL_LEN];
  265. _mav_put_int16_t(buf, 0, x);
  266. _mav_put_int16_t(buf, 2, y);
  267. _mav_put_int16_t(buf, 4, z);
  268. _mav_put_int16_t(buf, 6, r);
  269. _mav_put_uint16_t(buf, 8, buttons);
  270. _mav_put_uint8_t(buf, 10, target);
  271. _mav_put_uint16_t(buf, 11, buttons2);
  272. _mav_put_uint8_t(buf, 13, enabled_extensions);
  273. _mav_put_int16_t(buf, 14, s);
  274. _mav_put_int16_t(buf, 16, t);
  275. _mav_put_int16_t(buf, 18, aux1);
  276. _mav_put_int16_t(buf, 20, aux2);
  277. _mav_put_int16_t(buf, 22, aux3);
  278. _mav_put_int16_t(buf, 24, aux4);
  279. _mav_put_int16_t(buf, 26, aux5);
  280. _mav_put_int16_t(buf, 28, aux6);
  281. _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);
  282. #else
  283. mavlink_manual_control_t packet;
  284. packet.x = x;
  285. packet.y = y;
  286. packet.z = z;
  287. packet.r = r;
  288. packet.buttons = buttons;
  289. packet.target = target;
  290. packet.buttons2 = buttons2;
  291. packet.enabled_extensions = enabled_extensions;
  292. packet.s = s;
  293. packet.t = t;
  294. packet.aux1 = aux1;
  295. packet.aux2 = aux2;
  296. packet.aux3 = aux3;
  297. packet.aux4 = aux4;
  298. packet.aux5 = aux5;
  299. packet.aux6 = aux6;
  300. _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);
  301. #endif
  302. }
  303. /**
  304. * @brief Send a manual_control message
  305. * @param chan MAVLink channel to send the message
  306. * @param struct The MAVLink struct to serialize
  307. */
  308. static inline void mavlink_msg_manual_control_send_struct(mavlink_channel_t chan, const mavlink_manual_control_t* manual_control)
  309. {
  310. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  311. mavlink_msg_manual_control_send(chan, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons, manual_control->buttons2, manual_control->enabled_extensions, manual_control->s, manual_control->t, manual_control->aux1, manual_control->aux2, manual_control->aux3, manual_control->aux4, manual_control->aux5, manual_control->aux6);
  312. #else
  313. _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);
  314. #endif
  315. }
  316. #if MAVLINK_MSG_ID_MANUAL_CONTROL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  317. /*
  318. This variant of _send() can be used to save stack space by re-using
  319. memory from the receive buffer. The caller provides a
  320. mavlink_message_t which is the size of a full mavlink message. This
  321. is usually the receive buffer for the channel, and allows a reply to an
  322. incoming message with minimum stack space usage.
  323. */
  324. 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, uint16_t buttons2, uint8_t enabled_extensions, int16_t s, int16_t t, int16_t aux1, int16_t aux2, int16_t aux3, int16_t aux4, int16_t aux5, int16_t aux6)
  325. {
  326. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  327. char *buf = (char *)msgbuf;
  328. _mav_put_int16_t(buf, 0, x);
  329. _mav_put_int16_t(buf, 2, y);
  330. _mav_put_int16_t(buf, 4, z);
  331. _mav_put_int16_t(buf, 6, r);
  332. _mav_put_uint16_t(buf, 8, buttons);
  333. _mav_put_uint8_t(buf, 10, target);
  334. _mav_put_uint16_t(buf, 11, buttons2);
  335. _mav_put_uint8_t(buf, 13, enabled_extensions);
  336. _mav_put_int16_t(buf, 14, s);
  337. _mav_put_int16_t(buf, 16, t);
  338. _mav_put_int16_t(buf, 18, aux1);
  339. _mav_put_int16_t(buf, 20, aux2);
  340. _mav_put_int16_t(buf, 22, aux3);
  341. _mav_put_int16_t(buf, 24, aux4);
  342. _mav_put_int16_t(buf, 26, aux5);
  343. _mav_put_int16_t(buf, 28, aux6);
  344. _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);
  345. #else
  346. mavlink_manual_control_t *packet = (mavlink_manual_control_t *)msgbuf;
  347. packet->x = x;
  348. packet->y = y;
  349. packet->z = z;
  350. packet->r = r;
  351. packet->buttons = buttons;
  352. packet->target = target;
  353. packet->buttons2 = buttons2;
  354. packet->enabled_extensions = enabled_extensions;
  355. packet->s = s;
  356. packet->t = t;
  357. packet->aux1 = aux1;
  358. packet->aux2 = aux2;
  359. packet->aux3 = aux3;
  360. packet->aux4 = aux4;
  361. packet->aux5 = aux5;
  362. packet->aux6 = aux6;
  363. _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);
  364. #endif
  365. }
  366. #endif
  367. #endif
  368. // MESSAGE MANUAL_CONTROL UNPACKING
  369. /**
  370. * @brief Get field target from manual_control message
  371. *
  372. * @return The system to be controlled.
  373. */
  374. static inline uint8_t mavlink_msg_manual_control_get_target(const mavlink_message_t* msg)
  375. {
  376. return _MAV_RETURN_uint8_t(msg, 10);
  377. }
  378. /**
  379. * @brief Get field x from manual_control message
  380. *
  381. * @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.
  382. */
  383. static inline int16_t mavlink_msg_manual_control_get_x(const mavlink_message_t* msg)
  384. {
  385. return _MAV_RETURN_int16_t(msg, 0);
  386. }
  387. /**
  388. * @brief Get field y from manual_control message
  389. *
  390. * @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.
  391. */
  392. static inline int16_t mavlink_msg_manual_control_get_y(const mavlink_message_t* msg)
  393. {
  394. return _MAV_RETURN_int16_t(msg, 2);
  395. }
  396. /**
  397. * @brief Get field z from manual_control message
  398. *
  399. * @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.
  400. */
  401. static inline int16_t mavlink_msg_manual_control_get_z(const mavlink_message_t* msg)
  402. {
  403. return _MAV_RETURN_int16_t(msg, 4);
  404. }
  405. /**
  406. * @brief Get field r from manual_control message
  407. *
  408. * @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.
  409. */
  410. static inline int16_t mavlink_msg_manual_control_get_r(const mavlink_message_t* msg)
  411. {
  412. return _MAV_RETURN_int16_t(msg, 6);
  413. }
  414. /**
  415. * @brief Get field buttons from manual_control message
  416. *
  417. * @return A bitfield corresponding to the joystick buttons' 0-15 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1.
  418. */
  419. static inline uint16_t mavlink_msg_manual_control_get_buttons(const mavlink_message_t* msg)
  420. {
  421. return _MAV_RETURN_uint16_t(msg, 8);
  422. }
  423. /**
  424. * @brief Get field buttons2 from manual_control message
  425. *
  426. * @return A bitfield corresponding to the joystick buttons' 16-31 current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 16.
  427. */
  428. static inline uint16_t mavlink_msg_manual_control_get_buttons2(const mavlink_message_t* msg)
  429. {
  430. return _MAV_RETURN_uint16_t(msg, 11);
  431. }
  432. /**
  433. * @brief Get field enabled_extensions from manual_control message
  434. *
  435. * @return Set bits to 1 to indicate which of the following extension fields contain valid data: bit 0: pitch, bit 1: roll, bit 2: aux1, bit 3: aux2, bit 4: aux3, bit 5: aux4, bit 6: aux5, bit 7: aux6
  436. */
  437. static inline uint8_t mavlink_msg_manual_control_get_enabled_extensions(const mavlink_message_t* msg)
  438. {
  439. return _MAV_RETURN_uint8_t(msg, 13);
  440. }
  441. /**
  442. * @brief Get field s from manual_control message
  443. *
  444. * @return Pitch-only-axis, normalized to the range [-1000,1000]. Generally corresponds to pitch on vehicles with additional degrees of freedom. Valid if bit 0 of enabled_extensions field is set. Set to 0 if invalid.
  445. */
  446. static inline int16_t mavlink_msg_manual_control_get_s(const mavlink_message_t* msg)
  447. {
  448. return _MAV_RETURN_int16_t(msg, 14);
  449. }
  450. /**
  451. * @brief Get field t from manual_control message
  452. *
  453. * @return Roll-only-axis, normalized to the range [-1000,1000]. Generally corresponds to roll on vehicles with additional degrees of freedom. Valid if bit 1 of enabled_extensions field is set. Set to 0 if invalid.
  454. */
  455. static inline int16_t mavlink_msg_manual_control_get_t(const mavlink_message_t* msg)
  456. {
  457. return _MAV_RETURN_int16_t(msg, 16);
  458. }
  459. /**
  460. * @brief Get field aux1 from manual_control message
  461. *
  462. * @return Aux continuous input field 1. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 2 of enabled_extensions field is set. 0 if bit 2 is unset.
  463. */
  464. static inline int16_t mavlink_msg_manual_control_get_aux1(const mavlink_message_t* msg)
  465. {
  466. return _MAV_RETURN_int16_t(msg, 18);
  467. }
  468. /**
  469. * @brief Get field aux2 from manual_control message
  470. *
  471. * @return Aux continuous input field 2. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 3 of enabled_extensions field is set. 0 if bit 3 is unset.
  472. */
  473. static inline int16_t mavlink_msg_manual_control_get_aux2(const mavlink_message_t* msg)
  474. {
  475. return _MAV_RETURN_int16_t(msg, 20);
  476. }
  477. /**
  478. * @brief Get field aux3 from manual_control message
  479. *
  480. * @return Aux continuous input field 3. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 4 of enabled_extensions field is set. 0 if bit 4 is unset.
  481. */
  482. static inline int16_t mavlink_msg_manual_control_get_aux3(const mavlink_message_t* msg)
  483. {
  484. return _MAV_RETURN_int16_t(msg, 22);
  485. }
  486. /**
  487. * @brief Get field aux4 from manual_control message
  488. *
  489. * @return Aux continuous input field 4. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 5 of enabled_extensions field is set. 0 if bit 5 is unset.
  490. */
  491. static inline int16_t mavlink_msg_manual_control_get_aux4(const mavlink_message_t* msg)
  492. {
  493. return _MAV_RETURN_int16_t(msg, 24);
  494. }
  495. /**
  496. * @brief Get field aux5 from manual_control message
  497. *
  498. * @return Aux continuous input field 5. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 6 of enabled_extensions field is set. 0 if bit 6 is unset.
  499. */
  500. static inline int16_t mavlink_msg_manual_control_get_aux5(const mavlink_message_t* msg)
  501. {
  502. return _MAV_RETURN_int16_t(msg, 26);
  503. }
  504. /**
  505. * @brief Get field aux6 from manual_control message
  506. *
  507. * @return Aux continuous input field 6. Normalized in the range [-1000,1000]. Purpose defined by recipient. Valid data if bit 7 of enabled_extensions field is set. 0 if bit 7 is unset.
  508. */
  509. static inline int16_t mavlink_msg_manual_control_get_aux6(const mavlink_message_t* msg)
  510. {
  511. return _MAV_RETURN_int16_t(msg, 28);
  512. }
  513. /**
  514. * @brief Decode a manual_control message into a struct
  515. *
  516. * @param msg The message to decode
  517. * @param manual_control C-struct to decode the message contents into
  518. */
  519. static inline void mavlink_msg_manual_control_decode(const mavlink_message_t* msg, mavlink_manual_control_t* manual_control)
  520. {
  521. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  522. manual_control->x = mavlink_msg_manual_control_get_x(msg);
  523. manual_control->y = mavlink_msg_manual_control_get_y(msg);
  524. manual_control->z = mavlink_msg_manual_control_get_z(msg);
  525. manual_control->r = mavlink_msg_manual_control_get_r(msg);
  526. manual_control->buttons = mavlink_msg_manual_control_get_buttons(msg);
  527. manual_control->target = mavlink_msg_manual_control_get_target(msg);
  528. manual_control->buttons2 = mavlink_msg_manual_control_get_buttons2(msg);
  529. manual_control->enabled_extensions = mavlink_msg_manual_control_get_enabled_extensions(msg);
  530. manual_control->s = mavlink_msg_manual_control_get_s(msg);
  531. manual_control->t = mavlink_msg_manual_control_get_t(msg);
  532. manual_control->aux1 = mavlink_msg_manual_control_get_aux1(msg);
  533. manual_control->aux2 = mavlink_msg_manual_control_get_aux2(msg);
  534. manual_control->aux3 = mavlink_msg_manual_control_get_aux3(msg);
  535. manual_control->aux4 = mavlink_msg_manual_control_get_aux4(msg);
  536. manual_control->aux5 = mavlink_msg_manual_control_get_aux5(msg);
  537. manual_control->aux6 = mavlink_msg_manual_control_get_aux6(msg);
  538. #else
  539. uint8_t len = msg->len < MAVLINK_MSG_ID_MANUAL_CONTROL_LEN? msg->len : MAVLINK_MSG_ID_MANUAL_CONTROL_LEN;
  540. memset(manual_control, 0, MAVLINK_MSG_ID_MANUAL_CONTROL_LEN);
  541. memcpy(manual_control, _MAV_PAYLOAD(msg), len);
  542. #endif
  543. }