mavlink_msg_utm_global_position.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #pragma once
  2. // MESSAGE UTM_GLOBAL_POSITION PACKING
  3. #define MAVLINK_MSG_ID_UTM_GLOBAL_POSITION 340
  4. typedef struct __mavlink_utm_global_position_t {
  5. uint64_t time; /*< [us] Time of applicability of position (microseconds since UNIX epoch).*/
  6. int32_t lat; /*< [degE7] Latitude (WGS84)*/
  7. int32_t lon; /*< [degE7] Longitude (WGS84)*/
  8. int32_t alt; /*< [mm] Altitude (WGS84)*/
  9. int32_t relative_alt; /*< [mm] Altitude above ground*/
  10. int32_t next_lat; /*< [degE7] Next waypoint, latitude (WGS84)*/
  11. int32_t next_lon; /*< [degE7] Next waypoint, longitude (WGS84)*/
  12. int32_t next_alt; /*< [mm] Next waypoint, altitude (WGS84)*/
  13. int16_t vx; /*< [cm/s] Ground X speed (latitude, positive north)*/
  14. int16_t vy; /*< [cm/s] Ground Y speed (longitude, positive east)*/
  15. int16_t vz; /*< [cm/s] Ground Z speed (altitude, positive down)*/
  16. uint16_t h_acc; /*< [mm] Horizontal position uncertainty (standard deviation)*/
  17. uint16_t v_acc; /*< [mm] Altitude uncertainty (standard deviation)*/
  18. uint16_t vel_acc; /*< [cm/s] Speed uncertainty (standard deviation)*/
  19. uint16_t update_rate; /*< [cs] Time until next update. Set to 0 if unknown or in data driven mode.*/
  20. uint8_t uas_id[18]; /*< Unique UAS ID.*/
  21. uint8_t flight_state; /*< Flight state*/
  22. uint8_t flags; /*< Bitwise OR combination of the data available flags.*/
  23. } mavlink_utm_global_position_t;
  24. #define MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN 70
  25. #define MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN 70
  26. #define MAVLINK_MSG_ID_340_LEN 70
  27. #define MAVLINK_MSG_ID_340_MIN_LEN 70
  28. #define MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC 99
  29. #define MAVLINK_MSG_ID_340_CRC 99
  30. #define MAVLINK_MSG_UTM_GLOBAL_POSITION_FIELD_UAS_ID_LEN 18
  31. #if MAVLINK_COMMAND_24BIT
  32. #define MAVLINK_MESSAGE_INFO_UTM_GLOBAL_POSITION { \
  33. 340, \
  34. "UTM_GLOBAL_POSITION", \
  35. 18, \
  36. { { "time", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_utm_global_position_t, time) }, \
  37. { "uas_id", NULL, MAVLINK_TYPE_UINT8_T, 18, 50, offsetof(mavlink_utm_global_position_t, uas_id) }, \
  38. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_utm_global_position_t, lat) }, \
  39. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_utm_global_position_t, lon) }, \
  40. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_utm_global_position_t, alt) }, \
  41. { "relative_alt", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_utm_global_position_t, relative_alt) }, \
  42. { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 36, offsetof(mavlink_utm_global_position_t, vx) }, \
  43. { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_utm_global_position_t, vy) }, \
  44. { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_utm_global_position_t, vz) }, \
  45. { "h_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 42, offsetof(mavlink_utm_global_position_t, h_acc) }, \
  46. { "v_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 44, offsetof(mavlink_utm_global_position_t, v_acc) }, \
  47. { "vel_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 46, offsetof(mavlink_utm_global_position_t, vel_acc) }, \
  48. { "next_lat", NULL, MAVLINK_TYPE_INT32_T, 0, 24, offsetof(mavlink_utm_global_position_t, next_lat) }, \
  49. { "next_lon", NULL, MAVLINK_TYPE_INT32_T, 0, 28, offsetof(mavlink_utm_global_position_t, next_lon) }, \
  50. { "next_alt", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_utm_global_position_t, next_alt) }, \
  51. { "update_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 48, offsetof(mavlink_utm_global_position_t, update_rate) }, \
  52. { "flight_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 68, offsetof(mavlink_utm_global_position_t, flight_state) }, \
  53. { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 69, offsetof(mavlink_utm_global_position_t, flags) }, \
  54. } \
  55. }
  56. #else
  57. #define MAVLINK_MESSAGE_INFO_UTM_GLOBAL_POSITION { \
  58. "UTM_GLOBAL_POSITION", \
  59. 18, \
  60. { { "time", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_utm_global_position_t, time) }, \
  61. { "uas_id", NULL, MAVLINK_TYPE_UINT8_T, 18, 50, offsetof(mavlink_utm_global_position_t, uas_id) }, \
  62. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_utm_global_position_t, lat) }, \
  63. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_utm_global_position_t, lon) }, \
  64. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_utm_global_position_t, alt) }, \
  65. { "relative_alt", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_utm_global_position_t, relative_alt) }, \
  66. { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 36, offsetof(mavlink_utm_global_position_t, vx) }, \
  67. { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 38, offsetof(mavlink_utm_global_position_t, vy) }, \
  68. { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 40, offsetof(mavlink_utm_global_position_t, vz) }, \
  69. { "h_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 42, offsetof(mavlink_utm_global_position_t, h_acc) }, \
  70. { "v_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 44, offsetof(mavlink_utm_global_position_t, v_acc) }, \
  71. { "vel_acc", NULL, MAVLINK_TYPE_UINT16_T, 0, 46, offsetof(mavlink_utm_global_position_t, vel_acc) }, \
  72. { "next_lat", NULL, MAVLINK_TYPE_INT32_T, 0, 24, offsetof(mavlink_utm_global_position_t, next_lat) }, \
  73. { "next_lon", NULL, MAVLINK_TYPE_INT32_T, 0, 28, offsetof(mavlink_utm_global_position_t, next_lon) }, \
  74. { "next_alt", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_utm_global_position_t, next_alt) }, \
  75. { "update_rate", NULL, MAVLINK_TYPE_UINT16_T, 0, 48, offsetof(mavlink_utm_global_position_t, update_rate) }, \
  76. { "flight_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 68, offsetof(mavlink_utm_global_position_t, flight_state) }, \
  77. { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 69, offsetof(mavlink_utm_global_position_t, flags) }, \
  78. } \
  79. }
  80. #endif
  81. /**
  82. * @brief Pack a utm_global_position message
  83. * @param system_id ID of this system
  84. * @param component_id ID of this component (e.g. 200 for IMU)
  85. * @param msg The MAVLink message to compress the data into
  86. *
  87. * @param time [us] Time of applicability of position (microseconds since UNIX epoch).
  88. * @param uas_id Unique UAS ID.
  89. * @param lat [degE7] Latitude (WGS84)
  90. * @param lon [degE7] Longitude (WGS84)
  91. * @param alt [mm] Altitude (WGS84)
  92. * @param relative_alt [mm] Altitude above ground
  93. * @param vx [cm/s] Ground X speed (latitude, positive north)
  94. * @param vy [cm/s] Ground Y speed (longitude, positive east)
  95. * @param vz [cm/s] Ground Z speed (altitude, positive down)
  96. * @param h_acc [mm] Horizontal position uncertainty (standard deviation)
  97. * @param v_acc [mm] Altitude uncertainty (standard deviation)
  98. * @param vel_acc [cm/s] Speed uncertainty (standard deviation)
  99. * @param next_lat [degE7] Next waypoint, latitude (WGS84)
  100. * @param next_lon [degE7] Next waypoint, longitude (WGS84)
  101. * @param next_alt [mm] Next waypoint, altitude (WGS84)
  102. * @param update_rate [cs] Time until next update. Set to 0 if unknown or in data driven mode.
  103. * @param flight_state Flight state
  104. * @param flags Bitwise OR combination of the data available flags.
  105. * @return length of the message in bytes (excluding serial stream start sign)
  106. */
  107. static inline uint16_t mavlink_msg_utm_global_position_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  108. uint64_t time, const uint8_t *uas_id, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t h_acc, uint16_t v_acc, uint16_t vel_acc, int32_t next_lat, int32_t next_lon, int32_t next_alt, uint16_t update_rate, uint8_t flight_state, uint8_t flags)
  109. {
  110. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  111. char buf[MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN];
  112. _mav_put_uint64_t(buf, 0, time);
  113. _mav_put_int32_t(buf, 8, lat);
  114. _mav_put_int32_t(buf, 12, lon);
  115. _mav_put_int32_t(buf, 16, alt);
  116. _mav_put_int32_t(buf, 20, relative_alt);
  117. _mav_put_int32_t(buf, 24, next_lat);
  118. _mav_put_int32_t(buf, 28, next_lon);
  119. _mav_put_int32_t(buf, 32, next_alt);
  120. _mav_put_int16_t(buf, 36, vx);
  121. _mav_put_int16_t(buf, 38, vy);
  122. _mav_put_int16_t(buf, 40, vz);
  123. _mav_put_uint16_t(buf, 42, h_acc);
  124. _mav_put_uint16_t(buf, 44, v_acc);
  125. _mav_put_uint16_t(buf, 46, vel_acc);
  126. _mav_put_uint16_t(buf, 48, update_rate);
  127. _mav_put_uint8_t(buf, 68, flight_state);
  128. _mav_put_uint8_t(buf, 69, flags);
  129. _mav_put_uint8_t_array(buf, 50, uas_id, 18);
  130. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN);
  131. #else
  132. mavlink_utm_global_position_t packet;
  133. packet.time = time;
  134. packet.lat = lat;
  135. packet.lon = lon;
  136. packet.alt = alt;
  137. packet.relative_alt = relative_alt;
  138. packet.next_lat = next_lat;
  139. packet.next_lon = next_lon;
  140. packet.next_alt = next_alt;
  141. packet.vx = vx;
  142. packet.vy = vy;
  143. packet.vz = vz;
  144. packet.h_acc = h_acc;
  145. packet.v_acc = v_acc;
  146. packet.vel_acc = vel_acc;
  147. packet.update_rate = update_rate;
  148. packet.flight_state = flight_state;
  149. packet.flags = flags;
  150. mav_array_memcpy(packet.uas_id, uas_id, sizeof(uint8_t)*18);
  151. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN);
  152. #endif
  153. msg->msgid = MAVLINK_MSG_ID_UTM_GLOBAL_POSITION;
  154. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  155. }
  156. /**
  157. * @brief Pack a utm_global_position message on a channel
  158. * @param system_id ID of this system
  159. * @param component_id ID of this component (e.g. 200 for IMU)
  160. * @param chan The MAVLink channel this message will be sent over
  161. * @param msg The MAVLink message to compress the data into
  162. * @param time [us] Time of applicability of position (microseconds since UNIX epoch).
  163. * @param uas_id Unique UAS ID.
  164. * @param lat [degE7] Latitude (WGS84)
  165. * @param lon [degE7] Longitude (WGS84)
  166. * @param alt [mm] Altitude (WGS84)
  167. * @param relative_alt [mm] Altitude above ground
  168. * @param vx [cm/s] Ground X speed (latitude, positive north)
  169. * @param vy [cm/s] Ground Y speed (longitude, positive east)
  170. * @param vz [cm/s] Ground Z speed (altitude, positive down)
  171. * @param h_acc [mm] Horizontal position uncertainty (standard deviation)
  172. * @param v_acc [mm] Altitude uncertainty (standard deviation)
  173. * @param vel_acc [cm/s] Speed uncertainty (standard deviation)
  174. * @param next_lat [degE7] Next waypoint, latitude (WGS84)
  175. * @param next_lon [degE7] Next waypoint, longitude (WGS84)
  176. * @param next_alt [mm] Next waypoint, altitude (WGS84)
  177. * @param update_rate [cs] Time until next update. Set to 0 if unknown or in data driven mode.
  178. * @param flight_state Flight state
  179. * @param flags Bitwise OR combination of the data available flags.
  180. * @return length of the message in bytes (excluding serial stream start sign)
  181. */
  182. static inline uint16_t mavlink_msg_utm_global_position_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  183. mavlink_message_t* msg,
  184. uint64_t time,const uint8_t *uas_id,int32_t lat,int32_t lon,int32_t alt,int32_t relative_alt,int16_t vx,int16_t vy,int16_t vz,uint16_t h_acc,uint16_t v_acc,uint16_t vel_acc,int32_t next_lat,int32_t next_lon,int32_t next_alt,uint16_t update_rate,uint8_t flight_state,uint8_t flags)
  185. {
  186. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  187. char buf[MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN];
  188. _mav_put_uint64_t(buf, 0, time);
  189. _mav_put_int32_t(buf, 8, lat);
  190. _mav_put_int32_t(buf, 12, lon);
  191. _mav_put_int32_t(buf, 16, alt);
  192. _mav_put_int32_t(buf, 20, relative_alt);
  193. _mav_put_int32_t(buf, 24, next_lat);
  194. _mav_put_int32_t(buf, 28, next_lon);
  195. _mav_put_int32_t(buf, 32, next_alt);
  196. _mav_put_int16_t(buf, 36, vx);
  197. _mav_put_int16_t(buf, 38, vy);
  198. _mav_put_int16_t(buf, 40, vz);
  199. _mav_put_uint16_t(buf, 42, h_acc);
  200. _mav_put_uint16_t(buf, 44, v_acc);
  201. _mav_put_uint16_t(buf, 46, vel_acc);
  202. _mav_put_uint16_t(buf, 48, update_rate);
  203. _mav_put_uint8_t(buf, 68, flight_state);
  204. _mav_put_uint8_t(buf, 69, flags);
  205. _mav_put_uint8_t_array(buf, 50, uas_id, 18);
  206. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN);
  207. #else
  208. mavlink_utm_global_position_t packet;
  209. packet.time = time;
  210. packet.lat = lat;
  211. packet.lon = lon;
  212. packet.alt = alt;
  213. packet.relative_alt = relative_alt;
  214. packet.next_lat = next_lat;
  215. packet.next_lon = next_lon;
  216. packet.next_alt = next_alt;
  217. packet.vx = vx;
  218. packet.vy = vy;
  219. packet.vz = vz;
  220. packet.h_acc = h_acc;
  221. packet.v_acc = v_acc;
  222. packet.vel_acc = vel_acc;
  223. packet.update_rate = update_rate;
  224. packet.flight_state = flight_state;
  225. packet.flags = flags;
  226. mav_array_memcpy(packet.uas_id, uas_id, sizeof(uint8_t)*18);
  227. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN);
  228. #endif
  229. msg->msgid = MAVLINK_MSG_ID_UTM_GLOBAL_POSITION;
  230. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  231. }
  232. /**
  233. * @brief Encode a utm_global_position 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 utm_global_position C-struct to read the message contents from
  239. */
  240. static inline uint16_t mavlink_msg_utm_global_position_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_utm_global_position_t* utm_global_position)
  241. {
  242. return mavlink_msg_utm_global_position_pack(system_id, component_id, msg, utm_global_position->time, utm_global_position->uas_id, utm_global_position->lat, utm_global_position->lon, utm_global_position->alt, utm_global_position->relative_alt, utm_global_position->vx, utm_global_position->vy, utm_global_position->vz, utm_global_position->h_acc, utm_global_position->v_acc, utm_global_position->vel_acc, utm_global_position->next_lat, utm_global_position->next_lon, utm_global_position->next_alt, utm_global_position->update_rate, utm_global_position->flight_state, utm_global_position->flags);
  243. }
  244. /**
  245. * @brief Encode a utm_global_position 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 utm_global_position C-struct to read the message contents from
  252. */
  253. static inline uint16_t mavlink_msg_utm_global_position_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_utm_global_position_t* utm_global_position)
  254. {
  255. return mavlink_msg_utm_global_position_pack_chan(system_id, component_id, chan, msg, utm_global_position->time, utm_global_position->uas_id, utm_global_position->lat, utm_global_position->lon, utm_global_position->alt, utm_global_position->relative_alt, utm_global_position->vx, utm_global_position->vy, utm_global_position->vz, utm_global_position->h_acc, utm_global_position->v_acc, utm_global_position->vel_acc, utm_global_position->next_lat, utm_global_position->next_lon, utm_global_position->next_alt, utm_global_position->update_rate, utm_global_position->flight_state, utm_global_position->flags);
  256. }
  257. /**
  258. * @brief Send a utm_global_position message
  259. * @param chan MAVLink channel to send the message
  260. *
  261. * @param time [us] Time of applicability of position (microseconds since UNIX epoch).
  262. * @param uas_id Unique UAS ID.
  263. * @param lat [degE7] Latitude (WGS84)
  264. * @param lon [degE7] Longitude (WGS84)
  265. * @param alt [mm] Altitude (WGS84)
  266. * @param relative_alt [mm] Altitude above ground
  267. * @param vx [cm/s] Ground X speed (latitude, positive north)
  268. * @param vy [cm/s] Ground Y speed (longitude, positive east)
  269. * @param vz [cm/s] Ground Z speed (altitude, positive down)
  270. * @param h_acc [mm] Horizontal position uncertainty (standard deviation)
  271. * @param v_acc [mm] Altitude uncertainty (standard deviation)
  272. * @param vel_acc [cm/s] Speed uncertainty (standard deviation)
  273. * @param next_lat [degE7] Next waypoint, latitude (WGS84)
  274. * @param next_lon [degE7] Next waypoint, longitude (WGS84)
  275. * @param next_alt [mm] Next waypoint, altitude (WGS84)
  276. * @param update_rate [cs] Time until next update. Set to 0 if unknown or in data driven mode.
  277. * @param flight_state Flight state
  278. * @param flags Bitwise OR combination of the data available flags.
  279. */
  280. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  281. static inline void mavlink_msg_utm_global_position_send(mavlink_channel_t chan, uint64_t time, const uint8_t *uas_id, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t h_acc, uint16_t v_acc, uint16_t vel_acc, int32_t next_lat, int32_t next_lon, int32_t next_alt, uint16_t update_rate, uint8_t flight_state, uint8_t flags)
  282. {
  283. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  284. char buf[MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN];
  285. _mav_put_uint64_t(buf, 0, time);
  286. _mav_put_int32_t(buf, 8, lat);
  287. _mav_put_int32_t(buf, 12, lon);
  288. _mav_put_int32_t(buf, 16, alt);
  289. _mav_put_int32_t(buf, 20, relative_alt);
  290. _mav_put_int32_t(buf, 24, next_lat);
  291. _mav_put_int32_t(buf, 28, next_lon);
  292. _mav_put_int32_t(buf, 32, next_alt);
  293. _mav_put_int16_t(buf, 36, vx);
  294. _mav_put_int16_t(buf, 38, vy);
  295. _mav_put_int16_t(buf, 40, vz);
  296. _mav_put_uint16_t(buf, 42, h_acc);
  297. _mav_put_uint16_t(buf, 44, v_acc);
  298. _mav_put_uint16_t(buf, 46, vel_acc);
  299. _mav_put_uint16_t(buf, 48, update_rate);
  300. _mav_put_uint8_t(buf, 68, flight_state);
  301. _mav_put_uint8_t(buf, 69, flags);
  302. _mav_put_uint8_t_array(buf, 50, uas_id, 18);
  303. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION, buf, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  304. #else
  305. mavlink_utm_global_position_t packet;
  306. packet.time = time;
  307. packet.lat = lat;
  308. packet.lon = lon;
  309. packet.alt = alt;
  310. packet.relative_alt = relative_alt;
  311. packet.next_lat = next_lat;
  312. packet.next_lon = next_lon;
  313. packet.next_alt = next_alt;
  314. packet.vx = vx;
  315. packet.vy = vy;
  316. packet.vz = vz;
  317. packet.h_acc = h_acc;
  318. packet.v_acc = v_acc;
  319. packet.vel_acc = vel_acc;
  320. packet.update_rate = update_rate;
  321. packet.flight_state = flight_state;
  322. packet.flags = flags;
  323. mav_array_memcpy(packet.uas_id, uas_id, sizeof(uint8_t)*18);
  324. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION, (const char *)&packet, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  325. #endif
  326. }
  327. /**
  328. * @brief Send a utm_global_position message
  329. * @param chan MAVLink channel to send the message
  330. * @param struct The MAVLink struct to serialize
  331. */
  332. static inline void mavlink_msg_utm_global_position_send_struct(mavlink_channel_t chan, const mavlink_utm_global_position_t* utm_global_position)
  333. {
  334. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  335. mavlink_msg_utm_global_position_send(chan, utm_global_position->time, utm_global_position->uas_id, utm_global_position->lat, utm_global_position->lon, utm_global_position->alt, utm_global_position->relative_alt, utm_global_position->vx, utm_global_position->vy, utm_global_position->vz, utm_global_position->h_acc, utm_global_position->v_acc, utm_global_position->vel_acc, utm_global_position->next_lat, utm_global_position->next_lon, utm_global_position->next_alt, utm_global_position->update_rate, utm_global_position->flight_state, utm_global_position->flags);
  336. #else
  337. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION, (const char *)utm_global_position, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  338. #endif
  339. }
  340. #if MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  341. /*
  342. This variant of _send() can be used to save stack space by re-using
  343. memory from the receive buffer. The caller provides a
  344. mavlink_message_t which is the size of a full mavlink message. This
  345. is usually the receive buffer for the channel, and allows a reply to an
  346. incoming message with minimum stack space usage.
  347. */
  348. static inline void mavlink_msg_utm_global_position_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time, const uint8_t *uas_id, int32_t lat, int32_t lon, int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, int16_t vz, uint16_t h_acc, uint16_t v_acc, uint16_t vel_acc, int32_t next_lat, int32_t next_lon, int32_t next_alt, uint16_t update_rate, uint8_t flight_state, uint8_t flags)
  349. {
  350. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  351. char *buf = (char *)msgbuf;
  352. _mav_put_uint64_t(buf, 0, time);
  353. _mav_put_int32_t(buf, 8, lat);
  354. _mav_put_int32_t(buf, 12, lon);
  355. _mav_put_int32_t(buf, 16, alt);
  356. _mav_put_int32_t(buf, 20, relative_alt);
  357. _mav_put_int32_t(buf, 24, next_lat);
  358. _mav_put_int32_t(buf, 28, next_lon);
  359. _mav_put_int32_t(buf, 32, next_alt);
  360. _mav_put_int16_t(buf, 36, vx);
  361. _mav_put_int16_t(buf, 38, vy);
  362. _mav_put_int16_t(buf, 40, vz);
  363. _mav_put_uint16_t(buf, 42, h_acc);
  364. _mav_put_uint16_t(buf, 44, v_acc);
  365. _mav_put_uint16_t(buf, 46, vel_acc);
  366. _mav_put_uint16_t(buf, 48, update_rate);
  367. _mav_put_uint8_t(buf, 68, flight_state);
  368. _mav_put_uint8_t(buf, 69, flags);
  369. _mav_put_uint8_t_array(buf, 50, uas_id, 18);
  370. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION, buf, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  371. #else
  372. mavlink_utm_global_position_t *packet = (mavlink_utm_global_position_t *)msgbuf;
  373. packet->time = time;
  374. packet->lat = lat;
  375. packet->lon = lon;
  376. packet->alt = alt;
  377. packet->relative_alt = relative_alt;
  378. packet->next_lat = next_lat;
  379. packet->next_lon = next_lon;
  380. packet->next_alt = next_alt;
  381. packet->vx = vx;
  382. packet->vy = vy;
  383. packet->vz = vz;
  384. packet->h_acc = h_acc;
  385. packet->v_acc = v_acc;
  386. packet->vel_acc = vel_acc;
  387. packet->update_rate = update_rate;
  388. packet->flight_state = flight_state;
  389. packet->flags = flags;
  390. mav_array_memcpy(packet->uas_id, uas_id, sizeof(uint8_t)*18);
  391. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION, (const char *)packet, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_MIN_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_CRC);
  392. #endif
  393. }
  394. #endif
  395. #endif
  396. // MESSAGE UTM_GLOBAL_POSITION UNPACKING
  397. /**
  398. * @brief Get field time from utm_global_position message
  399. *
  400. * @return [us] Time of applicability of position (microseconds since UNIX epoch).
  401. */
  402. static inline uint64_t mavlink_msg_utm_global_position_get_time(const mavlink_message_t* msg)
  403. {
  404. return _MAV_RETURN_uint64_t(msg, 0);
  405. }
  406. /**
  407. * @brief Get field uas_id from utm_global_position message
  408. *
  409. * @return Unique UAS ID.
  410. */
  411. static inline uint16_t mavlink_msg_utm_global_position_get_uas_id(const mavlink_message_t* msg, uint8_t *uas_id)
  412. {
  413. return _MAV_RETURN_uint8_t_array(msg, uas_id, 18, 50);
  414. }
  415. /**
  416. * @brief Get field lat from utm_global_position message
  417. *
  418. * @return [degE7] Latitude (WGS84)
  419. */
  420. static inline int32_t mavlink_msg_utm_global_position_get_lat(const mavlink_message_t* msg)
  421. {
  422. return _MAV_RETURN_int32_t(msg, 8);
  423. }
  424. /**
  425. * @brief Get field lon from utm_global_position message
  426. *
  427. * @return [degE7] Longitude (WGS84)
  428. */
  429. static inline int32_t mavlink_msg_utm_global_position_get_lon(const mavlink_message_t* msg)
  430. {
  431. return _MAV_RETURN_int32_t(msg, 12);
  432. }
  433. /**
  434. * @brief Get field alt from utm_global_position message
  435. *
  436. * @return [mm] Altitude (WGS84)
  437. */
  438. static inline int32_t mavlink_msg_utm_global_position_get_alt(const mavlink_message_t* msg)
  439. {
  440. return _MAV_RETURN_int32_t(msg, 16);
  441. }
  442. /**
  443. * @brief Get field relative_alt from utm_global_position message
  444. *
  445. * @return [mm] Altitude above ground
  446. */
  447. static inline int32_t mavlink_msg_utm_global_position_get_relative_alt(const mavlink_message_t* msg)
  448. {
  449. return _MAV_RETURN_int32_t(msg, 20);
  450. }
  451. /**
  452. * @brief Get field vx from utm_global_position message
  453. *
  454. * @return [cm/s] Ground X speed (latitude, positive north)
  455. */
  456. static inline int16_t mavlink_msg_utm_global_position_get_vx(const mavlink_message_t* msg)
  457. {
  458. return _MAV_RETURN_int16_t(msg, 36);
  459. }
  460. /**
  461. * @brief Get field vy from utm_global_position message
  462. *
  463. * @return [cm/s] Ground Y speed (longitude, positive east)
  464. */
  465. static inline int16_t mavlink_msg_utm_global_position_get_vy(const mavlink_message_t* msg)
  466. {
  467. return _MAV_RETURN_int16_t(msg, 38);
  468. }
  469. /**
  470. * @brief Get field vz from utm_global_position message
  471. *
  472. * @return [cm/s] Ground Z speed (altitude, positive down)
  473. */
  474. static inline int16_t mavlink_msg_utm_global_position_get_vz(const mavlink_message_t* msg)
  475. {
  476. return _MAV_RETURN_int16_t(msg, 40);
  477. }
  478. /**
  479. * @brief Get field h_acc from utm_global_position message
  480. *
  481. * @return [mm] Horizontal position uncertainty (standard deviation)
  482. */
  483. static inline uint16_t mavlink_msg_utm_global_position_get_h_acc(const mavlink_message_t* msg)
  484. {
  485. return _MAV_RETURN_uint16_t(msg, 42);
  486. }
  487. /**
  488. * @brief Get field v_acc from utm_global_position message
  489. *
  490. * @return [mm] Altitude uncertainty (standard deviation)
  491. */
  492. static inline uint16_t mavlink_msg_utm_global_position_get_v_acc(const mavlink_message_t* msg)
  493. {
  494. return _MAV_RETURN_uint16_t(msg, 44);
  495. }
  496. /**
  497. * @brief Get field vel_acc from utm_global_position message
  498. *
  499. * @return [cm/s] Speed uncertainty (standard deviation)
  500. */
  501. static inline uint16_t mavlink_msg_utm_global_position_get_vel_acc(const mavlink_message_t* msg)
  502. {
  503. return _MAV_RETURN_uint16_t(msg, 46);
  504. }
  505. /**
  506. * @brief Get field next_lat from utm_global_position message
  507. *
  508. * @return [degE7] Next waypoint, latitude (WGS84)
  509. */
  510. static inline int32_t mavlink_msg_utm_global_position_get_next_lat(const mavlink_message_t* msg)
  511. {
  512. return _MAV_RETURN_int32_t(msg, 24);
  513. }
  514. /**
  515. * @brief Get field next_lon from utm_global_position message
  516. *
  517. * @return [degE7] Next waypoint, longitude (WGS84)
  518. */
  519. static inline int32_t mavlink_msg_utm_global_position_get_next_lon(const mavlink_message_t* msg)
  520. {
  521. return _MAV_RETURN_int32_t(msg, 28);
  522. }
  523. /**
  524. * @brief Get field next_alt from utm_global_position message
  525. *
  526. * @return [mm] Next waypoint, altitude (WGS84)
  527. */
  528. static inline int32_t mavlink_msg_utm_global_position_get_next_alt(const mavlink_message_t* msg)
  529. {
  530. return _MAV_RETURN_int32_t(msg, 32);
  531. }
  532. /**
  533. * @brief Get field update_rate from utm_global_position message
  534. *
  535. * @return [cs] Time until next update. Set to 0 if unknown or in data driven mode.
  536. */
  537. static inline uint16_t mavlink_msg_utm_global_position_get_update_rate(const mavlink_message_t* msg)
  538. {
  539. return _MAV_RETURN_uint16_t(msg, 48);
  540. }
  541. /**
  542. * @brief Get field flight_state from utm_global_position message
  543. *
  544. * @return Flight state
  545. */
  546. static inline uint8_t mavlink_msg_utm_global_position_get_flight_state(const mavlink_message_t* msg)
  547. {
  548. return _MAV_RETURN_uint8_t(msg, 68);
  549. }
  550. /**
  551. * @brief Get field flags from utm_global_position message
  552. *
  553. * @return Bitwise OR combination of the data available flags.
  554. */
  555. static inline uint8_t mavlink_msg_utm_global_position_get_flags(const mavlink_message_t* msg)
  556. {
  557. return _MAV_RETURN_uint8_t(msg, 69);
  558. }
  559. /**
  560. * @brief Decode a utm_global_position message into a struct
  561. *
  562. * @param msg The message to decode
  563. * @param utm_global_position C-struct to decode the message contents into
  564. */
  565. static inline void mavlink_msg_utm_global_position_decode(const mavlink_message_t* msg, mavlink_utm_global_position_t* utm_global_position)
  566. {
  567. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  568. utm_global_position->time = mavlink_msg_utm_global_position_get_time(msg);
  569. utm_global_position->lat = mavlink_msg_utm_global_position_get_lat(msg);
  570. utm_global_position->lon = mavlink_msg_utm_global_position_get_lon(msg);
  571. utm_global_position->alt = mavlink_msg_utm_global_position_get_alt(msg);
  572. utm_global_position->relative_alt = mavlink_msg_utm_global_position_get_relative_alt(msg);
  573. utm_global_position->next_lat = mavlink_msg_utm_global_position_get_next_lat(msg);
  574. utm_global_position->next_lon = mavlink_msg_utm_global_position_get_next_lon(msg);
  575. utm_global_position->next_alt = mavlink_msg_utm_global_position_get_next_alt(msg);
  576. utm_global_position->vx = mavlink_msg_utm_global_position_get_vx(msg);
  577. utm_global_position->vy = mavlink_msg_utm_global_position_get_vy(msg);
  578. utm_global_position->vz = mavlink_msg_utm_global_position_get_vz(msg);
  579. utm_global_position->h_acc = mavlink_msg_utm_global_position_get_h_acc(msg);
  580. utm_global_position->v_acc = mavlink_msg_utm_global_position_get_v_acc(msg);
  581. utm_global_position->vel_acc = mavlink_msg_utm_global_position_get_vel_acc(msg);
  582. utm_global_position->update_rate = mavlink_msg_utm_global_position_get_update_rate(msg);
  583. mavlink_msg_utm_global_position_get_uas_id(msg, utm_global_position->uas_id);
  584. utm_global_position->flight_state = mavlink_msg_utm_global_position_get_flight_state(msg);
  585. utm_global_position->flags = mavlink_msg_utm_global_position_get_flags(msg);
  586. #else
  587. uint8_t len = msg->len < MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN? msg->len : MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN;
  588. memset(utm_global_position, 0, MAVLINK_MSG_ID_UTM_GLOBAL_POSITION_LEN);
  589. memcpy(utm_global_position, _MAV_PAYLOAD(msg), len);
  590. #endif
  591. }