mavlink_msg_follow_target.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. #pragma once
  2. // MESSAGE FOLLOW_TARGET PACKING
  3. #define MAVLINK_MSG_ID_FOLLOW_TARGET 144
  4. typedef struct __mavlink_follow_target_t {
  5. uint64_t timestamp; /*< [ms] Timestamp (time since system boot).*/
  6. uint64_t custom_state; /*< button states or switches of a tracker device*/
  7. int32_t lat; /*< [degE7] Latitude (WGS84)*/
  8. int32_t lon; /*< [degE7] Longitude (WGS84)*/
  9. float alt; /*< [m] Altitude (MSL)*/
  10. float vel[3]; /*< [m/s] target velocity (0,0,0) for unknown*/
  11. float acc[3]; /*< [m/s/s] linear target acceleration (0,0,0) for unknown*/
  12. float attitude_q[4]; /*< (0 0 0 0 for unknown)*/
  13. float rates[3]; /*< (0 0 0 for unknown)*/
  14. float position_cov[3]; /*< eph epv*/
  15. uint8_t est_capabilities; /*< bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)*/
  16. } mavlink_follow_target_t;
  17. #define MAVLINK_MSG_ID_FOLLOW_TARGET_LEN 93
  18. #define MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN 93
  19. #define MAVLINK_MSG_ID_144_LEN 93
  20. #define MAVLINK_MSG_ID_144_MIN_LEN 93
  21. #define MAVLINK_MSG_ID_FOLLOW_TARGET_CRC 127
  22. #define MAVLINK_MSG_ID_144_CRC 127
  23. #define MAVLINK_MSG_FOLLOW_TARGET_FIELD_VEL_LEN 3
  24. #define MAVLINK_MSG_FOLLOW_TARGET_FIELD_ACC_LEN 3
  25. #define MAVLINK_MSG_FOLLOW_TARGET_FIELD_ATTITUDE_Q_LEN 4
  26. #define MAVLINK_MSG_FOLLOW_TARGET_FIELD_RATES_LEN 3
  27. #define MAVLINK_MSG_FOLLOW_TARGET_FIELD_POSITION_COV_LEN 3
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_FOLLOW_TARGET { \
  30. 144, \
  31. "FOLLOW_TARGET", \
  32. 11, \
  33. { { "timestamp", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_follow_target_t, timestamp) }, \
  34. { "est_capabilities", NULL, MAVLINK_TYPE_UINT8_T, 0, 92, offsetof(mavlink_follow_target_t, est_capabilities) }, \
  35. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_follow_target_t, lat) }, \
  36. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_follow_target_t, lon) }, \
  37. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_follow_target_t, alt) }, \
  38. { "vel", NULL, MAVLINK_TYPE_FLOAT, 3, 28, offsetof(mavlink_follow_target_t, vel) }, \
  39. { "acc", NULL, MAVLINK_TYPE_FLOAT, 3, 40, offsetof(mavlink_follow_target_t, acc) }, \
  40. { "attitude_q", NULL, MAVLINK_TYPE_FLOAT, 4, 52, offsetof(mavlink_follow_target_t, attitude_q) }, \
  41. { "rates", NULL, MAVLINK_TYPE_FLOAT, 3, 68, offsetof(mavlink_follow_target_t, rates) }, \
  42. { "position_cov", NULL, MAVLINK_TYPE_FLOAT, 3, 80, offsetof(mavlink_follow_target_t, position_cov) }, \
  43. { "custom_state", NULL, MAVLINK_TYPE_UINT64_T, 0, 8, offsetof(mavlink_follow_target_t, custom_state) }, \
  44. } \
  45. }
  46. #else
  47. #define MAVLINK_MESSAGE_INFO_FOLLOW_TARGET { \
  48. "FOLLOW_TARGET", \
  49. 11, \
  50. { { "timestamp", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_follow_target_t, timestamp) }, \
  51. { "est_capabilities", NULL, MAVLINK_TYPE_UINT8_T, 0, 92, offsetof(mavlink_follow_target_t, est_capabilities) }, \
  52. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_follow_target_t, lat) }, \
  53. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_follow_target_t, lon) }, \
  54. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_follow_target_t, alt) }, \
  55. { "vel", NULL, MAVLINK_TYPE_FLOAT, 3, 28, offsetof(mavlink_follow_target_t, vel) }, \
  56. { "acc", NULL, MAVLINK_TYPE_FLOAT, 3, 40, offsetof(mavlink_follow_target_t, acc) }, \
  57. { "attitude_q", NULL, MAVLINK_TYPE_FLOAT, 4, 52, offsetof(mavlink_follow_target_t, attitude_q) }, \
  58. { "rates", NULL, MAVLINK_TYPE_FLOAT, 3, 68, offsetof(mavlink_follow_target_t, rates) }, \
  59. { "position_cov", NULL, MAVLINK_TYPE_FLOAT, 3, 80, offsetof(mavlink_follow_target_t, position_cov) }, \
  60. { "custom_state", NULL, MAVLINK_TYPE_UINT64_T, 0, 8, offsetof(mavlink_follow_target_t, custom_state) }, \
  61. } \
  62. }
  63. #endif
  64. /**
  65. * @brief Pack a follow_target message
  66. * @param system_id ID of this system
  67. * @param component_id ID of this component (e.g. 200 for IMU)
  68. * @param msg The MAVLink message to compress the data into
  69. *
  70. * @param timestamp [ms] Timestamp (time since system boot).
  71. * @param est_capabilities bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)
  72. * @param lat [degE7] Latitude (WGS84)
  73. * @param lon [degE7] Longitude (WGS84)
  74. * @param alt [m] Altitude (MSL)
  75. * @param vel [m/s] target velocity (0,0,0) for unknown
  76. * @param acc [m/s/s] linear target acceleration (0,0,0) for unknown
  77. * @param attitude_q (0 0 0 0 for unknown)
  78. * @param rates (0 0 0 for unknown)
  79. * @param position_cov eph epv
  80. * @param custom_state button states or switches of a tracker device
  81. * @return length of the message in bytes (excluding serial stream start sign)
  82. */
  83. static inline uint16_t mavlink_msg_follow_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  84. uint64_t timestamp, uint8_t est_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *attitude_q, const float *rates, const float *position_cov, uint64_t custom_state)
  85. {
  86. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  87. char buf[MAVLINK_MSG_ID_FOLLOW_TARGET_LEN];
  88. _mav_put_uint64_t(buf, 0, timestamp);
  89. _mav_put_uint64_t(buf, 8, custom_state);
  90. _mav_put_int32_t(buf, 16, lat);
  91. _mav_put_int32_t(buf, 20, lon);
  92. _mav_put_float(buf, 24, alt);
  93. _mav_put_uint8_t(buf, 92, est_capabilities);
  94. _mav_put_float_array(buf, 28, vel, 3);
  95. _mav_put_float_array(buf, 40, acc, 3);
  96. _mav_put_float_array(buf, 52, attitude_q, 4);
  97. _mav_put_float_array(buf, 68, rates, 3);
  98. _mav_put_float_array(buf, 80, position_cov, 3);
  99. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  100. #else
  101. mavlink_follow_target_t packet;
  102. packet.timestamp = timestamp;
  103. packet.custom_state = custom_state;
  104. packet.lat = lat;
  105. packet.lon = lon;
  106. packet.alt = alt;
  107. packet.est_capabilities = est_capabilities;
  108. mav_array_memcpy(packet.vel, vel, sizeof(float)*3);
  109. mav_array_memcpy(packet.acc, acc, sizeof(float)*3);
  110. mav_array_memcpy(packet.attitude_q, attitude_q, sizeof(float)*4);
  111. mav_array_memcpy(packet.rates, rates, sizeof(float)*3);
  112. mav_array_memcpy(packet.position_cov, position_cov, sizeof(float)*3);
  113. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  114. #endif
  115. msg->msgid = MAVLINK_MSG_ID_FOLLOW_TARGET;
  116. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  117. }
  118. /**
  119. * @brief Pack a follow_target message
  120. * @param system_id ID of this system
  121. * @param component_id ID of this component (e.g. 200 for IMU)
  122. * @param status MAVLink status structure
  123. * @param msg The MAVLink message to compress the data into
  124. *
  125. * @param timestamp [ms] Timestamp (time since system boot).
  126. * @param est_capabilities bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)
  127. * @param lat [degE7] Latitude (WGS84)
  128. * @param lon [degE7] Longitude (WGS84)
  129. * @param alt [m] Altitude (MSL)
  130. * @param vel [m/s] target velocity (0,0,0) for unknown
  131. * @param acc [m/s/s] linear target acceleration (0,0,0) for unknown
  132. * @param attitude_q (0 0 0 0 for unknown)
  133. * @param rates (0 0 0 for unknown)
  134. * @param position_cov eph epv
  135. * @param custom_state button states or switches of a tracker device
  136. * @return length of the message in bytes (excluding serial stream start sign)
  137. */
  138. static inline uint16_t mavlink_msg_follow_target_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  139. uint64_t timestamp, uint8_t est_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *attitude_q, const float *rates, const float *position_cov, uint64_t custom_state)
  140. {
  141. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  142. char buf[MAVLINK_MSG_ID_FOLLOW_TARGET_LEN];
  143. _mav_put_uint64_t(buf, 0, timestamp);
  144. _mav_put_uint64_t(buf, 8, custom_state);
  145. _mav_put_int32_t(buf, 16, lat);
  146. _mav_put_int32_t(buf, 20, lon);
  147. _mav_put_float(buf, 24, alt);
  148. _mav_put_uint8_t(buf, 92, est_capabilities);
  149. _mav_put_float_array(buf, 28, vel, 3);
  150. _mav_put_float_array(buf, 40, acc, 3);
  151. _mav_put_float_array(buf, 52, attitude_q, 4);
  152. _mav_put_float_array(buf, 68, rates, 3);
  153. _mav_put_float_array(buf, 80, position_cov, 3);
  154. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  155. #else
  156. mavlink_follow_target_t packet;
  157. packet.timestamp = timestamp;
  158. packet.custom_state = custom_state;
  159. packet.lat = lat;
  160. packet.lon = lon;
  161. packet.alt = alt;
  162. packet.est_capabilities = est_capabilities;
  163. mav_array_memcpy(packet.vel, vel, sizeof(float)*3);
  164. mav_array_memcpy(packet.acc, acc, sizeof(float)*3);
  165. mav_array_memcpy(packet.attitude_q, attitude_q, sizeof(float)*4);
  166. mav_array_memcpy(packet.rates, rates, sizeof(float)*3);
  167. mav_array_memcpy(packet.position_cov, position_cov, sizeof(float)*3);
  168. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  169. #endif
  170. msg->msgid = MAVLINK_MSG_ID_FOLLOW_TARGET;
  171. #if MAVLINK_CRC_EXTRA
  172. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  173. #else
  174. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  175. #endif
  176. }
  177. /**
  178. * @brief Pack a follow_target message on a channel
  179. * @param system_id ID of this system
  180. * @param component_id ID of this component (e.g. 200 for IMU)
  181. * @param chan The MAVLink channel this message will be sent over
  182. * @param msg The MAVLink message to compress the data into
  183. * @param timestamp [ms] Timestamp (time since system boot).
  184. * @param est_capabilities bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)
  185. * @param lat [degE7] Latitude (WGS84)
  186. * @param lon [degE7] Longitude (WGS84)
  187. * @param alt [m] Altitude (MSL)
  188. * @param vel [m/s] target velocity (0,0,0) for unknown
  189. * @param acc [m/s/s] linear target acceleration (0,0,0) for unknown
  190. * @param attitude_q (0 0 0 0 for unknown)
  191. * @param rates (0 0 0 for unknown)
  192. * @param position_cov eph epv
  193. * @param custom_state button states or switches of a tracker device
  194. * @return length of the message in bytes (excluding serial stream start sign)
  195. */
  196. static inline uint16_t mavlink_msg_follow_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  197. mavlink_message_t* msg,
  198. uint64_t timestamp,uint8_t est_capabilities,int32_t lat,int32_t lon,float alt,const float *vel,const float *acc,const float *attitude_q,const float *rates,const float *position_cov,uint64_t custom_state)
  199. {
  200. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  201. char buf[MAVLINK_MSG_ID_FOLLOW_TARGET_LEN];
  202. _mav_put_uint64_t(buf, 0, timestamp);
  203. _mav_put_uint64_t(buf, 8, custom_state);
  204. _mav_put_int32_t(buf, 16, lat);
  205. _mav_put_int32_t(buf, 20, lon);
  206. _mav_put_float(buf, 24, alt);
  207. _mav_put_uint8_t(buf, 92, est_capabilities);
  208. _mav_put_float_array(buf, 28, vel, 3);
  209. _mav_put_float_array(buf, 40, acc, 3);
  210. _mav_put_float_array(buf, 52, attitude_q, 4);
  211. _mav_put_float_array(buf, 68, rates, 3);
  212. _mav_put_float_array(buf, 80, position_cov, 3);
  213. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  214. #else
  215. mavlink_follow_target_t packet;
  216. packet.timestamp = timestamp;
  217. packet.custom_state = custom_state;
  218. packet.lat = lat;
  219. packet.lon = lon;
  220. packet.alt = alt;
  221. packet.est_capabilities = est_capabilities;
  222. mav_array_memcpy(packet.vel, vel, sizeof(float)*3);
  223. mav_array_memcpy(packet.acc, acc, sizeof(float)*3);
  224. mav_array_memcpy(packet.attitude_q, attitude_q, sizeof(float)*4);
  225. mav_array_memcpy(packet.rates, rates, sizeof(float)*3);
  226. mav_array_memcpy(packet.position_cov, position_cov, sizeof(float)*3);
  227. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  228. #endif
  229. msg->msgid = MAVLINK_MSG_ID_FOLLOW_TARGET;
  230. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  231. }
  232. /**
  233. * @brief Encode a follow_target struct
  234. *
  235. * @param system_id ID of this system
  236. * @param component_id ID of this component (e.g. 200 for IMU)
  237. * @param msg The MAVLink message to compress the data into
  238. * @param follow_target C-struct to read the message contents from
  239. */
  240. static inline uint16_t mavlink_msg_follow_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_follow_target_t* follow_target)
  241. {
  242. return mavlink_msg_follow_target_pack(system_id, component_id, msg, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state);
  243. }
  244. /**
  245. * @brief Encode a follow_target struct on a channel
  246. *
  247. * @param system_id ID of this system
  248. * @param component_id ID of this component (e.g. 200 for IMU)
  249. * @param chan The MAVLink channel this message will be sent over
  250. * @param msg The MAVLink message to compress the data into
  251. * @param follow_target C-struct to read the message contents from
  252. */
  253. static inline uint16_t mavlink_msg_follow_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_follow_target_t* follow_target)
  254. {
  255. return mavlink_msg_follow_target_pack_chan(system_id, component_id, chan, msg, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state);
  256. }
  257. /**
  258. * @brief Encode a follow_target struct with provided status structure
  259. *
  260. * @param system_id ID of this system
  261. * @param component_id ID of this component (e.g. 200 for IMU)
  262. * @param status MAVLink status structure
  263. * @param msg The MAVLink message to compress the data into
  264. * @param follow_target C-struct to read the message contents from
  265. */
  266. static inline uint16_t mavlink_msg_follow_target_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_follow_target_t* follow_target)
  267. {
  268. return mavlink_msg_follow_target_pack_status(system_id, component_id, _status, msg, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state);
  269. }
  270. /**
  271. * @brief Send a follow_target message
  272. * @param chan MAVLink channel to send the message
  273. *
  274. * @param timestamp [ms] Timestamp (time since system boot).
  275. * @param est_capabilities bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)
  276. * @param lat [degE7] Latitude (WGS84)
  277. * @param lon [degE7] Longitude (WGS84)
  278. * @param alt [m] Altitude (MSL)
  279. * @param vel [m/s] target velocity (0,0,0) for unknown
  280. * @param acc [m/s/s] linear target acceleration (0,0,0) for unknown
  281. * @param attitude_q (0 0 0 0 for unknown)
  282. * @param rates (0 0 0 for unknown)
  283. * @param position_cov eph epv
  284. * @param custom_state button states or switches of a tracker device
  285. */
  286. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  287. static inline void mavlink_msg_follow_target_send(mavlink_channel_t chan, uint64_t timestamp, uint8_t est_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *attitude_q, const float *rates, const float *position_cov, uint64_t custom_state)
  288. {
  289. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  290. char buf[MAVLINK_MSG_ID_FOLLOW_TARGET_LEN];
  291. _mav_put_uint64_t(buf, 0, timestamp);
  292. _mav_put_uint64_t(buf, 8, custom_state);
  293. _mav_put_int32_t(buf, 16, lat);
  294. _mav_put_int32_t(buf, 20, lon);
  295. _mav_put_float(buf, 24, alt);
  296. _mav_put_uint8_t(buf, 92, est_capabilities);
  297. _mav_put_float_array(buf, 28, vel, 3);
  298. _mav_put_float_array(buf, 40, acc, 3);
  299. _mav_put_float_array(buf, 52, attitude_q, 4);
  300. _mav_put_float_array(buf, 68, rates, 3);
  301. _mav_put_float_array(buf, 80, position_cov, 3);
  302. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FOLLOW_TARGET, buf, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  303. #else
  304. mavlink_follow_target_t packet;
  305. packet.timestamp = timestamp;
  306. packet.custom_state = custom_state;
  307. packet.lat = lat;
  308. packet.lon = lon;
  309. packet.alt = alt;
  310. packet.est_capabilities = est_capabilities;
  311. mav_array_memcpy(packet.vel, vel, sizeof(float)*3);
  312. mav_array_memcpy(packet.acc, acc, sizeof(float)*3);
  313. mav_array_memcpy(packet.attitude_q, attitude_q, sizeof(float)*4);
  314. mav_array_memcpy(packet.rates, rates, sizeof(float)*3);
  315. mav_array_memcpy(packet.position_cov, position_cov, sizeof(float)*3);
  316. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FOLLOW_TARGET, (const char *)&packet, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  317. #endif
  318. }
  319. /**
  320. * @brief Send a follow_target message
  321. * @param chan MAVLink channel to send the message
  322. * @param struct The MAVLink struct to serialize
  323. */
  324. static inline void mavlink_msg_follow_target_send_struct(mavlink_channel_t chan, const mavlink_follow_target_t* follow_target)
  325. {
  326. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  327. mavlink_msg_follow_target_send(chan, follow_target->timestamp, follow_target->est_capabilities, follow_target->lat, follow_target->lon, follow_target->alt, follow_target->vel, follow_target->acc, follow_target->attitude_q, follow_target->rates, follow_target->position_cov, follow_target->custom_state);
  328. #else
  329. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FOLLOW_TARGET, (const char *)follow_target, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  330. #endif
  331. }
  332. #if MAVLINK_MSG_ID_FOLLOW_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  333. /*
  334. This variant of _send() can be used to save stack space by re-using
  335. memory from the receive buffer. The caller provides a
  336. mavlink_message_t which is the size of a full mavlink message. This
  337. is usually the receive buffer for the channel, and allows a reply to an
  338. incoming message with minimum stack space usage.
  339. */
  340. static inline void mavlink_msg_follow_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t timestamp, uint8_t est_capabilities, int32_t lat, int32_t lon, float alt, const float *vel, const float *acc, const float *attitude_q, const float *rates, const float *position_cov, uint64_t custom_state)
  341. {
  342. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  343. char *buf = (char *)msgbuf;
  344. _mav_put_uint64_t(buf, 0, timestamp);
  345. _mav_put_uint64_t(buf, 8, custom_state);
  346. _mav_put_int32_t(buf, 16, lat);
  347. _mav_put_int32_t(buf, 20, lon);
  348. _mav_put_float(buf, 24, alt);
  349. _mav_put_uint8_t(buf, 92, est_capabilities);
  350. _mav_put_float_array(buf, 28, vel, 3);
  351. _mav_put_float_array(buf, 40, acc, 3);
  352. _mav_put_float_array(buf, 52, attitude_q, 4);
  353. _mav_put_float_array(buf, 68, rates, 3);
  354. _mav_put_float_array(buf, 80, position_cov, 3);
  355. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FOLLOW_TARGET, buf, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  356. #else
  357. mavlink_follow_target_t *packet = (mavlink_follow_target_t *)msgbuf;
  358. packet->timestamp = timestamp;
  359. packet->custom_state = custom_state;
  360. packet->lat = lat;
  361. packet->lon = lon;
  362. packet->alt = alt;
  363. packet->est_capabilities = est_capabilities;
  364. mav_array_memcpy(packet->vel, vel, sizeof(float)*3);
  365. mav_array_memcpy(packet->acc, acc, sizeof(float)*3);
  366. mav_array_memcpy(packet->attitude_q, attitude_q, sizeof(float)*4);
  367. mav_array_memcpy(packet->rates, rates, sizeof(float)*3);
  368. mav_array_memcpy(packet->position_cov, position_cov, sizeof(float)*3);
  369. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FOLLOW_TARGET, (const char *)packet, MAVLINK_MSG_ID_FOLLOW_TARGET_MIN_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN, MAVLINK_MSG_ID_FOLLOW_TARGET_CRC);
  370. #endif
  371. }
  372. #endif
  373. #endif
  374. // MESSAGE FOLLOW_TARGET UNPACKING
  375. /**
  376. * @brief Get field timestamp from follow_target message
  377. *
  378. * @return [ms] Timestamp (time since system boot).
  379. */
  380. static inline uint64_t mavlink_msg_follow_target_get_timestamp(const mavlink_message_t* msg)
  381. {
  382. return _MAV_RETURN_uint64_t(msg, 0);
  383. }
  384. /**
  385. * @brief Get field est_capabilities from follow_target message
  386. *
  387. * @return bit positions for tracker reporting capabilities (POS = 0, VEL = 1, ACCEL = 2, ATT + RATES = 3)
  388. */
  389. static inline uint8_t mavlink_msg_follow_target_get_est_capabilities(const mavlink_message_t* msg)
  390. {
  391. return _MAV_RETURN_uint8_t(msg, 92);
  392. }
  393. /**
  394. * @brief Get field lat from follow_target message
  395. *
  396. * @return [degE7] Latitude (WGS84)
  397. */
  398. static inline int32_t mavlink_msg_follow_target_get_lat(const mavlink_message_t* msg)
  399. {
  400. return _MAV_RETURN_int32_t(msg, 16);
  401. }
  402. /**
  403. * @brief Get field lon from follow_target message
  404. *
  405. * @return [degE7] Longitude (WGS84)
  406. */
  407. static inline int32_t mavlink_msg_follow_target_get_lon(const mavlink_message_t* msg)
  408. {
  409. return _MAV_RETURN_int32_t(msg, 20);
  410. }
  411. /**
  412. * @brief Get field alt from follow_target message
  413. *
  414. * @return [m] Altitude (MSL)
  415. */
  416. static inline float mavlink_msg_follow_target_get_alt(const mavlink_message_t* msg)
  417. {
  418. return _MAV_RETURN_float(msg, 24);
  419. }
  420. /**
  421. * @brief Get field vel from follow_target message
  422. *
  423. * @return [m/s] target velocity (0,0,0) for unknown
  424. */
  425. static inline uint16_t mavlink_msg_follow_target_get_vel(const mavlink_message_t* msg, float *vel)
  426. {
  427. return _MAV_RETURN_float_array(msg, vel, 3, 28);
  428. }
  429. /**
  430. * @brief Get field acc from follow_target message
  431. *
  432. * @return [m/s/s] linear target acceleration (0,0,0) for unknown
  433. */
  434. static inline uint16_t mavlink_msg_follow_target_get_acc(const mavlink_message_t* msg, float *acc)
  435. {
  436. return _MAV_RETURN_float_array(msg, acc, 3, 40);
  437. }
  438. /**
  439. * @brief Get field attitude_q from follow_target message
  440. *
  441. * @return (0 0 0 0 for unknown)
  442. */
  443. static inline uint16_t mavlink_msg_follow_target_get_attitude_q(const mavlink_message_t* msg, float *attitude_q)
  444. {
  445. return _MAV_RETURN_float_array(msg, attitude_q, 4, 52);
  446. }
  447. /**
  448. * @brief Get field rates from follow_target message
  449. *
  450. * @return (0 0 0 for unknown)
  451. */
  452. static inline uint16_t mavlink_msg_follow_target_get_rates(const mavlink_message_t* msg, float *rates)
  453. {
  454. return _MAV_RETURN_float_array(msg, rates, 3, 68);
  455. }
  456. /**
  457. * @brief Get field position_cov from follow_target message
  458. *
  459. * @return eph epv
  460. */
  461. static inline uint16_t mavlink_msg_follow_target_get_position_cov(const mavlink_message_t* msg, float *position_cov)
  462. {
  463. return _MAV_RETURN_float_array(msg, position_cov, 3, 80);
  464. }
  465. /**
  466. * @brief Get field custom_state from follow_target message
  467. *
  468. * @return button states or switches of a tracker device
  469. */
  470. static inline uint64_t mavlink_msg_follow_target_get_custom_state(const mavlink_message_t* msg)
  471. {
  472. return _MAV_RETURN_uint64_t(msg, 8);
  473. }
  474. /**
  475. * @brief Decode a follow_target message into a struct
  476. *
  477. * @param msg The message to decode
  478. * @param follow_target C-struct to decode the message contents into
  479. */
  480. static inline void mavlink_msg_follow_target_decode(const mavlink_message_t* msg, mavlink_follow_target_t* follow_target)
  481. {
  482. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  483. follow_target->timestamp = mavlink_msg_follow_target_get_timestamp(msg);
  484. follow_target->custom_state = mavlink_msg_follow_target_get_custom_state(msg);
  485. follow_target->lat = mavlink_msg_follow_target_get_lat(msg);
  486. follow_target->lon = mavlink_msg_follow_target_get_lon(msg);
  487. follow_target->alt = mavlink_msg_follow_target_get_alt(msg);
  488. mavlink_msg_follow_target_get_vel(msg, follow_target->vel);
  489. mavlink_msg_follow_target_get_acc(msg, follow_target->acc);
  490. mavlink_msg_follow_target_get_attitude_q(msg, follow_target->attitude_q);
  491. mavlink_msg_follow_target_get_rates(msg, follow_target->rates);
  492. mavlink_msg_follow_target_get_position_cov(msg, follow_target->position_cov);
  493. follow_target->est_capabilities = mavlink_msg_follow_target_get_est_capabilities(msg);
  494. #else
  495. uint8_t len = msg->len < MAVLINK_MSG_ID_FOLLOW_TARGET_LEN? msg->len : MAVLINK_MSG_ID_FOLLOW_TARGET_LEN;
  496. memset(follow_target, 0, MAVLINK_MSG_ID_FOLLOW_TARGET_LEN);
  497. memcpy(follow_target, _MAV_PAYLOAD(msg), len);
  498. #endif
  499. }