RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_terrain_report.h
1#pragma once
2// MESSAGE TERRAIN_REPORT PACKING
3
4#define MAVLINK_MSG_ID_TERRAIN_REPORT 136
5
6MAVPACKED(
7typedef struct __mavlink_terrain_report_t {
8 int32_t lat; /*< Latitude (degrees *10^7)*/
9 int32_t lon; /*< Longitude (degrees *10^7)*/
10 float terrain_height; /*< Terrain height in meters AMSL*/
11 float current_height; /*< Current vehicle height above lat/lon terrain height (meters)*/
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
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
75 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
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
98 msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
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
117static inline uint16_t mavlink_msg_terrain_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 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
122 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
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
145 msg->msgid = MAVLINK_MSG_ID_TERRAIN_REPORT;
146 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);
147}
148
157static 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)
158{
159 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);
160}
161
171static 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)
172{
173 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);
174}
175
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static 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)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_TERRAIN_REPORT_LEN];
194 _mav_put_int32_t(buf, 0, lat);
195 _mav_put_int32_t(buf, 4, lon);
196 _mav_put_float(buf, 8, terrain_height);
197 _mav_put_float(buf, 12, current_height);
198 _mav_put_uint16_t(buf, 16, spacing);
199 _mav_put_uint16_t(buf, 18, pending);
200 _mav_put_uint16_t(buf, 20, loaded);
201
202 _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);
203#else
204 mavlink_terrain_report_t packet;
205 packet.lat = lat;
206 packet.lon = lon;
207 packet.terrain_height = terrain_height;
208 packet.current_height = current_height;
209 packet.spacing = spacing;
210 packet.pending = pending;
211 packet.loaded = loaded;
212
213 _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);
214#endif
215}
216
222static inline void mavlink_msg_terrain_report_send_struct(mavlink_channel_t chan, const mavlink_terrain_report_t* terrain_report)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 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);
226#else
227 _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);
228#endif
229}
230
231#if MAVLINK_MSG_ID_TERRAIN_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
232/*
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
238 */
239static 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)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_int32_t(buf, 0, lat);
244 _mav_put_int32_t(buf, 4, lon);
245 _mav_put_float(buf, 8, terrain_height);
246 _mav_put_float(buf, 12, current_height);
247 _mav_put_uint16_t(buf, 16, spacing);
248 _mav_put_uint16_t(buf, 18, pending);
249 _mav_put_uint16_t(buf, 20, loaded);
250
251 _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);
252#else
253 mavlink_terrain_report_t *packet = (mavlink_terrain_report_t *)msgbuf;
254 packet->lat = lat;
255 packet->lon = lon;
256 packet->terrain_height = terrain_height;
257 packet->current_height = current_height;
258 packet->spacing = spacing;
259 packet->pending = pending;
260 packet->loaded = loaded;
261
262 _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);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE TERRAIN_REPORT UNPACKING
270
271
277static inline int32_t mavlink_msg_terrain_report_get_lat(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_int32_t(msg, 0);
280}
281
287static inline int32_t mavlink_msg_terrain_report_get_lon(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_int32_t(msg, 4);
290}
291
297static inline uint16_t mavlink_msg_terrain_report_get_spacing(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_uint16_t(msg, 16);
300}
301
307static inline float mavlink_msg_terrain_report_get_terrain_height(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_float(msg, 8);
310}
311
317static inline float mavlink_msg_terrain_report_get_current_height(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_float(msg, 12);
320}
321
327static inline uint16_t mavlink_msg_terrain_report_get_pending(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_uint16_t(msg, 18);
330}
331
337static inline uint16_t mavlink_msg_terrain_report_get_loaded(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_uint16_t(msg, 20);
340}
341
348static inline void mavlink_msg_terrain_report_decode(const mavlink_message_t* msg, mavlink_terrain_report_t* terrain_report)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 terrain_report->lat = mavlink_msg_terrain_report_get_lat(msg);
352 terrain_report->lon = mavlink_msg_terrain_report_get_lon(msg);
353 terrain_report->terrain_height = mavlink_msg_terrain_report_get_terrain_height(msg);
354 terrain_report->current_height = mavlink_msg_terrain_report_get_current_height(msg);
355 terrain_report->spacing = mavlink_msg_terrain_report_get_spacing(msg);
356 terrain_report->pending = mavlink_msg_terrain_report_get_pending(msg);
357 terrain_report->loaded = mavlink_msg_terrain_report_get_loaded(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_REPORT_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_REPORT_LEN;
360 memset(terrain_report, 0, MAVLINK_MSG_ID_TERRAIN_REPORT_LEN);
361 memcpy(terrain_report, _MAV_PAYLOAD(msg), len);
362#endif
363}