NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_ahrs2.h
Go to the documentation of this file.
1 // MESSAGE AHRS2 PACKING
2 
3 #define MAVLINK_MSG_ID_AHRS2 178
4 
5 typedef struct __mavlink_ahrs2_t
6 {
7  float roll;
8  float pitch;
9  float yaw;
10  float altitude;
11  int32_t lat;
12  int32_t lng;
14 
15 #define MAVLINK_MSG_ID_AHRS2_LEN 24
16 #define MAVLINK_MSG_ID_178_LEN 24
17 
18 #define MAVLINK_MSG_ID_AHRS2_CRC 47
19 #define MAVLINK_MSG_ID_178_CRC 47
20 
21 
22 
23 #define MAVLINK_MESSAGE_INFO_AHRS2 { \
24  "AHRS2", \
25  6, \
26  { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs2_t, roll) }, \
27  { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs2_t, pitch) }, \
28  { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs2_t, yaw) }, \
29  { "altitude", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs2_t, altitude) }, \
30  { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_ahrs2_t, lat) }, \
31  { "lng", NULL, MAVLINK_TYPE_INT32_T, 0, 20, offsetof(mavlink_ahrs2_t, lng) }, \
32  } \
33 }
34 
35 
50 static inline uint16_t mavlink_msg_ahrs2_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51  float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
52 {
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
54  char buf[MAVLINK_MSG_ID_AHRS2_LEN];
55  _mav_put_float(buf, 0, roll);
56  _mav_put_float(buf, 4, pitch);
57  _mav_put_float(buf, 8, yaw);
58  _mav_put_float(buf, 12, altitude);
59  _mav_put_int32_t(buf, 16, lat);
60  _mav_put_int32_t(buf, 20, lng);
61 
63 #else
64  mavlink_ahrs2_t packet;
65  packet.roll = roll;
66  packet.pitch = pitch;
67  packet.yaw = yaw;
68  packet.altitude = altitude;
69  packet.lat = lat;
70  packet.lng = lng;
71 
72  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
73 #endif
74 
75  msg->msgid = MAVLINK_MSG_ID_AHRS2;
76 #if MAVLINK_CRC_EXTRA
77  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
78 #else
79  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AHRS2_LEN);
80 #endif
81 }
82 
97 static inline uint16_t mavlink_msg_ahrs2_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
98  mavlink_message_t* msg,
99  float roll,float pitch,float yaw,float altitude,int32_t lat,int32_t lng)
100 {
101 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
102  char buf[MAVLINK_MSG_ID_AHRS2_LEN];
103  _mav_put_float(buf, 0, roll);
104  _mav_put_float(buf, 4, pitch);
105  _mav_put_float(buf, 8, yaw);
106  _mav_put_float(buf, 12, altitude);
107  _mav_put_int32_t(buf, 16, lat);
108  _mav_put_int32_t(buf, 20, lng);
109 
111 #else
112  mavlink_ahrs2_t packet;
113  packet.roll = roll;
114  packet.pitch = pitch;
115  packet.yaw = yaw;
116  packet.altitude = altitude;
117  packet.lat = lat;
118  packet.lng = lng;
119 
120  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AHRS2_LEN);
121 #endif
122 
123  msg->msgid = MAVLINK_MSG_ID_AHRS2;
124 #if MAVLINK_CRC_EXTRA
125  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
126 #else
127  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AHRS2_LEN);
128 #endif
129 }
130 
139 static inline uint16_t mavlink_msg_ahrs2_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs2_t* ahrs2)
140 {
141  return mavlink_msg_ahrs2_pack(system_id, component_id, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
142 }
143 
153 static 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)
154 {
155  return mavlink_msg_ahrs2_pack_chan(system_id, component_id, chan, msg, ahrs2->roll, ahrs2->pitch, ahrs2->yaw, ahrs2->altitude, ahrs2->lat, ahrs2->lng);
156 }
157 
169 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 
171 static inline void mavlink_msg_ahrs2_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float altitude, int32_t lat, int32_t lng)
172 {
173 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
174  char buf[MAVLINK_MSG_ID_AHRS2_LEN];
175  _mav_put_float(buf, 0, roll);
176  _mav_put_float(buf, 4, pitch);
177  _mav_put_float(buf, 8, yaw);
178  _mav_put_float(buf, 12, altitude);
179  _mav_put_int32_t(buf, 16, lat);
180  _mav_put_int32_t(buf, 20, lng);
181 
182 #if MAVLINK_CRC_EXTRA
183  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
184 #else
185  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_LEN);
186 #endif
187 #else
188  mavlink_ahrs2_t packet;
189  packet.roll = roll;
190  packet.pitch = pitch;
191  packet.yaw = yaw;
192  packet.altitude = altitude;
193  packet.lat = lat;
194  packet.lng = lng;
195 
196 #if MAVLINK_CRC_EXTRA
197  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)&packet, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
198 #else
199  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)&packet, MAVLINK_MSG_ID_AHRS2_LEN);
200 #endif
201 #endif
202 }
203 
204 #if MAVLINK_MSG_ID_AHRS2_LEN <= MAVLINK_MAX_PAYLOAD_LEN
205 /*
206  This varient of _send() can be used to save stack space by re-using
207  memory from the receive buffer. The caller provides a
208  mavlink_message_t which is the size of a full mavlink message. This
209  is usually the receive buffer for the channel, and allows a reply to an
210  incoming message with minimum stack space usage.
211  */
212 static 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)
213 {
214 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215  char *buf = (char *)msgbuf;
216  _mav_put_float(buf, 0, roll);
217  _mav_put_float(buf, 4, pitch);
218  _mav_put_float(buf, 8, yaw);
219  _mav_put_float(buf, 12, altitude);
220  _mav_put_int32_t(buf, 16, lat);
221  _mav_put_int32_t(buf, 20, lng);
222 
223 #if MAVLINK_CRC_EXTRA
224  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
225 #else
226  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, buf, MAVLINK_MSG_ID_AHRS2_LEN);
227 #endif
228 #else
229  mavlink_ahrs2_t *packet = (mavlink_ahrs2_t *)msgbuf;
230  packet->roll = roll;
231  packet->pitch = pitch;
232  packet->yaw = yaw;
233  packet->altitude = altitude;
234  packet->lat = lat;
235  packet->lng = lng;
236 
237 #if MAVLINK_CRC_EXTRA
238  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)packet, MAVLINK_MSG_ID_AHRS2_LEN, MAVLINK_MSG_ID_AHRS2_CRC);
239 #else
240  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS2, (const char *)packet, MAVLINK_MSG_ID_AHRS2_LEN);
241 #endif
242 #endif
243 }
244 #endif
245 
246 #endif
247 
248 // MESSAGE AHRS2 UNPACKING
249 
250 
256 static inline float mavlink_msg_ahrs2_get_roll(const mavlink_message_t* msg)
257 {
258  return _MAV_RETURN_float(msg, 0);
259 }
260 
266 static inline float mavlink_msg_ahrs2_get_pitch(const mavlink_message_t* msg)
267 {
268  return _MAV_RETURN_float(msg, 4);
269 }
270 
276 static inline float mavlink_msg_ahrs2_get_yaw(const mavlink_message_t* msg)
277 {
278  return _MAV_RETURN_float(msg, 8);
279 }
280 
286 static inline float mavlink_msg_ahrs2_get_altitude(const mavlink_message_t* msg)
287 {
288  return _MAV_RETURN_float(msg, 12);
289 }
290 
296 static inline int32_t mavlink_msg_ahrs2_get_lat(const mavlink_message_t* msg)
297 {
298  return _MAV_RETURN_int32_t(msg, 16);
299 }
300 
306 static inline int32_t mavlink_msg_ahrs2_get_lng(const mavlink_message_t* msg)
307 {
308  return _MAV_RETURN_int32_t(msg, 20);
309 }
310 
317 static inline void mavlink_msg_ahrs2_decode(const mavlink_message_t* msg, mavlink_ahrs2_t* ahrs2)
318 {
319 #if MAVLINK_NEED_BYTE_SWAP
320  ahrs2->roll = mavlink_msg_ahrs2_get_roll(msg);
321  ahrs2->pitch = mavlink_msg_ahrs2_get_pitch(msg);
322  ahrs2->yaw = mavlink_msg_ahrs2_get_yaw(msg);
323  ahrs2->altitude = mavlink_msg_ahrs2_get_altitude(msg);
324  ahrs2->lat = mavlink_msg_ahrs2_get_lat(msg);
325  ahrs2->lng = mavlink_msg_ahrs2_get_lng(msg);
326 #else
327  memcpy(ahrs2, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_AHRS2_LEN);
328 #endif
329 }
#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