RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_terrain_data.h
1#pragma once
2// MESSAGE TERRAIN_DATA PACKING
3
4#define MAVLINK_MSG_ID_TERRAIN_DATA 134
5
6MAVPACKED(
7typedef struct __mavlink_terrain_data_t {
8 int32_t lat; /*< Latitude of SW corner of first grid (degrees *10^7)*/
9 int32_t lon; /*< Longitude of SW corner of first grid (in degrees *10^7)*/
10 uint16_t grid_spacing; /*< Grid spacing in meters*/
11 int16_t data[16]; /*< Terrain data in meters AMSL*/
12 uint8_t gridbit; /*< bit within the terrain request mask*/
13}) mavlink_terrain_data_t;
14
15#define MAVLINK_MSG_ID_TERRAIN_DATA_LEN 43
16#define MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN 43
17#define MAVLINK_MSG_ID_134_LEN 43
18#define MAVLINK_MSG_ID_134_MIN_LEN 43
19
20#define MAVLINK_MSG_ID_TERRAIN_DATA_CRC 229
21#define MAVLINK_MSG_ID_134_CRC 229
22
23#define MAVLINK_MSG_TERRAIN_DATA_FIELD_DATA_LEN 16
24
25#if MAVLINK_COMMAND_24BIT
26#define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
27 134, \
28 "TERRAIN_DATA", \
29 5, \
30 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
31 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
32 { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
33 { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
34 { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
35 } \
36}
37#else
38#define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
39 "TERRAIN_DATA", \
40 5, \
41 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
42 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
43 { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
44 { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
45 { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
46 } \
47}
48#endif
49
50/**
51 * @brief Pack a terrain_data message
52 * @param system_id ID of this system
53 * @param component_id ID of this component (e.g. 200 for IMU)
54 * @param msg The MAVLink message to compress the data into
55 *
56 * @param lat Latitude of SW corner of first grid (degrees *10^7)
57 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
58 * @param grid_spacing Grid spacing in meters
59 * @param gridbit bit within the terrain request mask
60 * @param data Terrain data in meters AMSL
61 * @return length of the message in bytes (excluding serial stream start sign)
62 */
63static inline uint16_t mavlink_msg_terrain_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
64 int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
65{
66#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
67 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
68 _mav_put_int32_t(buf, 0, lat);
69 _mav_put_int32_t(buf, 4, lon);
70 _mav_put_uint16_t(buf, 8, grid_spacing);
71 _mav_put_uint8_t(buf, 42, gridbit);
72 _mav_put_int16_t_array(buf, 10, data, 16);
73 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
74#else
75 mavlink_terrain_data_t packet;
76 packet.lat = lat;
77 packet.lon = lon;
78 packet.grid_spacing = grid_spacing;
79 packet.gridbit = gridbit;
80 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
81 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
82#endif
83
84 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
85 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
86}
87
88/**
89 * @brief Pack a terrain_data message on a channel
90 * @param system_id ID of this system
91 * @param component_id ID of this component (e.g. 200 for IMU)
92 * @param chan The MAVLink channel this message will be sent over
93 * @param msg The MAVLink message to compress the data into
94 * @param lat Latitude of SW corner of first grid (degrees *10^7)
95 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
96 * @param grid_spacing Grid spacing in meters
97 * @param gridbit bit within the terrain request mask
98 * @param data Terrain data in meters AMSL
99 * @return length of the message in bytes (excluding serial stream start sign)
100 */
101static inline uint16_t mavlink_msg_terrain_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
102 mavlink_message_t* msg,
103 int32_t lat,int32_t lon,uint16_t grid_spacing,uint8_t gridbit,const int16_t *data)
104{
105#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
106 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
107 _mav_put_int32_t(buf, 0, lat);
108 _mav_put_int32_t(buf, 4, lon);
109 _mav_put_uint16_t(buf, 8, grid_spacing);
110 _mav_put_uint8_t(buf, 42, gridbit);
111 _mav_put_int16_t_array(buf, 10, data, 16);
112 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
113#else
114 mavlink_terrain_data_t packet;
115 packet.lat = lat;
116 packet.lon = lon;
117 packet.grid_spacing = grid_spacing;
118 packet.gridbit = gridbit;
119 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
120 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
121#endif
122
123 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
124 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
125}
126
127/**
128 * @brief Encode a terrain_data struct
129 *
130 * @param system_id ID of this system
131 * @param component_id ID of this component (e.g. 200 for IMU)
132 * @param msg The MAVLink message to compress the data into
133 * @param terrain_data C-struct to read the message contents from
134 */
135static inline uint16_t mavlink_msg_terrain_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
136{
137 return mavlink_msg_terrain_data_pack(system_id, component_id, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
138}
139
140/**
141 * @brief Encode a terrain_data struct on a channel
142 *
143 * @param system_id ID of this system
144 * @param component_id ID of this component (e.g. 200 for IMU)
145 * @param chan The MAVLink channel this message will be sent over
146 * @param msg The MAVLink message to compress the data into
147 * @param terrain_data C-struct to read the message contents from
148 */
149static inline uint16_t mavlink_msg_terrain_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
150{
151 return mavlink_msg_terrain_data_pack_chan(system_id, component_id, chan, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
152}
153
154/**
155 * @brief Send a terrain_data message
156 * @param chan MAVLink channel to send the message
157 *
158 * @param lat Latitude of SW corner of first grid (degrees *10^7)
159 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
160 * @param grid_spacing Grid spacing in meters
161 * @param gridbit bit within the terrain request mask
162 * @param data Terrain data in meters AMSL
163 */
164#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
165
166static inline void mavlink_msg_terrain_data_send(mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
167{
168#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
169 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
170 _mav_put_int32_t(buf, 0, lat);
171 _mav_put_int32_t(buf, 4, lon);
172 _mav_put_uint16_t(buf, 8, grid_spacing);
173 _mav_put_uint8_t(buf, 42, gridbit);
174 _mav_put_int16_t_array(buf, 10, data, 16);
175 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
176#else
177 mavlink_terrain_data_t packet;
178 packet.lat = lat;
179 packet.lon = lon;
180 packet.grid_spacing = grid_spacing;
181 packet.gridbit = gridbit;
182 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
183 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
184#endif
185}
186
187/**
188 * @brief Send a terrain_data message
189 * @param chan MAVLink channel to send the message
190 * @param struct The MAVLink struct to serialize
191 */
192static inline void mavlink_msg_terrain_data_send_struct(mavlink_channel_t chan, const mavlink_terrain_data_t* terrain_data)
193{
194#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
195 mavlink_msg_terrain_data_send(chan, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
196#else
197 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)terrain_data, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
198#endif
199}
200
201#if MAVLINK_MSG_ID_TERRAIN_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
202/*
203 This varient of _send() can be used to save stack space by re-using
204 memory from the receive buffer. The caller provides a
205 mavlink_message_t which is the size of a full mavlink message. This
206 is usually the receive buffer for the channel, and allows a reply to an
207 incoming message with minimum stack space usage.
208 */
209static inline void mavlink_msg_terrain_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
210{
211#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
212 char *buf = (char *)msgbuf;
213 _mav_put_int32_t(buf, 0, lat);
214 _mav_put_int32_t(buf, 4, lon);
215 _mav_put_uint16_t(buf, 8, grid_spacing);
216 _mav_put_uint8_t(buf, 42, gridbit);
217 _mav_put_int16_t_array(buf, 10, data, 16);
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
219#else
220 mavlink_terrain_data_t *packet = (mavlink_terrain_data_t *)msgbuf;
221 packet->lat = lat;
222 packet->lon = lon;
223 packet->grid_spacing = grid_spacing;
224 packet->gridbit = gridbit;
225 mav_array_memcpy(packet->data, data, sizeof(int16_t)*16);
226 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_MIN_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
227#endif
228}
229#endif
230
231#endif
232
233// MESSAGE TERRAIN_DATA UNPACKING
234
235
236/**
237 * @brief Get field lat from terrain_data message
238 *
239 * @return Latitude of SW corner of first grid (degrees *10^7)
240 */
241static inline int32_t mavlink_msg_terrain_data_get_lat(const mavlink_message_t* msg)
242{
243 return _MAV_RETURN_int32_t(msg, 0);
244}
245
246/**
247 * @brief Get field lon from terrain_data message
248 *
249 * @return Longitude of SW corner of first grid (in degrees *10^7)
250 */
251static inline int32_t mavlink_msg_terrain_data_get_lon(const mavlink_message_t* msg)
252{
253 return _MAV_RETURN_int32_t(msg, 4);
254}
255
256/**
257 * @brief Get field grid_spacing from terrain_data message
258 *
259 * @return Grid spacing in meters
260 */
261static inline uint16_t mavlink_msg_terrain_data_get_grid_spacing(const mavlink_message_t* msg)
262{
263 return _MAV_RETURN_uint16_t(msg, 8);
264}
265
266/**
267 * @brief Get field gridbit from terrain_data message
268 *
269 * @return bit within the terrain request mask
270 */
271static inline uint8_t mavlink_msg_terrain_data_get_gridbit(const mavlink_message_t* msg)
272{
273 return _MAV_RETURN_uint8_t(msg, 42);
274}
275
276/**
277 * @brief Get field data from terrain_data message
278 *
279 * @return Terrain data in meters AMSL
280 */
281static inline uint16_t mavlink_msg_terrain_data_get_data(const mavlink_message_t* msg, int16_t *data)
282{
283 return _MAV_RETURN_int16_t_array(msg, data, 16, 10);
284}
285
286/**
287 * @brief Decode a terrain_data message into a struct
288 *
289 * @param msg The message to decode
290 * @param terrain_data C-struct to decode the message contents into
291 */
292static inline void mavlink_msg_terrain_data_decode(const mavlink_message_t* msg, mavlink_terrain_data_t* terrain_data)
293{
294#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
295 terrain_data->lat = mavlink_msg_terrain_data_get_lat(msg);
296 terrain_data->lon = mavlink_msg_terrain_data_get_lon(msg);
297 terrain_data->grid_spacing = mavlink_msg_terrain_data_get_grid_spacing(msg);
298 mavlink_msg_terrain_data_get_data(msg, terrain_data->data);
299 terrain_data->gridbit = mavlink_msg_terrain_data_get_gridbit(msg);
300#else
301 uint8_t len = msg->len < MAVLINK_MSG_ID_TERRAIN_DATA_LEN? msg->len : MAVLINK_MSG_ID_TERRAIN_DATA_LEN;
302 memset(terrain_data, 0, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
303 memcpy(terrain_data, _MAV_PAYLOAD(msg), len);
304#endif
305}