RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_ahrs2.h
1#pragma once
2// MESSAGE AHRS2 PACKING
3
4#define MAVLINK_MSG_ID_AHRS2 178
5
6MAVPACKED(
7typedef struct __mavlink_ahrs2_t {
8 float roll; /*< Roll angle (rad)*/
9 float pitch; /*< Pitch angle (rad)*/
10 float yaw; /*< Yaw angle (rad)*/
11 float altitude; /*< Altitude (MSL)*/
12 int32_t lat; /*< Latitude in degrees * 1E7*/
13 int32_t lng; /*< Longitude in degrees * 1E7*/
14}) mavlink_ahrs2_t;
15
16#define MAVLINK_MSG_ID_AHRS2_LEN 24
17#define MAVLINK_MSG_ID_AHRS2_MIN_LEN 24
18#define MAVLINK_MSG_ID_178_LEN 24
19#define MAVLINK_MSG_ID_178_MIN_LEN 24
20
21#define MAVLINK_MSG_ID_AHRS2_CRC 47
22#define MAVLINK_MSG_ID_178_CRC 47
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_AHRS2 { \
28 178, \
29 "AHRS2", \
30 6, \
31 { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs2_t, roll) }, \
32 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs2_t, pitch) }, \
33 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs2_t, yaw) }, \
34 { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs2_t, altitude) }, \
35 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_ahrs2_t, lat) }, \
36 { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_ahrs2_t, lng) }, \
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_AHRS2 { \
41 "AHRS2", \
42 6, \
43 { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs2_t, roll) }, \
44 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs2_t, pitch) }, \
45 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs2_t, yaw) }, \
46 { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs2_t, altitude) }, \
47 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_ahrs2_t, lat) }, \
48 { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_ahrs2_t, lng) }, \
49 } \
50}
51#endif
52
67static inline uint16_t mavlink_msg_ahrs2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
71 char buf[MAVLINK_MSG_ID_AHRS2_LEN];
72 _mav_put_float(buf, 0, roll);
73 _mav_put_float(buf, 4, pitch);
74 _mav_put_float(buf, 8, yaw);
75 _mav_put_float(buf, 12, altitude);
76 _mav_put_int32_t(buf, 16, lat);
77 _mav_put_int32_t(buf, 20, lng);
78
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS2_LEN);
80#else
81 mavlink_ahrs2_t packet;
82 packet.roll = roll;
83 packet.pitch = pitch;
84 packet.yaw = yaw;
85 packet.altitude = altitude;
86 packet.lat = lat;
87 packet.lng = lng;
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
90#endif
91
92 msg->msgid = MAVLINK_MSG_ID_AHRS2;
93 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
94}
95
110static inline uint16_t mavlink_msg_ahrs2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
111 mavlink_message_t* msg,
112 float roll,float pitch,float yaw,float altitude,int32_t lat,int32_t lng)
113{
114#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
115 char buf[MAVLINK_MSG_ID_AHRS2_LEN];
116 _mav_put_float(buf, 0, roll);
117 _mav_put_float(buf, 4, pitch);
118 _mav_put_float(buf, 8, yaw);
119 _mav_put_float(buf, 12, altitude);
120 _mav_put_int32_t(buf, 16, lat);
121 _mav_put_int32_t(buf, 20, lng);
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS2_LEN);
124#else
125 mavlink_ahrs2_t packet;
126 packet.roll = roll;
127 packet.pitch = pitch;
128 packet.yaw = yaw;
129 packet.altitude = altitude;
130 packet.lat = lat;
131 packet.lng = lng;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
134#endif
135
136 msg->msgid = MAVLINK_MSG_ID_AHRS2;
137 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
138}
139
148static inline uint16_t mavlink_msg_ahrs2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2)
149{
150 return mavlink_msg_ahrs2_pack(system_id, component_id, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
151}
152
162static inline uint16_t mavlink_msg_ahrs2_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2)
163{
164 return mavlink_msg_ahrs2_pack_chan(system_id, component_id, chan, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
165}
166
178#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
179
180static inline void mavlink_msg_ahrs2_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
181{
182#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 char buf[MAVLINK_MSG_ID_AHRS2_LEN];
184 _mav_put_float(buf, 0, roll);
185 _mav_put_float(buf, 4, pitch);
186 _mav_put_float(buf, 8, yaw);
187 _mav_put_float(buf, 12, altitude);
188 _mav_put_int32_t(buf, 16, lat);
189 _mav_put_int32_t(buf, 20, lng);
190
191 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
192#else
193 mavlink_ahrs2_t packet;
194 packet.roll = roll;
195 packet.pitch = pitch;
196 packet.yaw = yaw;
197 packet.altitude = altitude;
198 packet.lat = lat;
199 packet.lng = lng;
200
201 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)&packet, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
202#endif
203}
204
210static inline void mavlink_msg_ahrs2_send_struct(mavlink_channel_t chan, const mavlink_ahrs2_t* ahrs2)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 mavlink_msg_ahrs2_send(chan, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
214#else
215 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)ahrs2, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
216#endif
217}
218
219#if MAVLINK_MSG_ID_AHRS2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
220/*
221 This varient of _send() can be used to save stack space by re-using
222 memory from the receive buffer. The caller provides a
223 mavlink_message_t which is the size of a full mavlink message. This
224 is usually the receive buffer for the channel, and allows a reply to an
225 incoming message with minimum stack space usage.
226 */
227static inline void mavlink_msg_ahrs2_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
228{
229#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
230 char *buf = (char *)msgbuf;
231 _mav_put_float(buf, 0, roll);
232 _mav_put_float(buf, 4, pitch);
233 _mav_put_float(buf, 8, yaw);
234 _mav_put_float(buf, 12, altitude);
235 _mav_put_int32_t(buf, 16, lat);
236 _mav_put_int32_t(buf, 20, lng);
237
238 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
239#else
240 mavlink_ahrs2_t *packet = (mavlink_ahrs2_t *)msgbuf;
241 packet->roll = roll;
242 packet->pitch = pitch;
243 packet->yaw = yaw;
244 packet->altitude = altitude;
245 packet->lat = lat;
246 packet->lng = lng;
247
248 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)packet, MAVLINK_MSG_ID_AHRS2_MIN_LEN, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
249#endif
250}
251#endif
252
253#endif
254
255// MESSAGE AHRS2 UNPACKING
256
257
263static inline float mavlink_msg_ahrs2_get_roll(const mavlink_message_t* msg)
264{
265 return _MAV_RETURN_float(msg, 0);
266}
267
273static inline float mavlink_msg_ahrs2_get_pitch(const mavlink_message_t* msg)
274{
275 return _MAV_RETURN_float(msg, 4);
276}
277
283static inline float mavlink_msg_ahrs2_get_yaw(const mavlink_message_t* msg)
284{
285 return _MAV_RETURN_float(msg, 8);
286}
287
293static inline float mavlink_msg_ahrs2_get_altitude(const mavlink_message_t* msg)
294{
295 return _MAV_RETURN_float(msg, 12);
296}
297
303static inline int32_t mavlink_msg_ahrs2_get_lat(const mavlink_message_t* msg)
304{
305 return _MAV_RETURN_int32_t(msg, 16);
306}
307
313static inline int32_t mavlink_msg_ahrs2_get_lng(const mavlink_message_t* msg)
314{
315 return _MAV_RETURN_int32_t(msg, 20);
316}
317
324static inline void mavlink_msg_ahrs2_decode(const mavlink_message_t* msg, mavlink_ahrs2_t* ahrs2)
325{
326#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
327 ahrs2->roll = mavlink_msg_ahrs2_get_roll(msg);
328 ahrs2->pitch = mavlink_msg_ahrs2_get_pitch(msg);
329 ahrs2->yaw = mavlink_msg_ahrs2_get_yaw(msg);
330 ahrs2->altitude = mavlink_msg_ahrs2_get_altitude(msg);
331 ahrs2->lat = mavlink_msg_ahrs2_get_lat(msg);
332 ahrs2->lng = mavlink_msg_ahrs2_get_lng(msg);
333#else
334 uint8_t len = msg->len < MAVLINK_MSG_ID_AHRS2_LEN? msg->len : MAVLINK_MSG_ID_AHRS2_LEN;
335 memset(ahrs2, 0, MAVLINK_MSG_ID_AHRS2_LEN);
336 memcpy(ahrs2, _MAV_PAYLOAD(msg), len);
337#endif
338}