RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
mavlink_msg_simstate.h
1#pragma once
2// MESSAGE SIMSTATE PACKING
3
4#define MAVLINK_MSG_ID_SIMSTATE 164
5
6MAVPACKED(
7typedef struct __mavlink_simstate_t {
8 float roll; /*< Roll angle (rad)*/
9 float pitch; /*< Pitch angle (rad)*/
10 float yaw; /*< Yaw angle (rad)*/
11 float xacc; /*< X acceleration m/s/s*/
12 float yacc; /*< Y acceleration m/s/s*/
13 float zacc; /*< Z acceleration m/s/s*/
14 float xgyro; /*< Angular speed around X axis rad/s*/
15 float ygyro; /*< Angular speed around Y axis rad/s*/
16 float zgyro; /*< Angular speed around Z axis rad/s*/
17 int32_t lat; /*< Latitude in degrees * 1E7*/
18 int32_t lng; /*< Longitude in degrees * 1E7*/
19}) mavlink_simstate_t;
20
21#define MAVLINK_MSG_ID_SIMSTATE_LEN 44
22#define MAVLINK_MSG_ID_SIMSTATE_MIN_LEN 44
23#define MAVLINK_MSG_ID_164_LEN 44
24#define MAVLINK_MSG_ID_164_MIN_LEN 44
25
26#define MAVLINK_MSG_ID_SIMSTATE_CRC 154
27#define MAVLINK_MSG_ID_164_CRC 154
28
29
30
31#if MAVLINK_COMMAND_24BIT
32#define MAVLINK_MESSAGE_INFO_SIMSTATE { \
33 164, \
34 "SIMSTATE", \
35 11, \
36 { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_simstate_t, roll) }, \
37 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_simstate_t, pitch) }, \
38 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_simstate_t, yaw) }, \
39 { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_simstate_t, xacc) }, \
40 { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_simstate_t, yacc) }, \
41 { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_simstate_t, zacc) }, \
42 { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_simstate_t, xgyro) }, \
43 { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_simstate_t, ygyro) }, \
44 { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_simstate_t, zgyro) }, \
45 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_simstate_t, lat) }, \
46 { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_simstate_t, lng) }, \
47 } \
48}
49#else
50#define MAVLINK_MESSAGE_INFO_SIMSTATE { \
51 "SIMSTATE", \
52 11, \
53 { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_simstate_t, roll) }, \
54 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_simstate_t, pitch) }, \
55 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_simstate_t, yaw) }, \
56 { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_simstate_t, xacc) }, \
57 { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_simstate_t, yacc) }, \
58 { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_simstate_t, zacc) }, \
59 { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_simstate_t, xgyro) }, \
60 { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_simstate_t, ygyro) }, \
61 { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_simstate_t, zgyro) }, \
62 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_simstate_t, lat) }, \
63 { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_simstate_t, lng) }, \
64 } \
65}
66#endif
67
68/**
69 * @brief Pack a simstate message
70 * @param system_id ID of this system
71 * @param component_id ID of this component (e.g. 200 for IMU)
72 * @param msg The MAVLink message to compress the data into
73 *
74 * @param roll Roll angle (rad)
75 * @param pitch Pitch angle (rad)
76 * @param yaw Yaw angle (rad)
77 * @param xacc X acceleration m/s/s
78 * @param yacc Y acceleration m/s/s
79 * @param zacc Z acceleration m/s/s
80 * @param xgyro Angular speed around X axis rad/s
81 * @param ygyro Angular speed around Y axis rad/s
82 * @param zgyro Angular speed around Z axis rad/s
83 * @param lat Latitude in degrees * 1E7
84 * @param lng Longitude in degrees * 1E7
85 * @return length of the message in bytes (excluding serial stream start sign)
86 */
87static inline uint16_t mavlink_msg_simstate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
88 float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, int32_t lat, int32_t lng)
89{
90#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
91 char buf[MAVLINK_MSG_ID_SIMSTATE_LEN];
92 _mav_put_float(buf, 0, roll);
93 _mav_put_float(buf, 4, pitch);
94 _mav_put_float(buf, 8, yaw);
95 _mav_put_float(buf, 12, xacc);
96 _mav_put_float(buf, 16, yacc);
97 _mav_put_float(buf, 20, zacc);
98 _mav_put_float(buf, 24, xgyro);
99 _mav_put_float(buf, 28, ygyro);
100 _mav_put_float(buf, 32, zgyro);
101 _mav_put_int32_t(buf, 36, lat);
102 _mav_put_int32_t(buf, 40, lng);
103
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIMSTATE_LEN);
105#else
106 mavlink_simstate_t packet;
107 packet.roll = roll;
108 packet.pitch = pitch;
109 packet.yaw = yaw;
110 packet.xacc = xacc;
111 packet.yacc = yacc;
112 packet.zacc = zacc;
113 packet.xgyro = xgyro;
114 packet.ygyro = ygyro;
115 packet.zgyro = zgyro;
116 packet.lat = lat;
117 packet.lng = lng;
118
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIMSTATE_LEN);
120#endif
121
122 msg->msgid = MAVLINK_MSG_ID_SIMSTATE;
123 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
124}
125
126/**
127 * @brief Pack a simstate message on a channel
128 * @param system_id ID of this system
129 * @param component_id ID of this component (e.g. 200 for IMU)
130 * @param chan The MAVLink channel this message will be sent over
131 * @param msg The MAVLink message to compress the data into
132 * @param roll Roll angle (rad)
133 * @param pitch Pitch angle (rad)
134 * @param yaw Yaw angle (rad)
135 * @param xacc X acceleration m/s/s
136 * @param yacc Y acceleration m/s/s
137 * @param zacc Z acceleration m/s/s
138 * @param xgyro Angular speed around X axis rad/s
139 * @param ygyro Angular speed around Y axis rad/s
140 * @param zgyro Angular speed around Z axis rad/s
141 * @param lat Latitude in degrees * 1E7
142 * @param lng Longitude in degrees * 1E7
143 * @return length of the message in bytes (excluding serial stream start sign)
144 */
145static inline uint16_t mavlink_msg_simstate_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
146 mavlink_message_t* msg,
147 float roll,float pitch,float yaw,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,int32_t lat,int32_t lng)
148{
149#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
150 char buf[MAVLINK_MSG_ID_SIMSTATE_LEN];
151 _mav_put_float(buf, 0, roll);
152 _mav_put_float(buf, 4, pitch);
153 _mav_put_float(buf, 8, yaw);
154 _mav_put_float(buf, 12, xacc);
155 _mav_put_float(buf, 16, yacc);
156 _mav_put_float(buf, 20, zacc);
157 _mav_put_float(buf, 24, xgyro);
158 _mav_put_float(buf, 28, ygyro);
159 _mav_put_float(buf, 32, zgyro);
160 _mav_put_int32_t(buf, 36, lat);
161 _mav_put_int32_t(buf, 40, lng);
162
163 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SIMSTATE_LEN);
164#else
165 mavlink_simstate_t packet;
166 packet.roll = roll;
167 packet.pitch = pitch;
168 packet.yaw = yaw;
169 packet.xacc = xacc;
170 packet.yacc = yacc;
171 packet.zacc = zacc;
172 packet.xgyro = xgyro;
173 packet.ygyro = ygyro;
174 packet.zgyro = zgyro;
175 packet.lat = lat;
176 packet.lng = lng;
177
178 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SIMSTATE_LEN);
179#endif
180
181 msg->msgid = MAVLINK_MSG_ID_SIMSTATE;
182 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
183}
184
185/**
186 * @brief Encode a simstate struct
187 *
188 * @param system_id ID of this system
189 * @param component_id ID of this component (e.g. 200 for IMU)
190 * @param msg The MAVLink message to compress the data into
191 * @param simstate C-struct to read the message contents from
192 */
193static inline uint16_t mavlink_msg_simstate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_simstate_t* simstate)
194{
195 return mavlink_msg_simstate_pack(system_id, component_id, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng);
196}
197
198/**
199 * @brief Encode a simstate struct on a channel
200 *
201 * @param system_id ID of this system
202 * @param component_id ID of this component (e.g. 200 for IMU)
203 * @param chan The MAVLink channel this message will be sent over
204 * @param msg The MAVLink message to compress the data into
205 * @param simstate C-struct to read the message contents from
206 */
207static inline uint16_t mavlink_msg_simstate_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_simstate_t* simstate)
208{
209 return mavlink_msg_simstate_pack_chan(system_id, component_id, chan, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng);
210}
211
212/**
213 * @brief Send a simstate message
214 * @param chan MAVLink channel to send the message
215 *
216 * @param roll Roll angle (rad)
217 * @param pitch Pitch angle (rad)
218 * @param yaw Yaw angle (rad)
219 * @param xacc X acceleration m/s/s
220 * @param yacc Y acceleration m/s/s
221 * @param zacc Z acceleration m/s/s
222 * @param xgyro Angular speed around X axis rad/s
223 * @param ygyro Angular speed around Y axis rad/s
224 * @param zgyro Angular speed around Z axis rad/s
225 * @param lat Latitude in degrees * 1E7
226 * @param lng Longitude in degrees * 1E7
227 */
228#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
229
230static inline void mavlink_msg_simstate_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, int32_t lat, int32_t lng)
231{
232#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
233 char buf[MAVLINK_MSG_ID_SIMSTATE_LEN];
234 _mav_put_float(buf, 0, roll);
235 _mav_put_float(buf, 4, pitch);
236 _mav_put_float(buf, 8, yaw);
237 _mav_put_float(buf, 12, xacc);
238 _mav_put_float(buf, 16, yacc);
239 _mav_put_float(buf, 20, zacc);
240 _mav_put_float(buf, 24, xgyro);
241 _mav_put_float(buf, 28, ygyro);
242 _mav_put_float(buf, 32, zgyro);
243 _mav_put_int32_t(buf, 36, lat);
244 _mav_put_int32_t(buf, 40, lng);
245
246 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
247#else
248 mavlink_simstate_t packet;
249 packet.roll = roll;
250 packet.pitch = pitch;
251 packet.yaw = yaw;
252 packet.xacc = xacc;
253 packet.yacc = yacc;
254 packet.zacc = zacc;
255 packet.xgyro = xgyro;
256 packet.ygyro = ygyro;
257 packet.zgyro = zgyro;
258 packet.lat = lat;
259 packet.lng = lng;
260
261 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)&packet, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
262#endif
263}
264
265/**
266 * @brief Send a simstate message
267 * @param chan MAVLink channel to send the message
268 * @param struct The MAVLink struct to serialize
269 */
270static inline void mavlink_msg_simstate_send_struct(mavlink_channel_t chan, const mavlink_simstate_t* simstate)
271{
272#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
273 mavlink_msg_simstate_send(chan, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng);
274#else
275 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)simstate, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
276#endif
277}
278
279#if MAVLINK_MSG_ID_SIMSTATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
280/*
281 This varient of _send() can be used to save stack space by re-using
282 memory from the receive buffer. The caller provides a
283 mavlink_message_t which is the size of a full mavlink message. This
284 is usually the receive buffer for the channel, and allows a reply to an
285 incoming message with minimum stack space usage.
286 */
287static inline void mavlink_msg_simstate_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, int32_t lat, int32_t lng)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 char *buf = (char *)msgbuf;
291 _mav_put_float(buf, 0, roll);
292 _mav_put_float(buf, 4, pitch);
293 _mav_put_float(buf, 8, yaw);
294 _mav_put_float(buf, 12, xacc);
295 _mav_put_float(buf, 16, yacc);
296 _mav_put_float(buf, 20, zacc);
297 _mav_put_float(buf, 24, xgyro);
298 _mav_put_float(buf, 28, ygyro);
299 _mav_put_float(buf, 32, zgyro);
300 _mav_put_int32_t(buf, 36, lat);
301 _mav_put_int32_t(buf, 40, lng);
302
303 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
304#else
305 mavlink_simstate_t *packet = (mavlink_simstate_t *)msgbuf;
306 packet->roll = roll;
307 packet->pitch = pitch;
308 packet->yaw = yaw;
309 packet->xacc = xacc;
310 packet->yacc = yacc;
311 packet->zacc = zacc;
312 packet->xgyro = xgyro;
313 packet->ygyro = ygyro;
314 packet->zgyro = zgyro;
315 packet->lat = lat;
316 packet->lng = lng;
317
318 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)packet, MAVLINK_MSG_ID_SIMSTATE_MIN_LEN, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
319#endif
320}
321#endif
322
323#endif
324
325// MESSAGE SIMSTATE UNPACKING
326
327
328/**
329 * @brief Get field roll from simstate message
330 *
331 * @return Roll angle (rad)
332 */
333static inline float mavlink_msg_simstate_get_roll(const mavlink_message_t* msg)
334{
335 return _MAV_RETURN_float(msg, 0);
336}
337
338/**
339 * @brief Get field pitch from simstate message
340 *
341 * @return Pitch angle (rad)
342 */
343static inline float mavlink_msg_simstate_get_pitch(const mavlink_message_t* msg)
344{
345 return _MAV_RETURN_float(msg, 4);
346}
347
348/**
349 * @brief Get field yaw from simstate message
350 *
351 * @return Yaw angle (rad)
352 */
353static inline float mavlink_msg_simstate_get_yaw(const mavlink_message_t* msg)
354{
355 return _MAV_RETURN_float(msg, 8);
356}
357
358/**
359 * @brief Get field xacc from simstate message
360 *
361 * @return X acceleration m/s/s
362 */
363static inline float mavlink_msg_simstate_get_xacc(const mavlink_message_t* msg)
364{
365 return _MAV_RETURN_float(msg, 12);
366}
367
368/**
369 * @brief Get field yacc from simstate message
370 *
371 * @return Y acceleration m/s/s
372 */
373static inline float mavlink_msg_simstate_get_yacc(const mavlink_message_t* msg)
374{
375 return _MAV_RETURN_float(msg, 16);
376}
377
378/**
379 * @brief Get field zacc from simstate message
380 *
381 * @return Z acceleration m/s/s
382 */
383static inline float mavlink_msg_simstate_get_zacc(const mavlink_message_t* msg)
384{
385 return _MAV_RETURN_float(msg, 20);
386}
387
388/**
389 * @brief Get field xgyro from simstate message
390 *
391 * @return Angular speed around X axis rad/s
392 */
393static inline float mavlink_msg_simstate_get_xgyro(const mavlink_message_t* msg)
394{
395 return _MAV_RETURN_float(msg, 24);
396}
397
398/**
399 * @brief Get field ygyro from simstate message
400 *
401 * @return Angular speed around Y axis rad/s
402 */
403static inline float mavlink_msg_simstate_get_ygyro(const mavlink_message_t* msg)
404{
405 return _MAV_RETURN_float(msg, 28);
406}
407
408/**
409 * @brief Get field zgyro from simstate message
410 *
411 * @return Angular speed around Z axis rad/s
412 */
413static inline float mavlink_msg_simstate_get_zgyro(const mavlink_message_t* msg)
414{
415 return _MAV_RETURN_float(msg, 32);
416}
417
418/**
419 * @brief Get field lat from simstate message
420 *
421 * @return Latitude in degrees * 1E7
422 */
423static inline int32_t mavlink_msg_simstate_get_lat(const mavlink_message_t* msg)
424{
425 return _MAV_RETURN_int32_t(msg, 36);
426}
427
428/**
429 * @brief Get field lng from simstate message
430 *
431 * @return Longitude in degrees * 1E7
432 */
433static inline int32_t mavlink_msg_simstate_get_lng(const mavlink_message_t* msg)
434{
435 return _MAV_RETURN_int32_t(msg, 40);
436}
437
438/**
439 * @brief Decode a simstate message into a struct
440 *
441 * @param msg The message to decode
442 * @param simstate C-struct to decode the message contents into
443 */
444static inline void mavlink_msg_simstate_decode(const mavlink_message_t* msg, mavlink_simstate_t* simstate)
445{
446#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
447 simstate->roll = mavlink_msg_simstate_get_roll(msg);
448 simstate->pitch = mavlink_msg_simstate_get_pitch(msg);
449 simstate->yaw = mavlink_msg_simstate_get_yaw(msg);
450 simstate->xacc = mavlink_msg_simstate_get_xacc(msg);
451 simstate->yacc = mavlink_msg_simstate_get_yacc(msg);
452 simstate->zacc = mavlink_msg_simstate_get_zacc(msg);
453 simstate->xgyro = mavlink_msg_simstate_get_xgyro(msg);
454 simstate->ygyro = mavlink_msg_simstate_get_ygyro(msg);
455 simstate->zgyro = mavlink_msg_simstate_get_zgyro(msg);
456 simstate->lat = mavlink_msg_simstate_get_lat(msg);
457 simstate->lng = mavlink_msg_simstate_get_lng(msg);
458#else
459 uint8_t len = msg->len < MAVLINK_MSG_ID_SIMSTATE_LEN? msg->len : MAVLINK_MSG_ID_SIMSTATE_LEN;
460 memset(simstate, 0, MAVLINK_MSG_ID_SIMSTATE_LEN);
461 memcpy(simstate, _MAV_PAYLOAD(msg), len);
462#endif
463}