/libs/mavlink/include/mavlink/v1.0/common/mavlink_msg_terrain_report.h

https://gitlab.com/fsgdez/apm_planner · C Header · 353 lines · 208 code · 36 blank · 109 comment · 4 complexity · 285454310a53608d28c7adaf80c04297 MD5 · raw file

  1. // MESSAGE TERRAIN_REPORT PACKING
  2. #define MAVLINK_MSG_ID_TERRAIN_REPORT 136
  3. typedef struct __mavlink_terrain_report_t
  4. {
  5. int32_t lat; ///< Latitude (degrees *10^7)
  6. int32_t lon; ///< Longitude (degrees *10^7)
  7. float terrain_height; ///< Terrain height in meters AMSL
  8. float current_height; ///< Current vehicle height above lat/lon terrain height (meters)
  9. uint16_t spacing; ///< grid spacing (zero if terrain at this location unavailable)
  10. uint16_t pending; ///< Number of 4x4 terrain blocks waiting to be received or read from disk
  11. uint16_t loaded; ///< Number of 4x4 terrain blocks in memory
  12. } mavlink_terrain_report_t;
  13. #define MAVLINK_MSG_ID_TERRAIN_REPORT_LEN 22
  14. #define MAVLINK_MSG_ID_136_LEN 22
  15. #define MAVLINK_MSG_ID_TERRAIN_REPORT_CRC 1
  16. #define MAVLINK_MSG_ID_136_CRC 1
  17. #define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT { \
  18. "TERRAIN_REPORT", \
  19. 7, \
  20. { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) }, \
  21. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) }, \
  22. { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) }, \
  23. { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) }, \
  24. { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) }, \
  25. { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) }, \
  26. { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) }, \
  27. } \
  28. }
  29. /**
  30. * @brief Pack a terrain_report message
  31. * @param system_id ID of this system
  32. * @param component_id ID of this component (e.g. 200 for IMU)
  33. * @param msg The MAVLink message to compress the data into
  34. *
  35. * @param lat Latitude (degrees *10^7)
  36. * @param lon Longitude (degrees *10^7)
  37. * @param spacing grid spacing (zero if terrain at this location unavailable)
  38. * @param terrain_height Terrain height in meters AMSL
  39. * @param current_height Current vehicle height above lat/lon terrain height (meters)
  40. * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
  41. * @param loaded Number of 4x4 terrain blocks in memory
  42. * @return length of the message in bytes (excluding serial stream start sign)
  43. */
  44. static inline uint16_t mavlink_msg_terrain_report_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  45. int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
  46. {
  47. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  48. char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
  49. _mav_put_int32_t(buf, 0, lat);
  50. _mav_put_int32_t(buf, 4, lon);
  51. _mav_put_float(buf, 8, terrain_height);
  52. _mav_put_float(buf, 12, current_height);
  53. _mav_put_uint16_t(buf, 16, spacing);
  54. _mav_put_uint16_t(buf, 18, pending);
  55. _mav_put_uint16_t(buf, 20, loaded);
  56. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  57. #else
  58. mavlink_terrain_report_t packet;
  59. packet.lat = lat;
  60. packet.lon = lon;
  61. packet.terrain_height = terrain_height;
  62. packet.current_height = current_height;
  63. packet.spacing = spacing;
  64. packet.pending = pending;
  65. packet.loaded = loaded;
  66. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  67. #endif
  68. msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
  69. #if MAVLINK_CRC_EXTRA
  70. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  71. #else
  72. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  73. #endif
  74. }
  75. /**
  76. * @brief Pack a terrain_report message on a channel
  77. * @param system_id ID of this system
  78. * @param component_id ID of this component (e.g. 200 for IMU)
  79. * @param chan The MAVLink channel this message will be sent over
  80. * @param msg The MAVLink message to compress the data into
  81. * @param lat Latitude (degrees *10^7)
  82. * @param lon Longitude (degrees *10^7)
  83. * @param spacing grid spacing (zero if terrain at this location unavailable)
  84. * @param terrain_height Terrain height in meters AMSL
  85. * @param current_height Current vehicle height above lat/lon terrain height (meters)
  86. * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
  87. * @param loaded Number of 4x4 terrain blocks in memory
  88. * @return length of the message in bytes (excluding serial stream start sign)
  89. */
  90. static inline uint16_t mavlink_msg_terrain_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  91. mavlink_message_t* msg,
  92. int32_t lat,int32_t lon,uint16_t spacing,float terrain_height,float current_height,uint16_t pending,uint16_t loaded)
  93. {
  94. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  95. char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
  96. _mav_put_int32_t(buf, 0, lat);
  97. _mav_put_int32_t(buf, 4, lon);
  98. _mav_put_float(buf, 8, terrain_height);
  99. _mav_put_float(buf, 12, current_height);
  100. _mav_put_uint16_t(buf, 16, spacing);
  101. _mav_put_uint16_t(buf, 18, pending);
  102. _mav_put_uint16_t(buf, 20, loaded);
  103. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  104. #else
  105. mavlink_terrain_report_t packet;
  106. packet.lat = lat;
  107. packet.lon = lon;
  108. packet.terrain_height = terrain_height;
  109. packet.current_height = current_height;
  110. packet.spacing = spacing;
  111. packet.pending = pending;
  112. packet.loaded = loaded;
  113. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  114. #endif
  115. msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
  116. #if MAVLINK_CRC_EXTRA
  117. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  118. #else
  119. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  120. #endif
  121. }
  122. /**
  123. * @brief Encode a terrain_report struct
  124. *
  125. * @param system_id ID of this system
  126. * @param component_id ID of this component (e.g. 200 for IMU)
  127. * @param msg The MAVLink message to compress the data into
  128. * @param terrain_report C-struct to read the message contents from
  129. */
  130. static inline uint16_t mavlink_msg_terrain_report_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report)
  131. {
  132. return mavlink_msg_terrain_report_pack(system_id, component_id, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
  133. }
  134. /**
  135. * @brief Encode a terrain_report struct on a channel
  136. *
  137. * @param system_id ID of this system
  138. * @param component_id ID of this component (e.g. 200 for IMU)
  139. * @param chan The MAVLink channel this message will be sent over
  140. * @param msg The MAVLink message to compress the data into
  141. * @param terrain_report C-struct to read the message contents from
  142. */
  143. static inline uint16_t mavlink_msg_terrain_report_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report)
  144. {
  145. return mavlink_msg_terrain_report_pack_chan(system_id, component_id, chan, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
  146. }
  147. /**
  148. * @brief Send a terrain_report message
  149. * @param chan MAVLink channel to send the message
  150. *
  151. * @param lat Latitude (degrees *10^7)
  152. * @param lon Longitude (degrees *10^7)
  153. * @param spacing grid spacing (zero if terrain at this location unavailable)
  154. * @param terrain_height Terrain height in meters AMSL
  155. * @param current_height Current vehicle height above lat/lon terrain height (meters)
  156. * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
  157. * @param loaded Number of 4x4 terrain blocks in memory
  158. */
  159. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  160. static inline void mavlink_msg_terrain_report_send(mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
  161. {
  162. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  163. char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
  164. _mav_put_int32_t(buf, 0, lat);
  165. _mav_put_int32_t(buf, 4, lon);
  166. _mav_put_float(buf, 8, terrain_height);
  167. _mav_put_float(buf, 12, current_height);
  168. _mav_put_uint16_t(buf, 16, spacing);
  169. _mav_put_uint16_t(buf, 18, pending);
  170. _mav_put_uint16_t(buf, 20, loaded);
  171. #if MAVLINK_CRC_EXTRA
  172. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  173. #else
  174. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  175. #endif
  176. #else
  177. mavlink_terrain_report_t packet;
  178. packet.lat = lat;
  179. packet.lon = lon;
  180. packet.terrain_height = terrain_height;
  181. packet.current_height = current_height;
  182. packet.spacing = spacing;
  183. packet.pending = pending;
  184. packet.loaded = loaded;
  185. #if MAVLINK_CRC_EXTRA
  186. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  187. #else
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  189. #endif
  190. #endif
  191. }
  192. #if MAVLINK_MSG_ID_TERRAIN_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  193. /*
  194. This varient of _send() can be used to save stack space by re-using
  195. memory from the receive buffer. The caller provides a
  196. mavlink_message_t which is the size of a full mavlink message. This
  197. is usually the receive buffer for the channel, and allows a reply to an
  198. incoming message with minimum stack space usage.
  199. */
  200. static inline void mavlink_msg_terrain_report_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
  201. {
  202. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  203. char *buf = (char *)msgbuf;
  204. _mav_put_int32_t(buf, 0, lat);
  205. _mav_put_int32_t(buf, 4, lon);
  206. _mav_put_float(buf, 8, terrain_height);
  207. _mav_put_float(buf, 12, current_height);
  208. _mav_put_uint16_t(buf, 16, spacing);
  209. _mav_put_uint16_t(buf, 18, pending);
  210. _mav_put_uint16_t(buf, 20, loaded);
  211. #if MAVLINK_CRC_EXTRA
  212. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  213. #else
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  215. #endif
  216. #else
  217. mavlink_terrain_report_t *packet = (mavlink_terrain_report_t *)msgbuf;
  218. packet->lat = lat;
  219. packet->lon = lon;
  220. packet->terrain_height = terrain_height;
  221. packet->current_height = current_height;
  222. packet->spacing = spacing;
  223. packet->pending = pending;
  224. packet->loaded = loaded;
  225. #if MAVLINK_CRC_EXTRA
  226. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
  227. #else
  228. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  229. #endif
  230. #endif
  231. }
  232. #endif
  233. #endif
  234. // MESSAGE TERRAIN_REPORT UNPACKING
  235. /**
  236. * @brief Get field lat from terrain_report message
  237. *
  238. * @return Latitude (degrees *10^7)
  239. */
  240. static inline int32_t mavlink_msg_terrain_report_get_lat(const mavlink_message_t* msg)
  241. {
  242. return _MAV_RETURN_int32_t(msg, 0);
  243. }
  244. /**
  245. * @brief Get field lon from terrain_report message
  246. *
  247. * @return Longitude (degrees *10^7)
  248. */
  249. static inline int32_t mavlink_msg_terrain_report_get_lon(const mavlink_message_t* msg)
  250. {
  251. return _MAV_RETURN_int32_t(msg, 4);
  252. }
  253. /**
  254. * @brief Get field spacing from terrain_report message
  255. *
  256. * @return grid spacing (zero if terrain at this location unavailable)
  257. */
  258. static inline uint16_t mavlink_msg_terrain_report_get_spacing(const mavlink_message_t* msg)
  259. {
  260. return _MAV_RETURN_uint16_t(msg, 16);
  261. }
  262. /**
  263. * @brief Get field terrain_height from terrain_report message
  264. *
  265. * @return Terrain height in meters AMSL
  266. */
  267. static inline float mavlink_msg_terrain_report_get_terrain_height(const mavlink_message_t* msg)
  268. {
  269. return _MAV_RETURN_float(msg, 8);
  270. }
  271. /**
  272. * @brief Get field current_height from terrain_report message
  273. *
  274. * @return Current vehicle height above lat/lon terrain height (meters)
  275. */
  276. static inline float mavlink_msg_terrain_report_get_current_height(const mavlink_message_t* msg)
  277. {
  278. return _MAV_RETURN_float(msg, 12);
  279. }
  280. /**
  281. * @brief Get field pending from terrain_report message
  282. *
  283. * @return Number of 4x4 terrain blocks waiting to be received or read from disk
  284. */
  285. static inline uint16_t mavlink_msg_terrain_report_get_pending(const mavlink_message_t* msg)
  286. {
  287. return _MAV_RETURN_uint16_t(msg, 18);
  288. }
  289. /**
  290. * @brief Get field loaded from terrain_report message
  291. *
  292. * @return Number of 4x4 terrain blocks in memory
  293. */
  294. static inline uint16_t mavlink_msg_terrain_report_get_loaded(const mavlink_message_t* msg)
  295. {
  296. return _MAV_RETURN_uint16_t(msg, 20);
  297. }
  298. /**
  299. * @brief Decode a terrain_report message into a struct
  300. *
  301. * @param msg The message to decode
  302. * @param terrain_report C-struct to decode the message contents into
  303. */
  304. static inline void mavlink_msg_terrain_report_decode(const mavlink_message_t* msg, mavlink_terrain_report_t* terrain_report)
  305. {
  306. #if MAVLINK_NEED_BYTE_SWAP
  307. terrain_report->lat = mavlink_msg_terrain_report_get_lat(msg);
  308. terrain_report->lon = mavlink_msg_terrain_report_get_lon(msg);
  309. terrain_report->terrain_height = mavlink_msg_terrain_report_get_terrain_height(msg);
  310. terrain_report->current_height = mavlink_msg_terrain_report_get_current_height(msg);
  311. terrain_report->spacing = mavlink_msg_terrain_report_get_spacing(msg);
  312. terrain_report->pending = mavlink_msg_terrain_report_get_pending(msg);
  313. terrain_report->loaded = mavlink_msg_terrain_report_get_loaded(msg);
  314. #else
  315. memcpy(terrain_report, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
  316. #endif
  317. }