Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_terrain_report.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE TERRAIN_REPORT PACKING
3
4#define MAVLINK_MSG_ID_TERRAIN_REPORT 136
5
6
8 int32_t lat; /*< [degE7] Latitude*/
9 int32_t lon; /*< [degE7] Longitude*/
10 float terrain_height; /*< [m] Terrain height MSL*/
11 float current_height; /*< [m] Current vehicle height above lat/lon terrain height*/
12 uint16_t spacing; /*< grid spacing (zero if terrain at this location unavailable)*/
13 uint16_t pending; /*< Number of 4x4 terrain blocks waiting to be received or read from disk*/
14 uint16_t loaded; /*< Number of 4x4 terrain blocks in memory*/
15} mavlink_terrain_report_t;
16
17#define MAVLINK_MSG_ID_TERRAIN_REPORT_LEN 22
18#define MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN 22
19#define MAVLINK_MSG_ID_136_LEN 22
20#define MAVLINK_MSG_ID_136_MIN_LEN 22
21
22#define MAVLINK_MSG_ID_TERRAIN_REPORT_CRC 1
23#define MAVLINK_MSG_ID_136_CRC 1
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT {
29 136,
30 "TERRAIN_REPORT",
31 7,
32 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) },
33 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) },
34 { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) },
35 { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) },
36 { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) },
37 { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) },
38 { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) },
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_TERRAIN_REPORT {
43 "TERRAIN_REPORT",
44 7,
45 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_report_t, lat) },
46 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_report_t, lon) },
47 { "spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_terrain_report_t, spacing) },
48 { "terrain_height", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_terrain_report_t, terrain_height) },
49 { "current_height", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_terrain_report_t, current_height) },
50 { "pending", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_terrain_report_t, pending) },
51 { "loaded", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_terrain_report_t, loaded) },
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a terrain_report message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
61 *
62 * @param lat [degE7] Latitude
63 * @param lon [degE7] Longitude
64 * @param spacing grid spacing (zero if terrain at this location unavailable)
65 * @param terrain_height [m] Terrain height MSL
66 * @param current_height [m] Current vehicle height above lat/lon terrain height
67 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
68 * @param loaded Number of 4x4 terrain blocks in memory
69 * @return length of the message in bytes (excluding serial stream start sign)
70 */
71static inline uint16_t mavlink_msg_terrain_report_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
76 _mav_put_int32_t(buf, 0, lat);
77 _mav_put_int32_t(buf, 4, lon);
78 _mav_put_float(buf, 8, terrain_height);
79 _mav_put_float(buf, 12, current_height);
80 _mav_put_uint16_t(buf, 16, spacing);
81 _mav_put_uint16_t(buf, 18, pending);
82 _mav_put_uint16_t(buf, 20, loaded);
83
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
85#else
86 mavlink_terrain_report_t packet;
87 packet.lat = lat;
88 packet.lon = lon;
89 packet.terrain_height = terrain_height;
90 packet.current_height = current_height;
91 packet.spacing = spacing;
92 packet.pending = pending;
93 packet.loaded = loaded;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
96#endif
97
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
100}
101
102/**
103 * @brief Pack a terrain_report message
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param status MAVLink status structure
107 * @param msg The MAVLink message to compress the data into
108 *
109 * @param lat [degE7] Latitude
110 * @param lon [degE7] Longitude
111 * @param spacing grid spacing (zero if terrain at this location unavailable)
112 * @param terrain_height [m] Terrain height MSL
113 * @param current_height [m] Current vehicle height above lat/lon terrain height
114 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
115 * @param loaded Number of 4x4 terrain blocks in memory
116 * @return length of the message in bytes (excluding serial stream start sign)
117 */
118static inline uint16_t mavlink_msg_terrain_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
119 int32_t lat, int32_t lon, uint16_t spacing, float terrain_height, float current_height, uint16_t pending, uint16_t loaded)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
123 _mav_put_int32_t(buf, 0, lat);
124 _mav_put_int32_t(buf, 4, lon);
125 _mav_put_float(buf, 8, terrain_height);
126 _mav_put_float(buf, 12, current_height);
127 _mav_put_uint16_t(buf, 16, spacing);
128 _mav_put_uint16_t(buf, 18, pending);
129 _mav_put_uint16_t(buf, 20, loaded);
130
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
132#else
133 mavlink_terrain_report_t packet;
134 packet.lat = lat;
135 packet.lon = lon;
136 packet.terrain_height = terrain_height;
137 packet.current_height = current_height;
138 packet.spacing = spacing;
139 packet.pending = pending;
140 packet.loaded = loaded;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
143#endif
144
146#if MAVLINK_CRC_EXTRA
147 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
148#else
149 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
150#endif
151}
152
153/**
154 * @brief Pack a terrain_report message on a channel
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param lat [degE7] Latitude
160 * @param lon [degE7] Longitude
161 * @param spacing grid spacing (zero if terrain at this location unavailable)
162 * @param terrain_height [m] Terrain height MSL
163 * @param current_height [m] Current vehicle height above lat/lon terrain height
164 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
165 * @param loaded Number of 4x4 terrain blocks in memory
166 * @return length of the message in bytes (excluding serial stream start sign)
167 */
168static inline uint16_t mavlink_msg_terrain_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
169 mavlink_message_t* msg,
170 int32_t lat,int32_t lon,uint16_t spacing,float terrain_height,float current_height,uint16_t pending,uint16_t loaded)
171{
172#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
174 _mav_put_int32_t(buf, 0, lat);
175 _mav_put_int32_t(buf, 4, lon);
176 _mav_put_float(buf, 8, terrain_height);
177 _mav_put_float(buf, 12, current_height);
178 _mav_put_uint16_t(buf, 16, spacing);
179 _mav_put_uint16_t(buf, 18, pending);
180 _mav_put_uint16_t(buf, 20, loaded);
181
182 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
183#else
184 mavlink_terrain_report_t packet;
185 packet.lat = lat;
186 packet.lon = lon;
187 packet.terrain_height = terrain_height;
188 packet.current_height = current_height;
189 packet.spacing = spacing;
190 packet.pending = pending;
191 packet.loaded = loaded;
192
193 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
194#endif
195
197 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
198}
199
200/**
201 * @brief Encode a terrain_report struct
202 *
203 * @param system_id ID of this system
204 * @param component_id ID of this component (e.g. 200 for IMU)
205 * @param msg The MAVLink message to compress the data into
206 * @param terrain_report C-struct to read the message contents from
207 */
208static 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)
209{
210 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);
211}
212
213/**
214 * @brief Encode a terrain_report struct on a channel
215 *
216 * @param system_id ID of this system
217 * @param component_id ID of this component (e.g. 200 for IMU)
218 * @param chan The MAVLink channel this message will be sent over
219 * @param msg The MAVLink message to compress the data into
220 * @param terrain_report C-struct to read the message contents from
221 */
222static 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)
223{
224 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);
225}
226
227/**
228 * @brief Encode a terrain_report struct with provided status structure
229 *
230 * @param system_id ID of this system
231 * @param component_id ID of this component (e.g. 200 for IMU)
232 * @param status MAVLink status structure
233 * @param msg The MAVLink message to compress the data into
234 * @param terrain_report C-struct to read the message contents from
235 */
236static inline uint16_t mavlink_msg_terrain_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_terrain_report_t* terrain_report)
237{
238 return mavlink_msg_terrain_report_pack_status(system_id, component_id, _status, msg, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
239}
240
241/**
242 * @brief Send a terrain_report message
243 * @param chan MAVLink channel to send the message
244 *
245 * @param lat [degE7] Latitude
246 * @param lon [degE7] Longitude
247 * @param spacing grid spacing (zero if terrain at this location unavailable)
248 * @param terrain_height [m] Terrain height MSL
249 * @param current_height [m] Current vehicle height above lat/lon terrain height
250 * @param pending Number of 4x4 terrain blocks waiting to be received or read from disk
251 * @param loaded Number of 4x4 terrain blocks in memory
252 */
253#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
254
255static 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)
256{
257#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
258 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
259 _mav_put_int32_t(buf, 0, lat);
260 _mav_put_int32_t(buf, 4, lon);
261 _mav_put_float(buf, 8, terrain_height);
262 _mav_put_float(buf, 12, current_height);
263 _mav_put_uint16_t(buf, 16, spacing);
264 _mav_put_uint16_t(buf, 18, pending);
265 _mav_put_uint16_t(buf, 20, loaded);
266
267 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
268#else
269 mavlink_terrain_report_t packet;
270 packet.lat = lat;
271 packet.lon = lon;
272 packet.terrain_height = terrain_height;
273 packet.current_height = current_height;
274 packet.spacing = spacing;
275 packet.pending = pending;
276 packet.loaded = loaded;
277
278 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
279#endif
280}
281
282/**
283 * @brief Send a terrain_report message
284 * @param chan MAVLink channel to send the message
285 * @param struct The MAVLink struct to serialize
286 */
287static inline void mavlink_msg_terrain_report_send_struct(mavlink_channel_t chan, const mavlink_terrain_report_t* terrain_report)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 mavlink_msg_terrain_report_send(chan, terrain_report->lat, terrain_report->lon, terrain_report->spacing, terrain_report->terrain_height, terrain_report->current_height, terrain_report->pending, terrain_report->loaded);
291#else
292 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)terrain_report, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
293#endif
294}
295
296#if MAVLINK_MSG_ID_TERRAIN_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
297/*
298 This variant of _send() can be used to save stack space by reusing
299 memory from the receive buffer. The caller provides a
300 mavlink_message_t which is the size of a full mavlink message. This
301 is usually the receive buffer for the channel, and allows a reply to an
302 incoming message with minimum stack space usage.
303 */
304static 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)
305{
306#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
307 char *buf = (char *)msgbuf;
308 _mav_put_int32_t(buf, 0, lat);
309 _mav_put_int32_t(buf, 4, lon);
310 _mav_put_float(buf, 8, terrain_height);
311 _mav_put_float(buf, 12, current_height);
312 _mav_put_uint16_t(buf, 16, spacing);
313 _mav_put_uint16_t(buf, 18, pending);
314 _mav_put_uint16_t(buf, 20, loaded);
315
316 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, buf, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
317#else
318 mavlink_terrain_report_t *packet = (mavlink_terrain_report_t *)msgbuf;
319 packet->lat = lat;
320 packet->lon = lon;
321 packet->terrain_height = terrain_height;
322 packet->current_height = current_height;
323 packet->spacing = spacing;
324 packet->pending = pending;
325 packet->loaded = loaded;
326
327 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_REPORT, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_REPORT_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN, MAVLINK_MSG_ID_TERRAIN_REPORT_CRC);
328#endif
329}
330#endif
331
332#endif
333
334// MESSAGE TERRAIN_REPORT UNPACKING
335
336
337/**
338 * @brief Get field lat from terrain_report message
339 *
340 * @return [degE7] Latitude
341 */
342static inline int32_t mavlink_msg_terrain_report_get_lat(const mavlink_message_t* msg)
343{
344 return _MAV_RETURN_int32_t(msg, 0);
345}
346
347/**
348 * @brief Get field lon from terrain_report message
349 *
350 * @return [degE7] Longitude
351 */
352static inline int32_t mavlink_msg_terrain_report_get_lon(const mavlink_message_t* msg)
353{
354 return _MAV_RETURN_int32_t(msg, 4);
355}
356
357/**
358 * @brief Get field spacing from terrain_report message
359 *
360 * @return grid spacing (zero if terrain at this location unavailable)
361 */
362static inline uint16_t mavlink_msg_terrain_report_get_spacing(const mavlink_message_t* msg)
363{
364 return _MAV_RETURN_uint16_t(msg, 16);
365}
366
367/**
368 * @brief Get field terrain_height from terrain_report message
369 *
370 * @return [m] Terrain height MSL
371 */
372static inline float mavlink_msg_terrain_report_get_terrain_height(const mavlink_message_t* msg)
373{
374 return _MAV_RETURN_float(msg, 8);
375}
376
377/**
378 * @brief Get field current_height from terrain_report message
379 *
380 * @return [m] Current vehicle height above lat/lon terrain height
381 */
382static inline float mavlink_msg_terrain_report_get_current_height(const mavlink_message_t* msg)
383{
384 return _MAV_RETURN_float(msg, 12);
385}
386
387/**
388 * @brief Get field pending from terrain_report message
389 *
390 * @return Number of 4x4 terrain blocks waiting to be received or read from disk
391 */
392static inline uint16_t mavlink_msg_terrain_report_get_pending(const mavlink_message_t* msg)
393{
394 return _MAV_RETURN_uint16_t(msg, 18);
395}
396
397/**
398 * @brief Get field loaded from terrain_report message
399 *
400 * @return Number of 4x4 terrain blocks in memory
401 */
402static inline uint16_t mavlink_msg_terrain_report_get_loaded(const mavlink_message_t* msg)
403{
404 return _MAV_RETURN_uint16_t(msg, 20);
405}
406
407/**
408 * @brief Decode a terrain_report message into a struct
409 *
410 * @param msg The message to decode
411 * @param terrain_report C-struct to decode the message contents into
412 */
413static inline void mavlink_msg_terrain_report_decode(const mavlink_message_t* msg, mavlink_terrain_report_t* terrain_report)
414{
415#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
416 terrain_report->lat = mavlink_msg_terrain_report_get_lat(msg);
417 terrain_report->lon = mavlink_msg_terrain_report_get_lon(msg);
418 terrain_report->terrain_height = mavlink_msg_terrain_report_get_terrain_height(msg);
419 terrain_report->current_height = mavlink_msg_terrain_report_get_current_height(msg);
420 terrain_report->spacing = mavlink_msg_terrain_report_get_spacing(msg);
421 terrain_report->pending = mavlink_msg_terrain_report_get_pending(msg);
422 terrain_report->loaded = mavlink_msg_terrain_report_get_loaded(msg);
423#else
424 uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_REPORT_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_REPORT_LEN;
425 memset(terrain_report, 0, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
426 memcpy(terrain_report, _MAV_PAYLOAD(msg), len);
427#endif
428}