You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

513 lines
23 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE GPS_RTK PACKING
  3. #define MAVLINK_MSG_ID_GPS_RTK 127
  4. MAVPACKED(
  5. typedef struct __mavlink_gps_rtk_t {
  6. uint32_t time_last_baseline_ms; /*< [ms] Time since boot of last baseline message received.*/
  7. uint32_t tow; /*< [ms] GPS Time of Week of last baseline*/
  8. int32_t baseline_a_mm; /*< [mm] Current baseline in ECEF x or NED north component.*/
  9. int32_t baseline_b_mm; /*< [mm] Current baseline in ECEF y or NED east component.*/
  10. int32_t baseline_c_mm; /*< [mm] Current baseline in ECEF z or NED down component.*/
  11. uint32_t accuracy; /*< Current estimate of baseline accuracy.*/
  12. int32_t iar_num_hypotheses; /*< Current number of integer ambiguity hypotheses.*/
  13. uint16_t wn; /*< GPS Week Number of last baseline*/
  14. uint8_t rtk_receiver_id; /*< Identification of connected RTK receiver.*/
  15. uint8_t rtk_health; /*< GPS-specific health report for RTK data.*/
  16. uint8_t rtk_rate; /*< [Hz] Rate of baseline messages being received by GPS*/
  17. uint8_t nsats; /*< Current number of sats used for RTK calculation.*/
  18. uint8_t baseline_coords_type; /*< Coordinate system of baseline*/
  19. }) mavlink_gps_rtk_t;
  20. #define MAVLINK_MSG_ID_GPS_RTK_LEN 35
  21. #define MAVLINK_MSG_ID_GPS_RTK_MIN_LEN 35
  22. #define MAVLINK_MSG_ID_127_LEN 35
  23. #define MAVLINK_MSG_ID_127_MIN_LEN 35
  24. #define MAVLINK_MSG_ID_GPS_RTK_CRC 25
  25. #define MAVLINK_MSG_ID_127_CRC 25
  26. #if MAVLINK_COMMAND_24BIT
  27. #define MAVLINK_MESSAGE_INFO_GPS_RTK { \
  28. 127, \
  29. "GPS_RTK", \
  30. 13, \
  31. { { "time_last_baseline_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_gps_rtk_t, time_last_baseline_ms) }, \
  32. { "rtk_receiver_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 30, offsetof(mavlink_gps_rtk_t, rtk_receiver_id) }, \
  33. { "wn", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_gps_rtk_t, wn) }, \
  34. { "tow", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_gps_rtk_t, tow) }, \
  35. { "rtk_health", NULL, MAVLINK_TYPE_UINT8_T, 0, 31, offsetof(mavlink_gps_rtk_t, rtk_health) }, \
  36. { "rtk_rate", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_gps_rtk_t, rtk_rate) }, \
  37. { "nsats", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_gps_rtk_t, nsats) }, \
  38. { "baseline_coords_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_gps_rtk_t, baseline_coords_type) }, \
  39. { "baseline_a_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_gps_rtk_t, baseline_a_mm) }, \
  40. { "baseline_b_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_gps_rtk_t, baseline_b_mm) }, \
  41. { "baseline_c_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_gps_rtk_t, baseline_c_mm) }, \
  42. { "accuracy", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_gps_rtk_t, accuracy) }, \
  43. { "iar_num_hypotheses", NULL, MAVLINK_TYPE_INT32_T, 0, 24, offsetof(mavlink_gps_rtk_t, iar_num_hypotheses) }, \
  44. } \
  45. }
  46. #else
  47. #define MAVLINK_MESSAGE_INFO_GPS_RTK { \
  48. "GPS_RTK", \
  49. 13, \
  50. { { "time_last_baseline_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_gps_rtk_t, time_last_baseline_ms) }, \
  51. { "rtk_receiver_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 30, offsetof(mavlink_gps_rtk_t, rtk_receiver_id) }, \
  52. { "wn", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_gps_rtk_t, wn) }, \
  53. { "tow", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_gps_rtk_t, tow) }, \
  54. { "rtk_health", NULL, MAVLINK_TYPE_UINT8_T, 0, 31, offsetof(mavlink_gps_rtk_t, rtk_health) }, \
  55. { "rtk_rate", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_gps_rtk_t, rtk_rate) }, \
  56. { "nsats", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_gps_rtk_t, nsats) }, \
  57. { "baseline_coords_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_gps_rtk_t, baseline_coords_type) }, \
  58. { "baseline_a_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_gps_rtk_t, baseline_a_mm) }, \
  59. { "baseline_b_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_gps_rtk_t, baseline_b_mm) }, \
  60. { "baseline_c_mm", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_gps_rtk_t, baseline_c_mm) }, \
  61. { "accuracy", NULL, MAVLINK_TYPE_UINT32_T, 0, 20, offsetof(mavlink_gps_rtk_t, accuracy) }, \
  62. { "iar_num_hypotheses", NULL, MAVLINK_TYPE_INT32_T, 0, 24, offsetof(mavlink_gps_rtk_t, iar_num_hypotheses) }, \
  63. } \
  64. }
  65. #endif
  66. /**
  67. * @brief Pack a gps_rtk message
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param msg The MAVLink message to compress the data into
  71. *
  72. * @param time_last_baseline_ms [ms] Time since boot of last baseline message received.
  73. * @param rtk_receiver_id Identification of connected RTK receiver.
  74. * @param wn GPS Week Number of last baseline
  75. * @param tow [ms] GPS Time of Week of last baseline
  76. * @param rtk_health GPS-specific health report for RTK data.
  77. * @param rtk_rate [Hz] Rate of baseline messages being received by GPS
  78. * @param nsats Current number of sats used for RTK calculation.
  79. * @param baseline_coords_type Coordinate system of baseline
  80. * @param baseline_a_mm [mm] Current baseline in ECEF x or NED north component.
  81. * @param baseline_b_mm [mm] Current baseline in ECEF y or NED east component.
  82. * @param baseline_c_mm [mm] Current baseline in ECEF z or NED down component.
  83. * @param accuracy Current estimate of baseline accuracy.
  84. * @param iar_num_hypotheses Current number of integer ambiguity hypotheses.
  85. * @return length of the message in bytes (excluding serial stream start sign)
  86. */
  87. static inline uint16_t mavlink_msg_gps_rtk_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  88. uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses)
  89. {
  90. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  91. char buf[MAVLINK_MSG_ID_GPS_RTK_LEN];
  92. _mav_put_uint32_t(buf, 0, time_last_baseline_ms);
  93. _mav_put_uint32_t(buf, 4, tow);
  94. _mav_put_int32_t(buf, 8, baseline_a_mm);
  95. _mav_put_int32_t(buf, 12, baseline_b_mm);
  96. _mav_put_int32_t(buf, 16, baseline_c_mm);
  97. _mav_put_uint32_t(buf, 20, accuracy);
  98. _mav_put_int32_t(buf, 24, iar_num_hypotheses);
  99. _mav_put_uint16_t(buf, 28, wn);
  100. _mav_put_uint8_t(buf, 30, rtk_receiver_id);
  101. _mav_put_uint8_t(buf, 31, rtk_health);
  102. _mav_put_uint8_t(buf, 32, rtk_rate);
  103. _mav_put_uint8_t(buf, 33, nsats);
  104. _mav_put_uint8_t(buf, 34, baseline_coords_type);
  105. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTK_LEN);
  106. #else
  107. mavlink_gps_rtk_t packet;
  108. packet.time_last_baseline_ms = time_last_baseline_ms;
  109. packet.tow = tow;
  110. packet.baseline_a_mm = baseline_a_mm;
  111. packet.baseline_b_mm = baseline_b_mm;
  112. packet.baseline_c_mm = baseline_c_mm;
  113. packet.accuracy = accuracy;
  114. packet.iar_num_hypotheses = iar_num_hypotheses;
  115. packet.wn = wn;
  116. packet.rtk_receiver_id = rtk_receiver_id;
  117. packet.rtk_health = rtk_health;
  118. packet.rtk_rate = rtk_rate;
  119. packet.nsats = nsats;
  120. packet.baseline_coords_type = baseline_coords_type;
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTK_LEN);
  122. #endif
  123. msg->msgid = MAVLINK_MSG_ID_GPS_RTK;
  124. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  125. }
  126. /**
  127. * @brief Pack a gps_rtk message on a channel
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param chan The MAVLink channel this message will be sent over
  131. * @param msg The MAVLink message to compress the data into
  132. * @param time_last_baseline_ms [ms] Time since boot of last baseline message received.
  133. * @param rtk_receiver_id Identification of connected RTK receiver.
  134. * @param wn GPS Week Number of last baseline
  135. * @param tow [ms] GPS Time of Week of last baseline
  136. * @param rtk_health GPS-specific health report for RTK data.
  137. * @param rtk_rate [Hz] Rate of baseline messages being received by GPS
  138. * @param nsats Current number of sats used for RTK calculation.
  139. * @param baseline_coords_type Coordinate system of baseline
  140. * @param baseline_a_mm [mm] Current baseline in ECEF x or NED north component.
  141. * @param baseline_b_mm [mm] Current baseline in ECEF y or NED east component.
  142. * @param baseline_c_mm [mm] Current baseline in ECEF z or NED down component.
  143. * @param accuracy Current estimate of baseline accuracy.
  144. * @param iar_num_hypotheses Current number of integer ambiguity hypotheses.
  145. * @return length of the message in bytes (excluding serial stream start sign)
  146. */
  147. static inline uint16_t mavlink_msg_gps_rtk_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  148. mavlink_message_t* msg,
  149. uint32_t time_last_baseline_ms,uint8_t rtk_receiver_id,uint16_t wn,uint32_t tow,uint8_t rtk_health,uint8_t rtk_rate,uint8_t nsats,uint8_t baseline_coords_type,int32_t baseline_a_mm,int32_t baseline_b_mm,int32_t baseline_c_mm,uint32_t accuracy,int32_t iar_num_hypotheses)
  150. {
  151. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  152. char buf[MAVLINK_MSG_ID_GPS_RTK_LEN];
  153. _mav_put_uint32_t(buf, 0, time_last_baseline_ms);
  154. _mav_put_uint32_t(buf, 4, tow);
  155. _mav_put_int32_t(buf, 8, baseline_a_mm);
  156. _mav_put_int32_t(buf, 12, baseline_b_mm);
  157. _mav_put_int32_t(buf, 16, baseline_c_mm);
  158. _mav_put_uint32_t(buf, 20, accuracy);
  159. _mav_put_int32_t(buf, 24, iar_num_hypotheses);
  160. _mav_put_uint16_t(buf, 28, wn);
  161. _mav_put_uint8_t(buf, 30, rtk_receiver_id);
  162. _mav_put_uint8_t(buf, 31, rtk_health);
  163. _mav_put_uint8_t(buf, 32, rtk_rate);
  164. _mav_put_uint8_t(buf, 33, nsats);
  165. _mav_put_uint8_t(buf, 34, baseline_coords_type);
  166. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTK_LEN);
  167. #else
  168. mavlink_gps_rtk_t packet;
  169. packet.time_last_baseline_ms = time_last_baseline_ms;
  170. packet.tow = tow;
  171. packet.baseline_a_mm = baseline_a_mm;
  172. packet.baseline_b_mm = baseline_b_mm;
  173. packet.baseline_c_mm = baseline_c_mm;
  174. packet.accuracy = accuracy;
  175. packet.iar_num_hypotheses = iar_num_hypotheses;
  176. packet.wn = wn;
  177. packet.rtk_receiver_id = rtk_receiver_id;
  178. packet.rtk_health = rtk_health;
  179. packet.rtk_rate = rtk_rate;
  180. packet.nsats = nsats;
  181. packet.baseline_coords_type = baseline_coords_type;
  182. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTK_LEN);
  183. #endif
  184. msg->msgid = MAVLINK_MSG_ID_GPS_RTK;
  185. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  186. }
  187. /**
  188. * @brief Encode a gps_rtk struct
  189. *
  190. * @param system_id ID of this system
  191. * @param component_id ID of this component (e.g. 200 for IMU)
  192. * @param msg The MAVLink message to compress the data into
  193. * @param gps_rtk C-struct to read the message contents from
  194. */
  195. static inline uint16_t mavlink_msg_gps_rtk_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_rtk_t* gps_rtk)
  196. {
  197. return mavlink_msg_gps_rtk_pack(system_id, component_id, msg, gps_rtk->time_last_baseline_ms, gps_rtk->rtk_receiver_id, gps_rtk->wn, gps_rtk->tow, gps_rtk->rtk_health, gps_rtk->rtk_rate, gps_rtk->nsats, gps_rtk->baseline_coords_type, gps_rtk->baseline_a_mm, gps_rtk->baseline_b_mm, gps_rtk->baseline_c_mm, gps_rtk->accuracy, gps_rtk->iar_num_hypotheses);
  198. }
  199. /**
  200. * @brief Encode a gps_rtk struct on a channel
  201. *
  202. * @param system_id ID of this system
  203. * @param component_id ID of this component (e.g. 200 for IMU)
  204. * @param chan The MAVLink channel this message will be sent over
  205. * @param msg The MAVLink message to compress the data into
  206. * @param gps_rtk C-struct to read the message contents from
  207. */
  208. static inline uint16_t mavlink_msg_gps_rtk_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_rtk_t* gps_rtk)
  209. {
  210. return mavlink_msg_gps_rtk_pack_chan(system_id, component_id, chan, msg, gps_rtk->time_last_baseline_ms, gps_rtk->rtk_receiver_id, gps_rtk->wn, gps_rtk->tow, gps_rtk->rtk_health, gps_rtk->rtk_rate, gps_rtk->nsats, gps_rtk->baseline_coords_type, gps_rtk->baseline_a_mm, gps_rtk->baseline_b_mm, gps_rtk->baseline_c_mm, gps_rtk->accuracy, gps_rtk->iar_num_hypotheses);
  211. }
  212. /**
  213. * @brief Send a gps_rtk message
  214. * @param chan MAVLink channel to send the message
  215. *
  216. * @param time_last_baseline_ms [ms] Time since boot of last baseline message received.
  217. * @param rtk_receiver_id Identification of connected RTK receiver.
  218. * @param wn GPS Week Number of last baseline
  219. * @param tow [ms] GPS Time of Week of last baseline
  220. * @param rtk_health GPS-specific health report for RTK data.
  221. * @param rtk_rate [Hz] Rate of baseline messages being received by GPS
  222. * @param nsats Current number of sats used for RTK calculation.
  223. * @param baseline_coords_type Coordinate system of baseline
  224. * @param baseline_a_mm [mm] Current baseline in ECEF x or NED north component.
  225. * @param baseline_b_mm [mm] Current baseline in ECEF y or NED east component.
  226. * @param baseline_c_mm [mm] Current baseline in ECEF z or NED down component.
  227. * @param accuracy Current estimate of baseline accuracy.
  228. * @param iar_num_hypotheses Current number of integer ambiguity hypotheses.
  229. */
  230. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  231. static inline void mavlink_msg_gps_rtk_send(mavlink_channel_t chan, uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses)
  232. {
  233. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  234. char buf[MAVLINK_MSG_ID_GPS_RTK_LEN];
  235. _mav_put_uint32_t(buf, 0, time_last_baseline_ms);
  236. _mav_put_uint32_t(buf, 4, tow);
  237. _mav_put_int32_t(buf, 8, baseline_a_mm);
  238. _mav_put_int32_t(buf, 12, baseline_b_mm);
  239. _mav_put_int32_t(buf, 16, baseline_c_mm);
  240. _mav_put_uint32_t(buf, 20, accuracy);
  241. _mav_put_int32_t(buf, 24, iar_num_hypotheses);
  242. _mav_put_uint16_t(buf, 28, wn);
  243. _mav_put_uint8_t(buf, 30, rtk_receiver_id);
  244. _mav_put_uint8_t(buf, 31, rtk_health);
  245. _mav_put_uint8_t(buf, 32, rtk_rate);
  246. _mav_put_uint8_t(buf, 33, nsats);
  247. _mav_put_uint8_t(buf, 34, baseline_coords_type);
  248. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTK, buf, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  249. #else
  250. mavlink_gps_rtk_t packet;
  251. packet.time_last_baseline_ms = time_last_baseline_ms;
  252. packet.tow = tow;
  253. packet.baseline_a_mm = baseline_a_mm;
  254. packet.baseline_b_mm = baseline_b_mm;
  255. packet.baseline_c_mm = baseline_c_mm;
  256. packet.accuracy = accuracy;
  257. packet.iar_num_hypotheses = iar_num_hypotheses;
  258. packet.wn = wn;
  259. packet.rtk_receiver_id = rtk_receiver_id;
  260. packet.rtk_health = rtk_health;
  261. packet.rtk_rate = rtk_rate;
  262. packet.nsats = nsats;
  263. packet.baseline_coords_type = baseline_coords_type;
  264. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTK, (const char *)&packet, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  265. #endif
  266. }
  267. /**
  268. * @brief Send a gps_rtk message
  269. * @param chan MAVLink channel to send the message
  270. * @param struct The MAVLink struct to serialize
  271. */
  272. static inline void mavlink_msg_gps_rtk_send_struct(mavlink_channel_t chan, const mavlink_gps_rtk_t* gps_rtk)
  273. {
  274. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  275. mavlink_msg_gps_rtk_send(chan, gps_rtk->time_last_baseline_ms, gps_rtk->rtk_receiver_id, gps_rtk->wn, gps_rtk->tow, gps_rtk->rtk_health, gps_rtk->rtk_rate, gps_rtk->nsats, gps_rtk->baseline_coords_type, gps_rtk->baseline_a_mm, gps_rtk->baseline_b_mm, gps_rtk->baseline_c_mm, gps_rtk->accuracy, gps_rtk->iar_num_hypotheses);
  276. #else
  277. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTK, (const char *)gps_rtk, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  278. #endif
  279. }
  280. #if MAVLINK_MSG_ID_GPS_RTK_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  281. /*
  282. This varient of _send() can be used to save stack space by re-using
  283. memory from the receive buffer. The caller provides a
  284. mavlink_message_t which is the size of a full mavlink message. This
  285. is usually the receive buffer for the channel, and allows a reply to an
  286. incoming message with minimum stack space usage.
  287. */
  288. static inline void mavlink_msg_gps_rtk_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_last_baseline_ms, uint8_t rtk_receiver_id, uint16_t wn, uint32_t tow, uint8_t rtk_health, uint8_t rtk_rate, uint8_t nsats, uint8_t baseline_coords_type, int32_t baseline_a_mm, int32_t baseline_b_mm, int32_t baseline_c_mm, uint32_t accuracy, int32_t iar_num_hypotheses)
  289. {
  290. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  291. char *buf = (char *)msgbuf;
  292. _mav_put_uint32_t(buf, 0, time_last_baseline_ms);
  293. _mav_put_uint32_t(buf, 4, tow);
  294. _mav_put_int32_t(buf, 8, baseline_a_mm);
  295. _mav_put_int32_t(buf, 12, baseline_b_mm);
  296. _mav_put_int32_t(buf, 16, baseline_c_mm);
  297. _mav_put_uint32_t(buf, 20, accuracy);
  298. _mav_put_int32_t(buf, 24, iar_num_hypotheses);
  299. _mav_put_uint16_t(buf, 28, wn);
  300. _mav_put_uint8_t(buf, 30, rtk_receiver_id);
  301. _mav_put_uint8_t(buf, 31, rtk_health);
  302. _mav_put_uint8_t(buf, 32, rtk_rate);
  303. _mav_put_uint8_t(buf, 33, nsats);
  304. _mav_put_uint8_t(buf, 34, baseline_coords_type);
  305. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTK, buf, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  306. #else
  307. mavlink_gps_rtk_t *packet = (mavlink_gps_rtk_t *)msgbuf;
  308. packet->time_last_baseline_ms = time_last_baseline_ms;
  309. packet->tow = tow;
  310. packet->baseline_a_mm = baseline_a_mm;
  311. packet->baseline_b_mm = baseline_b_mm;
  312. packet->baseline_c_mm = baseline_c_mm;
  313. packet->accuracy = accuracy;
  314. packet->iar_num_hypotheses = iar_num_hypotheses;
  315. packet->wn = wn;
  316. packet->rtk_receiver_id = rtk_receiver_id;
  317. packet->rtk_health = rtk_health;
  318. packet->rtk_rate = rtk_rate;
  319. packet->nsats = nsats;
  320. packet->baseline_coords_type = baseline_coords_type;
  321. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTK, (const char *)packet, MAVLINK_MSG_ID_GPS_RTK_MIN_LEN, MAVLINK_MSG_ID_GPS_RTK_LEN, MAVLINK_MSG_ID_GPS_RTK_CRC);
  322. #endif
  323. }
  324. #endif
  325. #endif
  326. // MESSAGE GPS_RTK UNPACKING
  327. /**
  328. * @brief Get field time_last_baseline_ms from gps_rtk message
  329. *
  330. * @return [ms] Time since boot of last baseline message received.
  331. */
  332. static inline uint32_t mavlink_msg_gps_rtk_get_time_last_baseline_ms(const mavlink_message_t* msg)
  333. {
  334. return _MAV_RETURN_uint32_t(msg, 0);
  335. }
  336. /**
  337. * @brief Get field rtk_receiver_id from gps_rtk message
  338. *
  339. * @return Identification of connected RTK receiver.
  340. */
  341. static inline uint8_t mavlink_msg_gps_rtk_get_rtk_receiver_id(const mavlink_message_t* msg)
  342. {
  343. return _MAV_RETURN_uint8_t(msg, 30);
  344. }
  345. /**
  346. * @brief Get field wn from gps_rtk message
  347. *
  348. * @return GPS Week Number of last baseline
  349. */
  350. static inline uint16_t mavlink_msg_gps_rtk_get_wn(const mavlink_message_t* msg)
  351. {
  352. return _MAV_RETURN_uint16_t(msg, 28);
  353. }
  354. /**
  355. * @brief Get field tow from gps_rtk message
  356. *
  357. * @return [ms] GPS Time of Week of last baseline
  358. */
  359. static inline uint32_t mavlink_msg_gps_rtk_get_tow(const mavlink_message_t* msg)
  360. {
  361. return _MAV_RETURN_uint32_t(msg, 4);
  362. }
  363. /**
  364. * @brief Get field rtk_health from gps_rtk message
  365. *
  366. * @return GPS-specific health report for RTK data.
  367. */
  368. static inline uint8_t mavlink_msg_gps_rtk_get_rtk_health(const mavlink_message_t* msg)
  369. {
  370. return _MAV_RETURN_uint8_t(msg, 31);
  371. }
  372. /**
  373. * @brief Get field rtk_rate from gps_rtk message
  374. *
  375. * @return [Hz] Rate of baseline messages being received by GPS
  376. */
  377. static inline uint8_t mavlink_msg_gps_rtk_get_rtk_rate(const mavlink_message_t* msg)
  378. {
  379. return _MAV_RETURN_uint8_t(msg, 32);
  380. }
  381. /**
  382. * @brief Get field nsats from gps_rtk message
  383. *
  384. * @return Current number of sats used for RTK calculation.
  385. */
  386. static inline uint8_t mavlink_msg_gps_rtk_get_nsats(const mavlink_message_t* msg)
  387. {
  388. return _MAV_RETURN_uint8_t(msg, 33);
  389. }
  390. /**
  391. * @brief Get field baseline_coords_type from gps_rtk message
  392. *
  393. * @return Coordinate system of baseline
  394. */
  395. static inline uint8_t mavlink_msg_gps_rtk_get_baseline_coords_type(const mavlink_message_t* msg)
  396. {
  397. return _MAV_RETURN_uint8_t(msg, 34);
  398. }
  399. /**
  400. * @brief Get field baseline_a_mm from gps_rtk message
  401. *
  402. * @return [mm] Current baseline in ECEF x or NED north component.
  403. */
  404. static inline int32_t mavlink_msg_gps_rtk_get_baseline_a_mm(const mavlink_message_t* msg)
  405. {
  406. return _MAV_RETURN_int32_t(msg, 8);
  407. }
  408. /**
  409. * @brief Get field baseline_b_mm from gps_rtk message
  410. *
  411. * @return [mm] Current baseline in ECEF y or NED east component.
  412. */
  413. static inline int32_t mavlink_msg_gps_rtk_get_baseline_b_mm(const mavlink_message_t* msg)
  414. {
  415. return _MAV_RETURN_int32_t(msg, 12);
  416. }
  417. /**
  418. * @brief Get field baseline_c_mm from gps_rtk message
  419. *
  420. * @return [mm] Current baseline in ECEF z or NED down component.
  421. */
  422. static inline int32_t mavlink_msg_gps_rtk_get_baseline_c_mm(const mavlink_message_t* msg)
  423. {
  424. return _MAV_RETURN_int32_t(msg, 16);
  425. }
  426. /**
  427. * @brief Get field accuracy from gps_rtk message
  428. *
  429. * @return Current estimate of baseline accuracy.
  430. */
  431. static inline uint32_t mavlink_msg_gps_rtk_get_accuracy(const mavlink_message_t* msg)
  432. {
  433. return _MAV_RETURN_uint32_t(msg, 20);
  434. }
  435. /**
  436. * @brief Get field iar_num_hypotheses from gps_rtk message
  437. *
  438. * @return Current number of integer ambiguity hypotheses.
  439. */
  440. static inline int32_t mavlink_msg_gps_rtk_get_iar_num_hypotheses(const mavlink_message_t* msg)
  441. {
  442. return _MAV_RETURN_int32_t(msg, 24);
  443. }
  444. /**
  445. * @brief Decode a gps_rtk message into a struct
  446. *
  447. * @param msg The message to decode
  448. * @param gps_rtk C-struct to decode the message contents into
  449. */
  450. static inline void mavlink_msg_gps_rtk_decode(const mavlink_message_t* msg, mavlink_gps_rtk_t* gps_rtk)
  451. {
  452. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  453. gps_rtk->time_last_baseline_ms = mavlink_msg_gps_rtk_get_time_last_baseline_ms(msg);
  454. gps_rtk->tow = mavlink_msg_gps_rtk_get_tow(msg);
  455. gps_rtk->baseline_a_mm = mavlink_msg_gps_rtk_get_baseline_a_mm(msg);
  456. gps_rtk->baseline_b_mm = mavlink_msg_gps_rtk_get_baseline_b_mm(msg);
  457. gps_rtk->baseline_c_mm = mavlink_msg_gps_rtk_get_baseline_c_mm(msg);
  458. gps_rtk->accuracy = mavlink_msg_gps_rtk_get_accuracy(msg);
  459. gps_rtk->iar_num_hypotheses = mavlink_msg_gps_rtk_get_iar_num_hypotheses(msg);
  460. gps_rtk->wn = mavlink_msg_gps_rtk_get_wn(msg);
  461. gps_rtk->rtk_receiver_id = mavlink_msg_gps_rtk_get_rtk_receiver_id(msg);
  462. gps_rtk->rtk_health = mavlink_msg_gps_rtk_get_rtk_health(msg);
  463. gps_rtk->rtk_rate = mavlink_msg_gps_rtk_get_rtk_rate(msg);
  464. gps_rtk->nsats = mavlink_msg_gps_rtk_get_nsats(msg);
  465. gps_rtk->baseline_coords_type = mavlink_msg_gps_rtk_get_baseline_coords_type(msg);
  466. #else
  467. uint8_t len = msg->len < MAVLINK_MSG_ID_GPS_RTK_LEN? msg->len : MAVLINK_MSG_ID_GPS_RTK_LEN;
  468. memset(gps_rtk, 0, MAVLINK_MSG_ID_GPS_RTK_LEN);
  469. memcpy(gps_rtk, _MAV_PAYLOAD(msg), len);
  470. #endif
  471. }