2
0

mavlink_msg_landing_target.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. #pragma once
  2. // MESSAGE LANDING_TARGET PACKING
  3. #define MAVLINK_MSG_ID_LANDING_TARGET 149
  4. MAVPACKED(
  5. typedef struct __mavlink_landing_target_t {
  6. uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
  7. float angle_x; /*< [rad] X-axis angular offset of the target from the center of the image*/
  8. float angle_y; /*< [rad] Y-axis angular offset of the target from the center of the image*/
  9. float distance; /*< [m] Distance to the target from the vehicle*/
  10. float size_x; /*< [rad] Size of target along x-axis*/
  11. float size_y; /*< [rad] Size of target along y-axis*/
  12. uint8_t target_num; /*< The ID of the target if multiple targets are present*/
  13. uint8_t frame; /*< Coordinate frame used for following fields.*/
  14. float x; /*< [m] X Position of the landing target in MAV_FRAME*/
  15. float y; /*< [m] Y Position of the landing target in MAV_FRAME*/
  16. float z; /*< [m] Z Position of the landing target in MAV_FRAME*/
  17. float q[4]; /*< Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)*/
  18. uint8_t type; /*< Type of landing target*/
  19. uint8_t position_valid; /*< Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).*/
  20. }) mavlink_landing_target_t;
  21. #define MAVLINK_MSG_ID_LANDING_TARGET_LEN 60
  22. #define MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN 30
  23. #define MAVLINK_MSG_ID_149_LEN 60
  24. #define MAVLINK_MSG_ID_149_MIN_LEN 30
  25. #define MAVLINK_MSG_ID_LANDING_TARGET_CRC 200
  26. #define MAVLINK_MSG_ID_149_CRC 200
  27. #define MAVLINK_MSG_LANDING_TARGET_FIELD_Q_LEN 4
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_LANDING_TARGET { \
  30. 149, \
  31. "LANDING_TARGET", \
  32. 14, \
  33. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_landing_target_t, time_usec) }, \
  34. { "target_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_landing_target_t, target_num) }, \
  35. { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_landing_target_t, frame) }, \
  36. { "angle_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_landing_target_t, angle_x) }, \
  37. { "angle_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_landing_target_t, angle_y) }, \
  38. { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_landing_target_t, distance) }, \
  39. { "size_x", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_landing_target_t, size_x) }, \
  40. { "size_y", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_landing_target_t, size_y) }, \
  41. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 30, offsetof(mavlink_landing_target_t, x) }, \
  42. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 34, offsetof(mavlink_landing_target_t, y) }, \
  43. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 38, offsetof(mavlink_landing_target_t, z) }, \
  44. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 42, offsetof(mavlink_landing_target_t, q) }, \
  45. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 58, offsetof(mavlink_landing_target_t, type) }, \
  46. { "position_valid", NULL, MAVLINK_TYPE_UINT8_T, 0, 59, offsetof(mavlink_landing_target_t, position_valid) }, \
  47. } \
  48. }
  49. #else
  50. #define MAVLINK_MESSAGE_INFO_LANDING_TARGET { \
  51. "LANDING_TARGET", \
  52. 14, \
  53. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_landing_target_t, time_usec) }, \
  54. { "target_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_landing_target_t, target_num) }, \
  55. { "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 29, offsetof(mavlink_landing_target_t, frame) }, \
  56. { "angle_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_landing_target_t, angle_x) }, \
  57. { "angle_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_landing_target_t, angle_y) }, \
  58. { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_landing_target_t, distance) }, \
  59. { "size_x", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_landing_target_t, size_x) }, \
  60. { "size_y", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_landing_target_t, size_y) }, \
  61. { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 30, offsetof(mavlink_landing_target_t, x) }, \
  62. { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 34, offsetof(mavlink_landing_target_t, y) }, \
  63. { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 38, offsetof(mavlink_landing_target_t, z) }, \
  64. { "q", NULL, MAVLINK_TYPE_FLOAT, 4, 42, offsetof(mavlink_landing_target_t, q) }, \
  65. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 58, offsetof(mavlink_landing_target_t, type) }, \
  66. { "position_valid", NULL, MAVLINK_TYPE_UINT8_T, 0, 59, offsetof(mavlink_landing_target_t, position_valid) }, \
  67. } \
  68. }
  69. #endif
  70. /**
  71. * @brief Pack a landing_target message
  72. * @param system_id ID of this system
  73. * @param component_id ID of this component (e.g. 200 for IMU)
  74. * @param msg The MAVLink message to compress the data into
  75. *
  76. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  77. * @param target_num The ID of the target if multiple targets are present
  78. * @param frame Coordinate frame used for following fields.
  79. * @param angle_x [rad] X-axis angular offset of the target from the center of the image
  80. * @param angle_y [rad] Y-axis angular offset of the target from the center of the image
  81. * @param distance [m] Distance to the target from the vehicle
  82. * @param size_x [rad] Size of target along x-axis
  83. * @param size_y [rad] Size of target along y-axis
  84. * @param x [m] X Position of the landing target in MAV_FRAME
  85. * @param y [m] Y Position of the landing target in MAV_FRAME
  86. * @param z [m] Z Position of the landing target in MAV_FRAME
  87. * @param q Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
  88. * @param type Type of landing target
  89. * @param position_valid Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).
  90. * @return length of the message in bytes (excluding serial stream start sign)
  91. */
  92. static inline uint16_t mavlink_msg_landing_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  93. uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y, float x, float y, float z, const float *q, uint8_t type, uint8_t position_valid)
  94. {
  95. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  96. char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
  97. _mav_put_uint64_t(buf, 0, time_usec);
  98. _mav_put_float(buf, 8, angle_x);
  99. _mav_put_float(buf, 12, angle_y);
  100. _mav_put_float(buf, 16, distance);
  101. _mav_put_float(buf, 20, size_x);
  102. _mav_put_float(buf, 24, size_y);
  103. _mav_put_uint8_t(buf, 28, target_num);
  104. _mav_put_uint8_t(buf, 29, frame);
  105. _mav_put_float(buf, 30, x);
  106. _mav_put_float(buf, 34, y);
  107. _mav_put_float(buf, 38, z);
  108. _mav_put_uint8_t(buf, 58, type);
  109. _mav_put_uint8_t(buf, 59, position_valid);
  110. _mav_put_float_array(buf, 42, q, 4);
  111. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  112. #else
  113. mavlink_landing_target_t packet;
  114. packet.time_usec = time_usec;
  115. packet.angle_x = angle_x;
  116. packet.angle_y = angle_y;
  117. packet.distance = distance;
  118. packet.size_x = size_x;
  119. packet.size_y = size_y;
  120. packet.target_num = target_num;
  121. packet.frame = frame;
  122. packet.x = x;
  123. packet.y = y;
  124. packet.z = z;
  125. packet.type = type;
  126. packet.position_valid = position_valid;
  127. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
  131. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  132. }
  133. /**
  134. * @brief Pack a landing_target message
  135. * @param system_id ID of this system
  136. * @param component_id ID of this component (e.g. 200 for IMU)
  137. * @param status MAVLink status structure
  138. * @param msg The MAVLink message to compress the data into
  139. *
  140. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  141. * @param target_num The ID of the target if multiple targets are present
  142. * @param frame Coordinate frame used for following fields.
  143. * @param angle_x [rad] X-axis angular offset of the target from the center of the image
  144. * @param angle_y [rad] Y-axis angular offset of the target from the center of the image
  145. * @param distance [m] Distance to the target from the vehicle
  146. * @param size_x [rad] Size of target along x-axis
  147. * @param size_y [rad] Size of target along y-axis
  148. * @param x [m] X Position of the landing target in MAV_FRAME
  149. * @param y [m] Y Position of the landing target in MAV_FRAME
  150. * @param z [m] Z Position of the landing target in MAV_FRAME
  151. * @param q Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
  152. * @param type Type of landing target
  153. * @param position_valid Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).
  154. * @return length of the message in bytes (excluding serial stream start sign)
  155. */
  156. static inline uint16_t mavlink_msg_landing_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  157. uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y, float x, float y, float z, const float *q, uint8_t type, uint8_t position_valid)
  158. {
  159. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  160. char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
  161. _mav_put_uint64_t(buf, 0, time_usec);
  162. _mav_put_float(buf, 8, angle_x);
  163. _mav_put_float(buf, 12, angle_y);
  164. _mav_put_float(buf, 16, distance);
  165. _mav_put_float(buf, 20, size_x);
  166. _mav_put_float(buf, 24, size_y);
  167. _mav_put_uint8_t(buf, 28, target_num);
  168. _mav_put_uint8_t(buf, 29, frame);
  169. _mav_put_float(buf, 30, x);
  170. _mav_put_float(buf, 34, y);
  171. _mav_put_float(buf, 38, z);
  172. _mav_put_uint8_t(buf, 58, type);
  173. _mav_put_uint8_t(buf, 59, position_valid);
  174. _mav_put_float_array(buf, 42, q, 4);
  175. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  176. #else
  177. mavlink_landing_target_t packet;
  178. packet.time_usec = time_usec;
  179. packet.angle_x = angle_x;
  180. packet.angle_y = angle_y;
  181. packet.distance = distance;
  182. packet.size_x = size_x;
  183. packet.size_y = size_y;
  184. packet.target_num = target_num;
  185. packet.frame = frame;
  186. packet.x = x;
  187. packet.y = y;
  188. packet.z = z;
  189. packet.type = type;
  190. packet.position_valid = position_valid;
  191. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  192. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  193. #endif
  194. msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
  195. #if MAVLINK_CRC_EXTRA
  196. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  197. #else
  198. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  199. #endif
  200. }
  201. /**
  202. * @brief Pack a landing_target message on a channel
  203. * @param system_id ID of this system
  204. * @param component_id ID of this component (e.g. 200 for IMU)
  205. * @param chan The MAVLink channel this message will be sent over
  206. * @param msg The MAVLink message to compress the data into
  207. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  208. * @param target_num The ID of the target if multiple targets are present
  209. * @param frame Coordinate frame used for following fields.
  210. * @param angle_x [rad] X-axis angular offset of the target from the center of the image
  211. * @param angle_y [rad] Y-axis angular offset of the target from the center of the image
  212. * @param distance [m] Distance to the target from the vehicle
  213. * @param size_x [rad] Size of target along x-axis
  214. * @param size_y [rad] Size of target along y-axis
  215. * @param x [m] X Position of the landing target in MAV_FRAME
  216. * @param y [m] Y Position of the landing target in MAV_FRAME
  217. * @param z [m] Z Position of the landing target in MAV_FRAME
  218. * @param q Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
  219. * @param type Type of landing target
  220. * @param position_valid Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).
  221. * @return length of the message in bytes (excluding serial stream start sign)
  222. */
  223. static inline uint16_t mavlink_msg_landing_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  224. mavlink_message_t* msg,
  225. uint64_t time_usec,uint8_t target_num,uint8_t frame,float angle_x,float angle_y,float distance,float size_x,float size_y,float x,float y,float z,const float *q,uint8_t type,uint8_t position_valid)
  226. {
  227. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  228. char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
  229. _mav_put_uint64_t(buf, 0, time_usec);
  230. _mav_put_float(buf, 8, angle_x);
  231. _mav_put_float(buf, 12, angle_y);
  232. _mav_put_float(buf, 16, distance);
  233. _mav_put_float(buf, 20, size_x);
  234. _mav_put_float(buf, 24, size_y);
  235. _mav_put_uint8_t(buf, 28, target_num);
  236. _mav_put_uint8_t(buf, 29, frame);
  237. _mav_put_float(buf, 30, x);
  238. _mav_put_float(buf, 34, y);
  239. _mav_put_float(buf, 38, z);
  240. _mav_put_uint8_t(buf, 58, type);
  241. _mav_put_uint8_t(buf, 59, position_valid);
  242. _mav_put_float_array(buf, 42, q, 4);
  243. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  244. #else
  245. mavlink_landing_target_t packet;
  246. packet.time_usec = time_usec;
  247. packet.angle_x = angle_x;
  248. packet.angle_y = angle_y;
  249. packet.distance = distance;
  250. packet.size_x = size_x;
  251. packet.size_y = size_y;
  252. packet.target_num = target_num;
  253. packet.frame = frame;
  254. packet.x = x;
  255. packet.y = y;
  256. packet.z = z;
  257. packet.type = type;
  258. packet.position_valid = position_valid;
  259. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  260. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  261. #endif
  262. msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
  263. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  264. }
  265. /**
  266. * @brief Encode a landing_target struct
  267. *
  268. * @param system_id ID of this system
  269. * @param component_id ID of this component (e.g. 200 for IMU)
  270. * @param msg The MAVLink message to compress the data into
  271. * @param landing_target C-struct to read the message contents from
  272. */
  273. static inline uint16_t mavlink_msg_landing_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
  274. {
  275. return mavlink_msg_landing_target_pack(system_id, component_id, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid);
  276. }
  277. /**
  278. * @brief Encode a landing_target struct on a channel
  279. *
  280. * @param system_id ID of this system
  281. * @param component_id ID of this component (e.g. 200 for IMU)
  282. * @param chan The MAVLink channel this message will be sent over
  283. * @param msg The MAVLink message to compress the data into
  284. * @param landing_target C-struct to read the message contents from
  285. */
  286. static inline uint16_t mavlink_msg_landing_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
  287. {
  288. return mavlink_msg_landing_target_pack_chan(system_id, component_id, chan, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid);
  289. }
  290. /**
  291. * @brief Encode a landing_target struct with provided status structure
  292. *
  293. * @param system_id ID of this system
  294. * @param component_id ID of this component (e.g. 200 for IMU)
  295. * @param status MAVLink status structure
  296. * @param msg The MAVLink message to compress the data into
  297. * @param landing_target C-struct to read the message contents from
  298. */
  299. static inline uint16_t mavlink_msg_landing_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
  300. {
  301. return mavlink_msg_landing_target_pack_status(system_id, component_id, _status, msg, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid);
  302. }
  303. /**
  304. * @brief Send a landing_target message
  305. * @param chan MAVLink channel to send the message
  306. *
  307. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  308. * @param target_num The ID of the target if multiple targets are present
  309. * @param frame Coordinate frame used for following fields.
  310. * @param angle_x [rad] X-axis angular offset of the target from the center of the image
  311. * @param angle_y [rad] Y-axis angular offset of the target from the center of the image
  312. * @param distance [m] Distance to the target from the vehicle
  313. * @param size_x [rad] Size of target along x-axis
  314. * @param size_y [rad] Size of target along y-axis
  315. * @param x [m] X Position of the landing target in MAV_FRAME
  316. * @param y [m] Y Position of the landing target in MAV_FRAME
  317. * @param z [m] Z Position of the landing target in MAV_FRAME
  318. * @param q Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
  319. * @param type Type of landing target
  320. * @param position_valid Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).
  321. */
  322. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  323. static inline void mavlink_msg_landing_target_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y, float x, float y, float z, const float *q, uint8_t type, uint8_t position_valid)
  324. {
  325. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  326. char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
  327. _mav_put_uint64_t(buf, 0, time_usec);
  328. _mav_put_float(buf, 8, angle_x);
  329. _mav_put_float(buf, 12, angle_y);
  330. _mav_put_float(buf, 16, distance);
  331. _mav_put_float(buf, 20, size_x);
  332. _mav_put_float(buf, 24, size_y);
  333. _mav_put_uint8_t(buf, 28, target_num);
  334. _mav_put_uint8_t(buf, 29, frame);
  335. _mav_put_float(buf, 30, x);
  336. _mav_put_float(buf, 34, y);
  337. _mav_put_float(buf, 38, z);
  338. _mav_put_uint8_t(buf, 58, type);
  339. _mav_put_uint8_t(buf, 59, position_valid);
  340. _mav_put_float_array(buf, 42, q, 4);
  341. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  342. #else
  343. mavlink_landing_target_t packet;
  344. packet.time_usec = time_usec;
  345. packet.angle_x = angle_x;
  346. packet.angle_y = angle_y;
  347. packet.distance = distance;
  348. packet.size_x = size_x;
  349. packet.size_y = size_y;
  350. packet.target_num = target_num;
  351. packet.frame = frame;
  352. packet.x = x;
  353. packet.y = y;
  354. packet.z = z;
  355. packet.type = type;
  356. packet.position_valid = position_valid;
  357. mav_array_memcpy(packet.q, q, sizeof(float)*4);
  358. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)&packet, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  359. #endif
  360. }
  361. /**
  362. * @brief Send a landing_target message
  363. * @param chan MAVLink channel to send the message
  364. * @param struct The MAVLink struct to serialize
  365. */
  366. static inline void mavlink_msg_landing_target_send_struct(mavlink_channel_t chan, const mavlink_landing_target_t* landing_target)
  367. {
  368. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  369. mavlink_msg_landing_target_send(chan, landing_target->time_usec, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance, landing_target->size_x, landing_target->size_y, landing_target->x, landing_target->y, landing_target->z, landing_target->q, landing_target->type, landing_target->position_valid);
  370. #else
  371. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)landing_target, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  372. #endif
  373. }
  374. #if MAVLINK_MSG_ID_LANDING_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  375. /*
  376. This variant of _send() can be used to save stack space by re-using
  377. memory from the receive buffer. The caller provides a
  378. mavlink_message_t which is the size of a full mavlink message. This
  379. is usually the receive buffer for the channel, and allows a reply to an
  380. incoming message with minimum stack space usage.
  381. */
  382. static inline void mavlink_msg_landing_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance, float size_x, float size_y, float x, float y, float z, const float *q, uint8_t type, uint8_t position_valid)
  383. {
  384. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  385. char *buf = (char *)msgbuf;
  386. _mav_put_uint64_t(buf, 0, time_usec);
  387. _mav_put_float(buf, 8, angle_x);
  388. _mav_put_float(buf, 12, angle_y);
  389. _mav_put_float(buf, 16, distance);
  390. _mav_put_float(buf, 20, size_x);
  391. _mav_put_float(buf, 24, size_y);
  392. _mav_put_uint8_t(buf, 28, target_num);
  393. _mav_put_uint8_t(buf, 29, frame);
  394. _mav_put_float(buf, 30, x);
  395. _mav_put_float(buf, 34, y);
  396. _mav_put_float(buf, 38, z);
  397. _mav_put_uint8_t(buf, 58, type);
  398. _mav_put_uint8_t(buf, 59, position_valid);
  399. _mav_put_float_array(buf, 42, q, 4);
  400. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  401. #else
  402. mavlink_landing_target_t *packet = (mavlink_landing_target_t *)msgbuf;
  403. packet->time_usec = time_usec;
  404. packet->angle_x = angle_x;
  405. packet->angle_y = angle_y;
  406. packet->distance = distance;
  407. packet->size_x = size_x;
  408. packet->size_y = size_y;
  409. packet->target_num = target_num;
  410. packet->frame = frame;
  411. packet->x = x;
  412. packet->y = y;
  413. packet->z = z;
  414. packet->type = type;
  415. packet->position_valid = position_valid;
  416. mav_array_memcpy(packet->q, q, sizeof(float)*4);
  417. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)packet, MAVLINK_MSG_ID_LANDING_TARGET_MIN_LEN, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
  418. #endif
  419. }
  420. #endif
  421. #endif
  422. // MESSAGE LANDING_TARGET UNPACKING
  423. /**
  424. * @brief Get field time_usec from landing_target message
  425. *
  426. * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
  427. */
  428. static inline uint64_t mavlink_msg_landing_target_get_time_usec(const mavlink_message_t* msg)
  429. {
  430. return _MAV_RETURN_uint64_t(msg, 0);
  431. }
  432. /**
  433. * @brief Get field target_num from landing_target message
  434. *
  435. * @return The ID of the target if multiple targets are present
  436. */
  437. static inline uint8_t mavlink_msg_landing_target_get_target_num(const mavlink_message_t* msg)
  438. {
  439. return _MAV_RETURN_uint8_t(msg, 28);
  440. }
  441. /**
  442. * @brief Get field frame from landing_target message
  443. *
  444. * @return Coordinate frame used for following fields.
  445. */
  446. static inline uint8_t mavlink_msg_landing_target_get_frame(const mavlink_message_t* msg)
  447. {
  448. return _MAV_RETURN_uint8_t(msg, 29);
  449. }
  450. /**
  451. * @brief Get field angle_x from landing_target message
  452. *
  453. * @return [rad] X-axis angular offset of the target from the center of the image
  454. */
  455. static inline float mavlink_msg_landing_target_get_angle_x(const mavlink_message_t* msg)
  456. {
  457. return _MAV_RETURN_float(msg, 8);
  458. }
  459. /**
  460. * @brief Get field angle_y from landing_target message
  461. *
  462. * @return [rad] Y-axis angular offset of the target from the center of the image
  463. */
  464. static inline float mavlink_msg_landing_target_get_angle_y(const mavlink_message_t* msg)
  465. {
  466. return _MAV_RETURN_float(msg, 12);
  467. }
  468. /**
  469. * @brief Get field distance from landing_target message
  470. *
  471. * @return [m] Distance to the target from the vehicle
  472. */
  473. static inline float mavlink_msg_landing_target_get_distance(const mavlink_message_t* msg)
  474. {
  475. return _MAV_RETURN_float(msg, 16);
  476. }
  477. /**
  478. * @brief Get field size_x from landing_target message
  479. *
  480. * @return [rad] Size of target along x-axis
  481. */
  482. static inline float mavlink_msg_landing_target_get_size_x(const mavlink_message_t* msg)
  483. {
  484. return _MAV_RETURN_float(msg, 20);
  485. }
  486. /**
  487. * @brief Get field size_y from landing_target message
  488. *
  489. * @return [rad] Size of target along y-axis
  490. */
  491. static inline float mavlink_msg_landing_target_get_size_y(const mavlink_message_t* msg)
  492. {
  493. return _MAV_RETURN_float(msg, 24);
  494. }
  495. /**
  496. * @brief Get field x from landing_target message
  497. *
  498. * @return [m] X Position of the landing target in MAV_FRAME
  499. */
  500. static inline float mavlink_msg_landing_target_get_x(const mavlink_message_t* msg)
  501. {
  502. return _MAV_RETURN_float(msg, 30);
  503. }
  504. /**
  505. * @brief Get field y from landing_target message
  506. *
  507. * @return [m] Y Position of the landing target in MAV_FRAME
  508. */
  509. static inline float mavlink_msg_landing_target_get_y(const mavlink_message_t* msg)
  510. {
  511. return _MAV_RETURN_float(msg, 34);
  512. }
  513. /**
  514. * @brief Get field z from landing_target message
  515. *
  516. * @return [m] Z Position of the landing target in MAV_FRAME
  517. */
  518. static inline float mavlink_msg_landing_target_get_z(const mavlink_message_t* msg)
  519. {
  520. return _MAV_RETURN_float(msg, 38);
  521. }
  522. /**
  523. * @brief Get field q from landing_target message
  524. *
  525. * @return Quaternion of landing target orientation (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
  526. */
  527. static inline uint16_t mavlink_msg_landing_target_get_q(const mavlink_message_t* msg, float *q)
  528. {
  529. return _MAV_RETURN_float_array(msg, q, 4, 42);
  530. }
  531. /**
  532. * @brief Get field type from landing_target message
  533. *
  534. * @return Type of landing target
  535. */
  536. static inline uint8_t mavlink_msg_landing_target_get_type(const mavlink_message_t* msg)
  537. {
  538. return _MAV_RETURN_uint8_t(msg, 58);
  539. }
  540. /**
  541. * @brief Get field position_valid from landing_target message
  542. *
  543. * @return Boolean indicating whether the position fields (x, y, z, q, type) contain valid target position information (valid: 1, invalid: 0). Default is 0 (invalid).
  544. */
  545. static inline uint8_t mavlink_msg_landing_target_get_position_valid(const mavlink_message_t* msg)
  546. {
  547. return _MAV_RETURN_uint8_t(msg, 59);
  548. }
  549. /**
  550. * @brief Decode a landing_target message into a struct
  551. *
  552. * @param msg The message to decode
  553. * @param landing_target C-struct to decode the message contents into
  554. */
  555. static inline void mavlink_msg_landing_target_decode(const mavlink_message_t* msg, mavlink_landing_target_t* landing_target)
  556. {
  557. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  558. landing_target->time_usec = mavlink_msg_landing_target_get_time_usec(msg);
  559. landing_target->angle_x = mavlink_msg_landing_target_get_angle_x(msg);
  560. landing_target->angle_y = mavlink_msg_landing_target_get_angle_y(msg);
  561. landing_target->distance = mavlink_msg_landing_target_get_distance(msg);
  562. landing_target->size_x = mavlink_msg_landing_target_get_size_x(msg);
  563. landing_target->size_y = mavlink_msg_landing_target_get_size_y(msg);
  564. landing_target->target_num = mavlink_msg_landing_target_get_target_num(msg);
  565. landing_target->frame = mavlink_msg_landing_target_get_frame(msg);
  566. landing_target->x = mavlink_msg_landing_target_get_x(msg);
  567. landing_target->y = mavlink_msg_landing_target_get_y(msg);
  568. landing_target->z = mavlink_msg_landing_target_get_z(msg);
  569. mavlink_msg_landing_target_get_q(msg, landing_target->q);
  570. landing_target->type = mavlink_msg_landing_target_get_type(msg);
  571. landing_target->position_valid = mavlink_msg_landing_target_get_position_valid(msg);
  572. #else
  573. uint8_t len = msg->len < MAVLINK_MSG_ID_LANDING_TARGET_LEN? msg->len : MAVLINK_MSG_ID_LANDING_TARGET_LEN;
  574. memset(landing_target, 0, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
  575. memcpy(landing_target, _MAV_PAYLOAD(msg), len);
  576. #endif
  577. }