NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_simstate.h
Go to the documentation of this file.
1 // MESSAGE SIMSTATE PACKING
2 
3 #define MAVLINK_MSG_ID_SIMSTATE 164
4 
5 typedef struct __mavlink_simstate_t
6 {
7  float roll;
8  float pitch;
9  float yaw;
10  float xacc;
11  float yacc;
12  float zacc;
13  float xgyro;
14  float ygyro;
15  float zgyro;
16  int32_t lat;
17  int32_t lng;
19 
20 #define MAVLINK_MSG_ID_SIMSTATE_LEN 44
21 #define MAVLINK_MSG_ID_164_LEN 44
22 
23 #define MAVLINK_MSG_ID_SIMSTATE_CRC 154
24 #define MAVLINK_MSG_ID_164_CRC 154
25 
26 
27 
28 #define MAVLINK_MESSAGE_INFO_SIMSTATE { \
29  "SIMSTATE", \
30  11, \
31  { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_simstate_t, roll) }, \
32  { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_simstate_t, pitch) }, \
33  { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_simstate_t, yaw) }, \
34  { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_simstate_t, xacc) }, \
35  { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_simstate_t, yacc) }, \
36  { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_simstate_t, zacc) }, \
37  { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_simstate_t, xgyro) }, \
38  { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_simstate_t, ygyro) }, \
39  { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_simstate_t, zgyro) }, \
40  { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_simstate_t, lat) }, \
41  { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_simstate_t, lng) }, \
42  } \
43 }
44 
45 
65 static inline uint16_t mavlink_msg_simstate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
66  float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, int32_t lat, int32_t lng)
67 {
68 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
70  _mav_put_float(buf, 0, roll);
71  _mav_put_float(buf, 4, pitch);
72  _mav_put_float(buf, 8, yaw);
73  _mav_put_float(buf, 12, xacc);
74  _mav_put_float(buf, 16, yacc);
75  _mav_put_float(buf, 20, zacc);
76  _mav_put_float(buf, 24, xgyro);
77  _mav_put_float(buf, 28, ygyro);
78  _mav_put_float(buf, 32, zgyro);
79  _mav_put_int32_t(buf, 36, lat);
80  _mav_put_int32_t(buf, 40, lng);
81 
83 #else
84  mavlink_simstate_t packet;
85  packet.roll = roll;
86  packet.pitch = pitch;
87  packet.yaw = yaw;
88  packet.xacc = xacc;
89  packet.yacc = yacc;
90  packet.zacc = zacc;
91  packet.xgyro = xgyro;
92  packet.ygyro = ygyro;
93  packet.zgyro = zgyro;
94  packet.lat = lat;
95  packet.lng = lng;
96 
98 #endif
99 
100  msg->msgid = MAVLINK_MSG_ID_SIMSTATE;
101 #if MAVLINK_CRC_EXTRA
103 #else
104  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SIMSTATE_LEN);
105 #endif
106 }
107 
127 static inline uint16_t mavlink_msg_simstate_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
128  mavlink_message_t* msg,
129  float roll,float pitch,float yaw,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,int32_t lat,int32_t lng)
130 {
131 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
132  char buf[MAVLINK_MSG_ID_SIMSTATE_LEN];
133  _mav_put_float(buf, 0, roll);
134  _mav_put_float(buf, 4, pitch);
135  _mav_put_float(buf, 8, yaw);
136  _mav_put_float(buf, 12, xacc);
137  _mav_put_float(buf, 16, yacc);
138  _mav_put_float(buf, 20, zacc);
139  _mav_put_float(buf, 24, xgyro);
140  _mav_put_float(buf, 28, ygyro);
141  _mav_put_float(buf, 32, zgyro);
142  _mav_put_int32_t(buf, 36, lat);
143  _mav_put_int32_t(buf, 40, lng);
144 
146 #else
147  mavlink_simstate_t packet;
148  packet.roll = roll;
149  packet.pitch = pitch;
150  packet.yaw = yaw;
151  packet.xacc = xacc;
152  packet.yacc = yacc;
153  packet.zacc = zacc;
154  packet.xgyro = xgyro;
155  packet.ygyro = ygyro;
156  packet.zgyro = zgyro;
157  packet.lat = lat;
158  packet.lng = lng;
159 
161 #endif
162 
163  msg->msgid = MAVLINK_MSG_ID_SIMSTATE;
164 #if MAVLINK_CRC_EXTRA
166 #else
167  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SIMSTATE_LEN);
168 #endif
169 }
170 
179 static inline uint16_t mavlink_msg_simstate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_simstate_t* simstate)
180 {
181  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);
182 }
183 
193 static 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)
194 {
195  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);
196 }
197 
214 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
215 
216 static 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)
217 {
218 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
219  char buf[MAVLINK_MSG_ID_SIMSTATE_LEN];
220  _mav_put_float(buf, 0, roll);
221  _mav_put_float(buf, 4, pitch);
222  _mav_put_float(buf, 8, yaw);
223  _mav_put_float(buf, 12, xacc);
224  _mav_put_float(buf, 16, yacc);
225  _mav_put_float(buf, 20, zacc);
226  _mav_put_float(buf, 24, xgyro);
227  _mav_put_float(buf, 28, ygyro);
228  _mav_put_float(buf, 32, zgyro);
229  _mav_put_int32_t(buf, 36, lat);
230  _mav_put_int32_t(buf, 40, lng);
231 
232 #if MAVLINK_CRC_EXTRA
233  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
234 #else
235  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_LEN);
236 #endif
237 #else
238  mavlink_simstate_t packet;
239  packet.roll = roll;
240  packet.pitch = pitch;
241  packet.yaw = yaw;
242  packet.xacc = xacc;
243  packet.yacc = yacc;
244  packet.zacc = zacc;
245  packet.xgyro = xgyro;
246  packet.ygyro = ygyro;
247  packet.zgyro = zgyro;
248  packet.lat = lat;
249  packet.lng = lng;
250 
251 #if MAVLINK_CRC_EXTRA
252  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)&packet, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
253 #else
254  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)&packet, MAVLINK_MSG_ID_SIMSTATE_LEN);
255 #endif
256 #endif
257 }
258 
259 #if MAVLINK_MSG_ID_SIMSTATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
260 /*
261  This varient of _send() can be used to save stack space by re-using
262  memory from the receive buffer. The caller provides a
263  mavlink_message_t which is the size of a full mavlink message. This
264  is usually the receive buffer for the channel, and allows a reply to an
265  incoming message with minimum stack space usage.
266  */
267 static 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)
268 {
269 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
270  char *buf = (char *)msgbuf;
271  _mav_put_float(buf, 0, roll);
272  _mav_put_float(buf, 4, pitch);
273  _mav_put_float(buf, 8, yaw);
274  _mav_put_float(buf, 12, xacc);
275  _mav_put_float(buf, 16, yacc);
276  _mav_put_float(buf, 20, zacc);
277  _mav_put_float(buf, 24, xgyro);
278  _mav_put_float(buf, 28, ygyro);
279  _mav_put_float(buf, 32, zgyro);
280  _mav_put_int32_t(buf, 36, lat);
281  _mav_put_int32_t(buf, 40, lng);
282 
283 #if MAVLINK_CRC_EXTRA
284  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
285 #else
286  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, MAVLINK_MSG_ID_SIMSTATE_LEN);
287 #endif
288 #else
289  mavlink_simstate_t *packet = (mavlink_simstate_t *)msgbuf;
290  packet->roll = roll;
291  packet->pitch = pitch;
292  packet->yaw = yaw;
293  packet->xacc = xacc;
294  packet->yacc = yacc;
295  packet->zacc = zacc;
296  packet->xgyro = xgyro;
297  packet->ygyro = ygyro;
298  packet->zgyro = zgyro;
299  packet->lat = lat;
300  packet->lng = lng;
301 
302 #if MAVLINK_CRC_EXTRA
303  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)packet, MAVLINK_MSG_ID_SIMSTATE_LEN, MAVLINK_MSG_ID_SIMSTATE_CRC);
304 #else
305  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)packet, MAVLINK_MSG_ID_SIMSTATE_LEN);
306 #endif
307 #endif
308 }
309 #endif
310 
311 #endif
312 
313 // MESSAGE SIMSTATE UNPACKING
314 
315 
321 static inline float mavlink_msg_simstate_get_roll(const mavlink_message_t* msg)
322 {
323  return _MAV_RETURN_float(msg, 0);
324 }
325 
331 static inline float mavlink_msg_simstate_get_pitch(const mavlink_message_t* msg)
332 {
333  return _MAV_RETURN_float(msg, 4);
334 }
335 
341 static inline float mavlink_msg_simstate_get_yaw(const mavlink_message_t* msg)
342 {
343  return _MAV_RETURN_float(msg, 8);
344 }
345 
351 static inline float mavlink_msg_simstate_get_xacc(const mavlink_message_t* msg)
352 {
353  return _MAV_RETURN_float(msg, 12);
354 }
355 
361 static inline float mavlink_msg_simstate_get_yacc(const mavlink_message_t* msg)
362 {
363  return _MAV_RETURN_float(msg, 16);
364 }
365 
371 static inline float mavlink_msg_simstate_get_zacc(const mavlink_message_t* msg)
372 {
373  return _MAV_RETURN_float(msg, 20);
374 }
375 
381 static inline float mavlink_msg_simstate_get_xgyro(const mavlink_message_t* msg)
382 {
383  return _MAV_RETURN_float(msg, 24);
384 }
385 
391 static inline float mavlink_msg_simstate_get_ygyro(const mavlink_message_t* msg)
392 {
393  return _MAV_RETURN_float(msg, 28);
394 }
395 
401 static inline float mavlink_msg_simstate_get_zgyro(const mavlink_message_t* msg)
402 {
403  return _MAV_RETURN_float(msg, 32);
404 }
405 
411 static inline int32_t mavlink_msg_simstate_get_lat(const mavlink_message_t* msg)
412 {
413  return _MAV_RETURN_int32_t(msg, 36);
414 }
415 
421 static inline int32_t mavlink_msg_simstate_get_lng(const mavlink_message_t* msg)
422 {
423  return _MAV_RETURN_int32_t(msg, 40);
424 }
425 
432 static inline void mavlink_msg_simstate_decode(const mavlink_message_t* msg, mavlink_simstate_t* simstate)
433 {
434 #if MAVLINK_NEED_BYTE_SWAP
435  simstate->roll = mavlink_msg_simstate_get_roll(msg);
436  simstate->pitch = mavlink_msg_simstate_get_pitch(msg);
437  simstate->yaw = mavlink_msg_simstate_get_yaw(msg);
438  simstate->xacc = mavlink_msg_simstate_get_xacc(msg);
439  simstate->yacc = mavlink_msg_simstate_get_yacc(msg);
440  simstate->zacc = mavlink_msg_simstate_get_zacc(msg);
441  simstate->xgyro = mavlink_msg_simstate_get_xgyro(msg);
442  simstate->ygyro = mavlink_msg_simstate_get_ygyro(msg);
443  simstate->zgyro = mavlink_msg_simstate_get_zgyro(msg);
444  simstate->lat = mavlink_msg_simstate_get_lat(msg);
445  simstate->lng = mavlink_msg_simstate_get_lng(msg);
446 #else
447  memcpy(simstate, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_SIMSTATE_LEN);
448 #endif
449 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
#define _mav_put_int32_t(buf, wire_offset, b)
Definition: protocol.h:142
int16_t pitch
Definition: accelerometer.h:52
int16_t yaw
Definition: sensors.h:31
int16_t roll
Definition: accelerometer.h:51