mavlink_msg_mission_item.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. #pragma once
  2. // MESSAGE MISSION_ITEM PACKING
  3. #define MAVLINK_MSG_ID_MISSION_ITEM 39
  4. typedef struct __mavlink_mission_item_t {
  5. float param1; /*< PARAM1, see MAV_CMD enum*/
  6. float param2; /*< PARAM2, see MAV_CMD enum*/
  7. float param3; /*< PARAM3, see MAV_CMD enum*/
  8. float param4; /*< PARAM4, see MAV_CMD enum*/
  9. float x; /*< PARAM5 / local: X coordinate, global: latitude*/
  10. float y; /*< PARAM6 / local: Y coordinate, global: longitude*/
  11. float z; /*< PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).*/
  12. uint16_t seq; /*< Sequence*/
  13. uint16_t command; /*< The scheduled action for the waypoint.*/
  14. uint8_t target_system; /*< System ID*/
  15. uint8_t target_component; /*< Component ID*/
  16. uint8_t frame; /*< The coordinate system of the waypoint.*/
  17. uint8_t current; /*< false:0, true:1*/
  18. uint8_t autocontinue; /*< Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.*/
  19. uint8_t mission_type; /*< Mission type.*/
  20. } mavlink_mission_item_t;
  21. #define MAVLINK_MSG_ID_MISSION_ITEM_LEN 38
  22. #define MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN 37
  23. #define MAVLINK_MSG_ID_39_LEN 38
  24. #define MAVLINK_MSG_ID_39_MIN_LEN 37
  25. #define MAVLINK_MSG_ID_MISSION_ITEM_CRC 254
  26. #define MAVLINK_MSG_ID_39_CRC 254
  27. #if MAVLINK_COMMAND_24BIT
  28. #define MAVLINK_MESSAGE_INFO_MISSION_ITEM { \
  29. 39, \
  30. "MISSION_ITEM", \
  31. 15, \
  32. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_mission_item_t, target_system) }, \
  33. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_mission_item_t, target_component) }, \
  34. { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_mission_item_t, seq) }, \
  35. { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_mission_item_t, frame) }, \
  36. { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 30, offsetof(mavlink_mission_item_t, command) }, \
  37. { "current", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_mission_item_t, current) }, \
  38. { "autocontinue", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_mission_item_t, autocontinue) }, \
  39. { "param1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mission_item_t, param1) }, \
  40. { "param2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mission_item_t, param2) }, \
  41. { "param3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mission_item_t, param3) }, \
  42. { "param4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mission_item_t, param4) }, \
  43. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mission_item_t, x) }, \
  44. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mission_item_t, y) }, \
  45. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mission_item_t, z) }, \
  46. { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_mission_item_t, mission_type) }, \
  47. } \
  48. }
  49. #else
  50. #define MAVLINK_MESSAGE_INFO_MISSION_ITEM { \
  51. "MISSION_ITEM", \
  52. 15, \
  53. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_mission_item_t, target_system) }, \
  54. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_mission_item_t, target_component) }, \
  55. { "seq", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_mission_item_t, seq) }, \
  56. { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_mission_item_t, frame) }, \
  57. { "command", NULL, MAVLINK_TYPE_UINT16_T, 0, 30, offsetof(mavlink_mission_item_t, command) }, \
  58. { "current", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_mission_item_t, current) }, \
  59. { "autocontinue", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_mission_item_t, autocontinue) }, \
  60. { "param1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mission_item_t, param1) }, \
  61. { "param2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mission_item_t, param2) }, \
  62. { "param3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mission_item_t, param3) }, \
  63. { "param4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mission_item_t, param4) }, \
  64. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mission_item_t, x) }, \
  65. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mission_item_t, y) }, \
  66. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mission_item_t, z) }, \
  67. { "mission_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_mission_item_t, mission_type) }, \
  68. } \
  69. }
  70. #endif
  71. /**
  72. * @brief Pack a mission_item message
  73. * @param system_id ID of this system
  74. * @param component_id ID of this component (e.g. 200 for IMU)
  75. * @param msg The MAVLink message to compress the data into
  76. *
  77. * @param target_system System ID
  78. * @param target_component Component ID
  79. * @param seq Sequence
  80. * @param frame The coordinate system of the waypoint.
  81. * @param command The scheduled action for the waypoint.
  82. * @param current false:0, true:1
  83. * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.
  84. * @param param1 PARAM1, see MAV_CMD enum
  85. * @param param2 PARAM2, see MAV_CMD enum
  86. * @param param3 PARAM3, see MAV_CMD enum
  87. * @param param4 PARAM4, see MAV_CMD enum
  88. * @param x PARAM5 / local: X coordinate, global: latitude
  89. * @param y PARAM6 / local: Y coordinate, global: longitude
  90. * @param z PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).
  91. * @param mission_type Mission type.
  92. * @return length of the message in bytes (excluding serial stream start sign)
  93. */
  94. static inline uint16_t mavlink_msg_mission_item_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  95. uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, float x, float y, float z, uint8_t mission_type)
  96. {
  97. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  98. char buf[MAVLINK_MSG_ID_MISSION_ITEM_LEN];
  99. _mav_put_float(buf, 0, param1);
  100. _mav_put_float(buf, 4, param2);
  101. _mav_put_float(buf, 8, param3);
  102. _mav_put_float(buf, 12, param4);
  103. _mav_put_float(buf, 16, x);
  104. _mav_put_float(buf, 20, y);
  105. _mav_put_float(buf, 24, z);
  106. _mav_put_uint16_t(buf, 28, seq);
  107. _mav_put_uint16_t(buf, 30, command);
  108. _mav_put_uint8_t(buf, 32, target_system);
  109. _mav_put_uint8_t(buf, 33, target_component);
  110. _mav_put_uint8_t(buf, 34, frame);
  111. _mav_put_uint8_t(buf, 35, current);
  112. _mav_put_uint8_t(buf, 36, autocontinue);
  113. _mav_put_uint8_t(buf, 37, mission_type);
  114. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  115. #else
  116. mavlink_mission_item_t packet;
  117. packet.param1 = param1;
  118. packet.param2 = param2;
  119. packet.param3 = param3;
  120. packet.param4 = param4;
  121. packet.x = x;
  122. packet.y = y;
  123. packet.z = z;
  124. packet.seq = seq;
  125. packet.command = command;
  126. packet.target_system = target_system;
  127. packet.target_component = target_component;
  128. packet.frame = frame;
  129. packet.current = current;
  130. packet.autocontinue = autocontinue;
  131. packet.mission_type = mission_type;
  132. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  133. #endif
  134. msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM;
  135. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  136. }
  137. /**
  138. * @brief Pack a mission_item message
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param status MAVLink status structure
  142. * @param msg The MAVLink message to compress the data into
  143. *
  144. * @param target_system System ID
  145. * @param target_component Component ID
  146. * @param seq Sequence
  147. * @param frame The coordinate system of the waypoint.
  148. * @param command The scheduled action for the waypoint.
  149. * @param current false:0, true:1
  150. * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.
  151. * @param param1 PARAM1, see MAV_CMD enum
  152. * @param param2 PARAM2, see MAV_CMD enum
  153. * @param param3 PARAM3, see MAV_CMD enum
  154. * @param param4 PARAM4, see MAV_CMD enum
  155. * @param x PARAM5 / local: X coordinate, global: latitude
  156. * @param y PARAM6 / local: Y coordinate, global: longitude
  157. * @param z PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).
  158. * @param mission_type Mission type.
  159. * @return length of the message in bytes (excluding serial stream start sign)
  160. */
  161. static inline uint16_t mavlink_msg_mission_item_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  162. uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, float x, float y, float z, uint8_t mission_type)
  163. {
  164. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  165. char buf[MAVLINK_MSG_ID_MISSION_ITEM_LEN];
  166. _mav_put_float(buf, 0, param1);
  167. _mav_put_float(buf, 4, param2);
  168. _mav_put_float(buf, 8, param3);
  169. _mav_put_float(buf, 12, param4);
  170. _mav_put_float(buf, 16, x);
  171. _mav_put_float(buf, 20, y);
  172. _mav_put_float(buf, 24, z);
  173. _mav_put_uint16_t(buf, 28, seq);
  174. _mav_put_uint16_t(buf, 30, command);
  175. _mav_put_uint8_t(buf, 32, target_system);
  176. _mav_put_uint8_t(buf, 33, target_component);
  177. _mav_put_uint8_t(buf, 34, frame);
  178. _mav_put_uint8_t(buf, 35, current);
  179. _mav_put_uint8_t(buf, 36, autocontinue);
  180. _mav_put_uint8_t(buf, 37, mission_type);
  181. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  182. #else
  183. mavlink_mission_item_t packet;
  184. packet.param1 = param1;
  185. packet.param2 = param2;
  186. packet.param3 = param3;
  187. packet.param4 = param4;
  188. packet.x = x;
  189. packet.y = y;
  190. packet.z = z;
  191. packet.seq = seq;
  192. packet.command = command;
  193. packet.target_system = target_system;
  194. packet.target_component = target_component;
  195. packet.frame = frame;
  196. packet.current = current;
  197. packet.autocontinue = autocontinue;
  198. packet.mission_type = mission_type;
  199. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  200. #endif
  201. msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM;
  202. #if MAVLINK_CRC_EXTRA
  203. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  204. #else
  205. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  206. #endif
  207. }
  208. /**
  209. * @brief Pack a mission_item message on a channel
  210. * @param system_id ID of this system
  211. * @param component_id ID of this component (e.g. 200 for IMU)
  212. * @param chan The MAVLink channel this message will be sent over
  213. * @param msg The MAVLink message to compress the data into
  214. * @param target_system System ID
  215. * @param target_component Component ID
  216. * @param seq Sequence
  217. * @param frame The coordinate system of the waypoint.
  218. * @param command The scheduled action for the waypoint.
  219. * @param current false:0, true:1
  220. * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.
  221. * @param param1 PARAM1, see MAV_CMD enum
  222. * @param param2 PARAM2, see MAV_CMD enum
  223. * @param param3 PARAM3, see MAV_CMD enum
  224. * @param param4 PARAM4, see MAV_CMD enum
  225. * @param x PARAM5 / local: X coordinate, global: latitude
  226. * @param y PARAM6 / local: Y coordinate, global: longitude
  227. * @param z PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).
  228. * @param mission_type Mission type.
  229. * @return length of the message in bytes (excluding serial stream start sign)
  230. */
  231. static inline uint16_t mavlink_msg_mission_item_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  232. mavlink_message_t* msg,
  233. uint8_t target_system,uint8_t target_component,uint16_t seq,uint8_t frame,uint16_t command,uint8_t current,uint8_t autocontinue,float param1,float param2,float param3,float param4,float x,float y,float z,uint8_t mission_type)
  234. {
  235. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  236. char buf[MAVLINK_MSG_ID_MISSION_ITEM_LEN];
  237. _mav_put_float(buf, 0, param1);
  238. _mav_put_float(buf, 4, param2);
  239. _mav_put_float(buf, 8, param3);
  240. _mav_put_float(buf, 12, param4);
  241. _mav_put_float(buf, 16, x);
  242. _mav_put_float(buf, 20, y);
  243. _mav_put_float(buf, 24, z);
  244. _mav_put_uint16_t(buf, 28, seq);
  245. _mav_put_uint16_t(buf, 30, command);
  246. _mav_put_uint8_t(buf, 32, target_system);
  247. _mav_put_uint8_t(buf, 33, target_component);
  248. _mav_put_uint8_t(buf, 34, frame);
  249. _mav_put_uint8_t(buf, 35, current);
  250. _mav_put_uint8_t(buf, 36, autocontinue);
  251. _mav_put_uint8_t(buf, 37, mission_type);
  252. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  253. #else
  254. mavlink_mission_item_t packet;
  255. packet.param1 = param1;
  256. packet.param2 = param2;
  257. packet.param3 = param3;
  258. packet.param4 = param4;
  259. packet.x = x;
  260. packet.y = y;
  261. packet.z = z;
  262. packet.seq = seq;
  263. packet.command = command;
  264. packet.target_system = target_system;
  265. packet.target_component = target_component;
  266. packet.frame = frame;
  267. packet.current = current;
  268. packet.autocontinue = autocontinue;
  269. packet.mission_type = mission_type;
  270. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  271. #endif
  272. msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM;
  273. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  274. }
  275. /**
  276. * @brief Encode a mission_item struct
  277. *
  278. * @param system_id ID of this system
  279. * @param component_id ID of this component (e.g. 200 for IMU)
  280. * @param msg The MAVLink message to compress the data into
  281. * @param mission_item C-struct to read the message contents from
  282. */
  283. static inline uint16_t mavlink_msg_mission_item_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mission_item_t* mission_item)
  284. {
  285. return mavlink_msg_mission_item_pack(system_id, component_id, msg, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type);
  286. }
  287. /**
  288. * @brief Encode a mission_item struct on a channel
  289. *
  290. * @param system_id ID of this system
  291. * @param component_id ID of this component (e.g. 200 for IMU)
  292. * @param chan The MAVLink channel this message will be sent over
  293. * @param msg The MAVLink message to compress the data into
  294. * @param mission_item C-struct to read the message contents from
  295. */
  296. static inline uint16_t mavlink_msg_mission_item_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mission_item_t* mission_item)
  297. {
  298. return mavlink_msg_mission_item_pack_chan(system_id, component_id, chan, msg, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type);
  299. }
  300. /**
  301. * @brief Encode a mission_item struct with provided status structure
  302. *
  303. * @param system_id ID of this system
  304. * @param component_id ID of this component (e.g. 200 for IMU)
  305. * @param status MAVLink status structure
  306. * @param msg The MAVLink message to compress the data into
  307. * @param mission_item C-struct to read the message contents from
  308. */
  309. static inline uint16_t mavlink_msg_mission_item_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mission_item_t* mission_item)
  310. {
  311. return mavlink_msg_mission_item_pack_status(system_id, component_id, _status, msg, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type);
  312. }
  313. /**
  314. * @brief Send a mission_item message
  315. * @param chan MAVLink channel to send the message
  316. *
  317. * @param target_system System ID
  318. * @param target_component Component ID
  319. * @param seq Sequence
  320. * @param frame The coordinate system of the waypoint.
  321. * @param command The scheduled action for the waypoint.
  322. * @param current false:0, true:1
  323. * @param autocontinue Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.
  324. * @param param1 PARAM1, see MAV_CMD enum
  325. * @param param2 PARAM2, see MAV_CMD enum
  326. * @param param3 PARAM3, see MAV_CMD enum
  327. * @param param4 PARAM4, see MAV_CMD enum
  328. * @param x PARAM5 / local: X coordinate, global: latitude
  329. * @param y PARAM6 / local: Y coordinate, global: longitude
  330. * @param z PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).
  331. * @param mission_type Mission type.
  332. */
  333. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  334. static inline void mavlink_msg_mission_item_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, float x, float y, float z, uint8_t mission_type)
  335. {
  336. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  337. char buf[MAVLINK_MSG_ID_MISSION_ITEM_LEN];
  338. _mav_put_float(buf, 0, param1);
  339. _mav_put_float(buf, 4, param2);
  340. _mav_put_float(buf, 8, param3);
  341. _mav_put_float(buf, 12, param4);
  342. _mav_put_float(buf, 16, x);
  343. _mav_put_float(buf, 20, y);
  344. _mav_put_float(buf, 24, z);
  345. _mav_put_uint16_t(buf, 28, seq);
  346. _mav_put_uint16_t(buf, 30, command);
  347. _mav_put_uint8_t(buf, 32, target_system);
  348. _mav_put_uint8_t(buf, 33, target_component);
  349. _mav_put_uint8_t(buf, 34, frame);
  350. _mav_put_uint8_t(buf, 35, current);
  351. _mav_put_uint8_t(buf, 36, autocontinue);
  352. _mav_put_uint8_t(buf, 37, mission_type);
  353. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM, buf, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  354. #else
  355. mavlink_mission_item_t packet;
  356. packet.param1 = param1;
  357. packet.param2 = param2;
  358. packet.param3 = param3;
  359. packet.param4 = param4;
  360. packet.x = x;
  361. packet.y = y;
  362. packet.z = z;
  363. packet.seq = seq;
  364. packet.command = command;
  365. packet.target_system = target_system;
  366. packet.target_component = target_component;
  367. packet.frame = frame;
  368. packet.current = current;
  369. packet.autocontinue = autocontinue;
  370. packet.mission_type = mission_type;
  371. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM, (const char *)&packet, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  372. #endif
  373. }
  374. /**
  375. * @brief Send a mission_item message
  376. * @param chan MAVLink channel to send the message
  377. * @param struct The MAVLink struct to serialize
  378. */
  379. static inline void mavlink_msg_mission_item_send_struct(mavlink_channel_t chan, const mavlink_mission_item_t* mission_item)
  380. {
  381. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  382. mavlink_msg_mission_item_send(chan, mission_item->target_system, mission_item->target_component, mission_item->seq, mission_item->frame, mission_item->command, mission_item->current, mission_item->autocontinue, mission_item->param1, mission_item->param2, mission_item->param3, mission_item->param4, mission_item->x, mission_item->y, mission_item->z, mission_item->mission_type);
  383. #else
  384. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM, (const char *)mission_item, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  385. #endif
  386. }
  387. #if MAVLINK_MSG_ID_MISSION_ITEM_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  388. /*
  389. This variant of _send() can be used to save stack space by re-using
  390. memory from the receive buffer. The caller provides a
  391. mavlink_message_t which is the size of a full mavlink message. This
  392. is usually the receive buffer for the channel, and allows a reply to an
  393. incoming message with minimum stack space usage.
  394. */
  395. static inline void mavlink_msg_mission_item_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint16_t seq, uint8_t frame, uint16_t command, uint8_t current, uint8_t autocontinue, float param1, float param2, float param3, float param4, float x, float y, float z, uint8_t mission_type)
  396. {
  397. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  398. char *buf = (char *)msgbuf;
  399. _mav_put_float(buf, 0, param1);
  400. _mav_put_float(buf, 4, param2);
  401. _mav_put_float(buf, 8, param3);
  402. _mav_put_float(buf, 12, param4);
  403. _mav_put_float(buf, 16, x);
  404. _mav_put_float(buf, 20, y);
  405. _mav_put_float(buf, 24, z);
  406. _mav_put_uint16_t(buf, 28, seq);
  407. _mav_put_uint16_t(buf, 30, command);
  408. _mav_put_uint8_t(buf, 32, target_system);
  409. _mav_put_uint8_t(buf, 33, target_component);
  410. _mav_put_uint8_t(buf, 34, frame);
  411. _mav_put_uint8_t(buf, 35, current);
  412. _mav_put_uint8_t(buf, 36, autocontinue);
  413. _mav_put_uint8_t(buf, 37, mission_type);
  414. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM, buf, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  415. #else
  416. mavlink_mission_item_t *packet = (mavlink_mission_item_t *)msgbuf;
  417. packet->param1 = param1;
  418. packet->param2 = param2;
  419. packet->param3 = param3;
  420. packet->param4 = param4;
  421. packet->x = x;
  422. packet->y = y;
  423. packet->z = z;
  424. packet->seq = seq;
  425. packet->command = command;
  426. packet->target_system = target_system;
  427. packet->target_component = target_component;
  428. packet->frame = frame;
  429. packet->current = current;
  430. packet->autocontinue = autocontinue;
  431. packet->mission_type = mission_type;
  432. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MISSION_ITEM, (const char *)packet, MAVLINK_MSG_ID_MISSION_ITEM_MIN_LEN, MAVLINK_MSG_ID_MISSION_ITEM_LEN, MAVLINK_MSG_ID_MISSION_ITEM_CRC);
  433. #endif
  434. }
  435. #endif
  436. #endif
  437. // MESSAGE MISSION_ITEM UNPACKING
  438. /**
  439. * @brief Get field target_system from mission_item message
  440. *
  441. * @return System ID
  442. */
  443. static inline uint8_t mavlink_msg_mission_item_get_target_system(const mavlink_message_t* msg)
  444. {
  445. return _MAV_RETURN_uint8_t(msg, 32);
  446. }
  447. /**
  448. * @brief Get field target_component from mission_item message
  449. *
  450. * @return Component ID
  451. */
  452. static inline uint8_t mavlink_msg_mission_item_get_target_component(const mavlink_message_t* msg)
  453. {
  454. return _MAV_RETURN_uint8_t(msg, 33);
  455. }
  456. /**
  457. * @brief Get field seq from mission_item message
  458. *
  459. * @return Sequence
  460. */
  461. static inline uint16_t mavlink_msg_mission_item_get_seq(const mavlink_message_t* msg)
  462. {
  463. return _MAV_RETURN_uint16_t(msg, 28);
  464. }
  465. /**
  466. * @brief Get field frame from mission_item message
  467. *
  468. * @return The coordinate system of the waypoint.
  469. */
  470. static inline uint8_t mavlink_msg_mission_item_get_frame(const mavlink_message_t* msg)
  471. {
  472. return _MAV_RETURN_uint8_t(msg, 34);
  473. }
  474. /**
  475. * @brief Get field command from mission_item message
  476. *
  477. * @return The scheduled action for the waypoint.
  478. */
  479. static inline uint16_t mavlink_msg_mission_item_get_command(const mavlink_message_t* msg)
  480. {
  481. return _MAV_RETURN_uint16_t(msg, 30);
  482. }
  483. /**
  484. * @brief Get field current from mission_item message
  485. *
  486. * @return false:0, true:1
  487. */
  488. static inline uint8_t mavlink_msg_mission_item_get_current(const mavlink_message_t* msg)
  489. {
  490. return _MAV_RETURN_uint8_t(msg, 35);
  491. }
  492. /**
  493. * @brief Get field autocontinue from mission_item message
  494. *
  495. * @return Autocontinue to next waypoint. 0: false, 1: true. Set false to pause mission after the item completes.
  496. */
  497. static inline uint8_t mavlink_msg_mission_item_get_autocontinue(const mavlink_message_t* msg)
  498. {
  499. return _MAV_RETURN_uint8_t(msg, 36);
  500. }
  501. /**
  502. * @brief Get field param1 from mission_item message
  503. *
  504. * @return PARAM1, see MAV_CMD enum
  505. */
  506. static inline float mavlink_msg_mission_item_get_param1(const mavlink_message_t* msg)
  507. {
  508. return _MAV_RETURN_float(msg, 0);
  509. }
  510. /**
  511. * @brief Get field param2 from mission_item message
  512. *
  513. * @return PARAM2, see MAV_CMD enum
  514. */
  515. static inline float mavlink_msg_mission_item_get_param2(const mavlink_message_t* msg)
  516. {
  517. return _MAV_RETURN_float(msg, 4);
  518. }
  519. /**
  520. * @brief Get field param3 from mission_item message
  521. *
  522. * @return PARAM3, see MAV_CMD enum
  523. */
  524. static inline float mavlink_msg_mission_item_get_param3(const mavlink_message_t* msg)
  525. {
  526. return _MAV_RETURN_float(msg, 8);
  527. }
  528. /**
  529. * @brief Get field param4 from mission_item message
  530. *
  531. * @return PARAM4, see MAV_CMD enum
  532. */
  533. static inline float mavlink_msg_mission_item_get_param4(const mavlink_message_t* msg)
  534. {
  535. return _MAV_RETURN_float(msg, 12);
  536. }
  537. /**
  538. * @brief Get field x from mission_item message
  539. *
  540. * @return PARAM5 / local: X coordinate, global: latitude
  541. */
  542. static inline float mavlink_msg_mission_item_get_x(const mavlink_message_t* msg)
  543. {
  544. return _MAV_RETURN_float(msg, 16);
  545. }
  546. /**
  547. * @brief Get field y from mission_item message
  548. *
  549. * @return PARAM6 / local: Y coordinate, global: longitude
  550. */
  551. static inline float mavlink_msg_mission_item_get_y(const mavlink_message_t* msg)
  552. {
  553. return _MAV_RETURN_float(msg, 20);
  554. }
  555. /**
  556. * @brief Get field z from mission_item message
  557. *
  558. * @return PARAM7 / local: Z coordinate, global: altitude (relative or absolute, depending on frame).
  559. */
  560. static inline float mavlink_msg_mission_item_get_z(const mavlink_message_t* msg)
  561. {
  562. return _MAV_RETURN_float(msg, 24);
  563. }
  564. /**
  565. * @brief Get field mission_type from mission_item message
  566. *
  567. * @return Mission type.
  568. */
  569. static inline uint8_t mavlink_msg_mission_item_get_mission_type(const mavlink_message_t* msg)
  570. {
  571. return _MAV_RETURN_uint8_t(msg, 37);
  572. }
  573. /**
  574. * @brief Decode a mission_item message into a struct
  575. *
  576. * @param msg The message to decode
  577. * @param mission_item C-struct to decode the message contents into
  578. */
  579. static inline void mavlink_msg_mission_item_decode(const mavlink_message_t* msg, mavlink_mission_item_t* mission_item)
  580. {
  581. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  582. mission_item->param1 = mavlink_msg_mission_item_get_param1(msg);
  583. mission_item->param2 = mavlink_msg_mission_item_get_param2(msg);
  584. mission_item->param3 = mavlink_msg_mission_item_get_param3(msg);
  585. mission_item->param4 = mavlink_msg_mission_item_get_param4(msg);
  586. mission_item->x = mavlink_msg_mission_item_get_x(msg);
  587. mission_item->y = mavlink_msg_mission_item_get_y(msg);
  588. mission_item->z = mavlink_msg_mission_item_get_z(msg);
  589. mission_item->seq = mavlink_msg_mission_item_get_seq(msg);
  590. mission_item->command = mavlink_msg_mission_item_get_command(msg);
  591. mission_item->target_system = mavlink_msg_mission_item_get_target_system(msg);
  592. mission_item->target_component = mavlink_msg_mission_item_get_target_component(msg);
  593. mission_item->frame = mavlink_msg_mission_item_get_frame(msg);
  594. mission_item->current = mavlink_msg_mission_item_get_current(msg);
  595. mission_item->autocontinue = mavlink_msg_mission_item_get_autocontinue(msg);
  596. mission_item->mission_type = mavlink_msg_mission_item_get_mission_type(msg);
  597. #else
  598. uint8_t len = msg->len < MAVLINK_MSG_ID_MISSION_ITEM_LEN? msg->len : MAVLINK_MSG_ID_MISSION_ITEM_LEN;
  599. memset(mission_item, 0, MAVLINK_MSG_ID_MISSION_ITEM_LEN);
  600. memcpy(mission_item, _MAV_PAYLOAD(msg), len);
  601. #endif
  602. }