RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_ahrs.h
1#pragma once
2// MESSAGE AHRS PACKING
3
4#define MAVLINK_MSG_ID_AHRS 163
5
6MAVPACKED(
7typedef struct __mavlink_ahrs_t {
8 float omegaIx; /*< X gyro drift estimate rad/s*/
9 float omegaIy; /*< Y gyro drift estimate rad/s*/
10 float omegaIz; /*< Z gyro drift estimate rad/s*/
11 float accel_weight; /*< average accel_weight*/
12 float renorm_val; /*< average renormalisation value*/
13 float error_rp; /*< average error_roll_pitch value*/
14 float error_yaw; /*< average error_yaw value*/
15}) mavlink_ahrs_t;
16
17#define MAVLINK_MSG_ID_AHRS_LEN 28
18#define MAVLINK_MSG_ID_AHRS_MIN_LEN 28
19#define MAVLINK_MSG_ID_163_LEN 28
20#define MAVLINK_MSG_ID_163_MIN_LEN 28
21
22#define MAVLINK_MSG_ID_AHRS_CRC 127
23#define MAVLINK_MSG_ID_163_CRC 127
24
25
26
27#if MAVLINK_COMMAND_24BIT
28#define MAVLINK_MESSAGE_INFO_AHRS { \
29 163, \
30 "AHRS", \
31 7, \
32 { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \
33 { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \
34 { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \
35 { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \
36 { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \
37 { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \
38 { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \
39 } \
40}
41#else
42#define MAVLINK_MESSAGE_INFO_AHRS { \
43 "AHRS", \
44 7, \
45 { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \
46 { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \
47 { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \
48 { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \
49 { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \
50 { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \
51 { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \
52 } \
53}
54#endif
55
56/**
57 * @brief Pack a ahrs 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 omegaIx X gyro drift estimate rad/s
63 * @param omegaIy Y gyro drift estimate rad/s
64 * @param omegaIz Z gyro drift estimate rad/s
65 * @param accel_weight average accel_weight
66 * @param renorm_val average renormalisation value
67 * @param error_rp average error_roll_pitch value
68 * @param error_yaw average error_yaw value
69 * @return length of the message in bytes (excluding serial stream start sign)
70 */
71static inline uint16_t mavlink_msg_ahrs_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_AHRS_LEN];
76 _mav_put_float(buf, 0, omegaIx);
77 _mav_put_float(buf, 4, omegaIy);
78 _mav_put_float(buf, 8, omegaIz);
79 _mav_put_float(buf, 12, accel_weight);
80 _mav_put_float(buf, 16, renorm_val);
81 _mav_put_float(buf, 20, error_rp);
82 _mav_put_float(buf, 24, error_yaw);
83
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS_LEN);
85#else
86 mavlink_ahrs_t packet;
87 packet.omegaIx = omegaIx;
88 packet.omegaIy = omegaIy;
89 packet.omegaIz = omegaIz;
90 packet.accel_weight = accel_weight;
91 packet.renorm_val = renorm_val;
92 packet.error_rp = error_rp;
93 packet.error_yaw = error_yaw;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS_LEN);
96#endif
97
98 msg->msgid = MAVLINK_MSG_ID_AHRS;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
100}
101
102/**
103 * @brief Pack a ahrs message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param omegaIx X gyro drift estimate rad/s
109 * @param omegaIy Y gyro drift estimate rad/s
110 * @param omegaIz Z gyro drift estimate rad/s
111 * @param accel_weight average accel_weight
112 * @param renorm_val average renormalisation value
113 * @param error_rp average error_roll_pitch value
114 * @param error_yaw average error_yaw value
115 * @return length of the message in bytes (excluding serial stream start sign)
116 */
117static inline uint16_t mavlink_msg_ahrs_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 float omegaIx,float omegaIy,float omegaIz,float accel_weight,float renorm_val,float error_rp,float error_yaw)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_AHRS_LEN];
123 _mav_put_float(buf, 0, omegaIx);
124 _mav_put_float(buf, 4, omegaIy);
125 _mav_put_float(buf, 8, omegaIz);
126 _mav_put_float(buf, 12, accel_weight);
127 _mav_put_float(buf, 16, renorm_val);
128 _mav_put_float(buf, 20, error_rp);
129 _mav_put_float(buf, 24, error_yaw);
130
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AHRS_LEN);
132#else
133 mavlink_ahrs_t packet;
134 packet.omegaIx = omegaIx;
135 packet.omegaIy = omegaIy;
136 packet.omegaIz = omegaIz;
137 packet.accel_weight = accel_weight;
138 packet.renorm_val = renorm_val;
139 packet.error_rp = error_rp;
140 packet.error_yaw = error_yaw;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS_LEN);
143#endif
144
145 msg->msgid = MAVLINK_MSG_ID_AHRS;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
147}
148
149/**
150 * @brief Encode a ahrs struct
151 *
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param ahrs C-struct to read the message contents from
156 */
157static inline uint16_t mavlink_msg_ahrs_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs)
158{
159 return mavlink_msg_ahrs_pack(system_id, component_id, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
160}
161
162/**
163 * @brief Encode a ahrs struct on a channel
164 *
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param ahrs C-struct to read the message contents from
170 */
171static inline uint16_t mavlink_msg_ahrs_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs)
172{
173 return mavlink_msg_ahrs_pack_chan(system_id, component_id, chan, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
174}
175
176/**
177 * @brief Send a ahrs message
178 * @param chan MAVLink channel to send the message
179 *
180 * @param omegaIx X gyro drift estimate rad/s
181 * @param omegaIy Y gyro drift estimate rad/s
182 * @param omegaIz Z gyro drift estimate rad/s
183 * @param accel_weight average accel_weight
184 * @param renorm_val average renormalisation value
185 * @param error_rp average error_roll_pitch value
186 * @param error_yaw average error_yaw value
187 */
188#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
189
190static inline void mavlink_msg_ahrs_send(mavlink_channel_t chan, float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
191{
192#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_AHRS_LEN];
194 _mav_put_float(buf, 0, omegaIx);
195 _mav_put_float(buf, 4, omegaIy);
196 _mav_put_float(buf, 8, omegaIz);
197 _mav_put_float(buf, 12, accel_weight);
198 _mav_put_float(buf, 16, renorm_val);
199 _mav_put_float(buf, 20, error_rp);
200 _mav_put_float(buf, 24, error_yaw);
201
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
203#else
204 mavlink_ahrs_t packet;
205 packet.omegaIx = omegaIx;
206 packet.omegaIy = omegaIy;
207 packet.omegaIz = omegaIz;
208 packet.accel_weight = accel_weight;
209 packet.renorm_val = renorm_val;
210 packet.error_rp = error_rp;
211 packet.error_yaw = error_yaw;
212
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)&packet, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
214#endif
215}
216
217/**
218 * @brief Send a ahrs message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
221 */
222static inline void mavlink_msg_ahrs_send_struct(mavlink_channel_t chan, const mavlink_ahrs_t* ahrs)
223{
224#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_ahrs_send(chan, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw);
226#else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)ahrs, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
228#endif
229}
230
231#if MAVLINK_MSG_ID_AHRS_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_ahrs_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw)
240{
241#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_float(buf, 0, omegaIx);
244 _mav_put_float(buf, 4, omegaIy);
245 _mav_put_float(buf, 8, omegaIz);
246 _mav_put_float(buf, 12, accel_weight);
247 _mav_put_float(buf, 16, renorm_val);
248 _mav_put_float(buf, 20, error_rp);
249 _mav_put_float(buf, 24, error_yaw);
250
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
252#else
253 mavlink_ahrs_t *packet = (mavlink_ahrs_t *)msgbuf;
254 packet->omegaIx = omegaIx;
255 packet->omegaIy = omegaIy;
256 packet->omegaIz = omegaIz;
257 packet->accel_weight = accel_weight;
258 packet->renorm_val = renorm_val;
259 packet->error_rp = error_rp;
260 packet->error_yaw = error_yaw;
261
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)packet, MAVLINK_MSG_ID_AHRS_MIN_LEN, MAVLINK_MSG_ID_AHRS_LEN, MAVLINK_MSG_ID_AHRS_CRC);
263#endif
264}
265#endif
266
267#endif
268
269// MESSAGE AHRS UNPACKING
270
271
272/**
273 * @brief Get field omegaIx from ahrs message
274 *
275 * @return X gyro drift estimate rad/s
276 */
277static inline float mavlink_msg_ahrs_get_omegaIx(const mavlink_message_t* msg)
278{
279 return _MAV_RETURN_float(msg, 0);
280}
281
282/**
283 * @brief Get field omegaIy from ahrs message
284 *
285 * @return Y gyro drift estimate rad/s
286 */
287static inline float mavlink_msg_ahrs_get_omegaIy(const mavlink_message_t* msg)
288{
289 return _MAV_RETURN_float(msg, 4);
290}
291
292/**
293 * @brief Get field omegaIz from ahrs message
294 *
295 * @return Z gyro drift estimate rad/s
296 */
297static inline float mavlink_msg_ahrs_get_omegaIz(const mavlink_message_t* msg)
298{
299 return _MAV_RETURN_float(msg, 8);
300}
301
302/**
303 * @brief Get field accel_weight from ahrs message
304 *
305 * @return average accel_weight
306 */
307static inline float mavlink_msg_ahrs_get_accel_weight(const mavlink_message_t* msg)
308{
309 return _MAV_RETURN_float(msg, 12);
310}
311
312/**
313 * @brief Get field renorm_val from ahrs message
314 *
315 * @return average renormalisation value
316 */
317static inline float mavlink_msg_ahrs_get_renorm_val(const mavlink_message_t* msg)
318{
319 return _MAV_RETURN_float(msg, 16);
320}
321
322/**
323 * @brief Get field error_rp from ahrs message
324 *
325 * @return average error_roll_pitch value
326 */
327static inline float mavlink_msg_ahrs_get_error_rp(const mavlink_message_t* msg)
328{
329 return _MAV_RETURN_float(msg, 20);
330}
331
332/**
333 * @brief Get field error_yaw from ahrs message
334 *
335 * @return average error_yaw value
336 */
337static inline float mavlink_msg_ahrs_get_error_yaw(const mavlink_message_t* msg)
338{
339 return _MAV_RETURN_float(msg, 24);
340}
341
342/**
343 * @brief Decode a ahrs message into a struct
344 *
345 * @param msg The message to decode
346 * @param ahrs C-struct to decode the message contents into
347 */
348static inline void mavlink_msg_ahrs_decode(const mavlink_message_t* msg, mavlink_ahrs_t* ahrs)
349{
350#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 ahrs->omegaIx = mavlink_msg_ahrs_get_omegaIx(msg);
352 ahrs->omegaIy = mavlink_msg_ahrs_get_omegaIy(msg);
353 ahrs->omegaIz = mavlink_msg_ahrs_get_omegaIz(msg);
354 ahrs->accel_weight = mavlink_msg_ahrs_get_accel_weight(msg);
355 ahrs->renorm_val = mavlink_msg_ahrs_get_renorm_val(msg);
356 ahrs->error_rp = mavlink_msg_ahrs_get_error_rp(msg);
357 ahrs->error_yaw = mavlink_msg_ahrs_get_error_yaw(msg);
358#else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_AHRS_LEN? msg->len : MAVLINK_MSG_ID_AHRS_LEN;
360 memset(ahrs, 0, MAVLINK_MSG_ID_AHRS_LEN);
361 memcpy(ahrs, _MAV_PAYLOAD(msg), len);
362#endif
363}