[GYRO] Refactor gyro driver for dual-gyro support
[inav.git] / lib / main / MAVLink / common / mavlink_msg_hil_state.h
blob722c5835befd350d802fcde67d356d865e26ddb8
1 #pragma once
2 // MESSAGE HIL_STATE PACKING
4 #define MAVLINK_MSG_ID_HIL_STATE 90
6 MAVPACKED(
7 typedef struct __mavlink_hil_state_t {
8 uint64_t time_usec; /*< Timestamp (microseconds since UNIX epoch or microseconds since system boot)*/
9 float roll; /*< Roll angle (rad)*/
10 float pitch; /*< Pitch angle (rad)*/
11 float yaw; /*< Yaw angle (rad)*/
12 float rollspeed; /*< Body frame roll / phi angular speed (rad/s)*/
13 float pitchspeed; /*< Body frame pitch / theta angular speed (rad/s)*/
14 float yawspeed; /*< Body frame yaw / psi angular speed (rad/s)*/
15 int32_t lat; /*< Latitude, expressed as * 1E7*/
16 int32_t lon; /*< Longitude, expressed as * 1E7*/
17 int32_t alt; /*< Altitude in meters, expressed as * 1000 (millimeters)*/
18 int16_t vx; /*< Ground X Speed (Latitude), expressed as m/s * 100*/
19 int16_t vy; /*< Ground Y Speed (Longitude), expressed as m/s * 100*/
20 int16_t vz; /*< Ground Z Speed (Altitude), expressed as m/s * 100*/
21 int16_t xacc; /*< X acceleration (mg)*/
22 int16_t yacc; /*< Y acceleration (mg)*/
23 int16_t zacc; /*< Z acceleration (mg)*/
24 }) mavlink_hil_state_t;
26 #define MAVLINK_MSG_ID_HIL_STATE_LEN 56
27 #define MAVLINK_MSG_ID_HIL_STATE_MIN_LEN 56
28 #define MAVLINK_MSG_ID_90_LEN 56
29 #define MAVLINK_MSG_ID_90_MIN_LEN 56
31 #define MAVLINK_MSG_ID_HIL_STATE_CRC 183
32 #define MAVLINK_MSG_ID_90_CRC 183
36 #if MAVLINK_COMMAND_24BIT
37 #define MAVLINK_MESSAGE_INFO_HIL_STATE { \
38 90, \
39 "HIL_STATE", \
40 16, \
41 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_state_t, time_usec) }, \
42 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_state_t, roll) }, \
43 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_state_t, pitch) }, \
44 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_state_t, yaw) }, \
45 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_state_t, rollspeed) }, \
46 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_state_t, pitchspeed) }, \
47 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_state_t, yawspeed) }, \
48 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_hil_state_t, lat) }, \
49 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_hil_state_t, lon) }, \
50 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_hil_state_t, alt) }, \
51 { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 44, offsetof(mavlink_hil_state_t, vx) }, \
52 { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 46, offsetof(mavlink_hil_state_t, vy) }, \
53 { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 48, offsetof(mavlink_hil_state_t, vz) }, \
54 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 50, offsetof(mavlink_hil_state_t, xacc) }, \
55 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 52, offsetof(mavlink_hil_state_t, yacc) }, \
56 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 54, offsetof(mavlink_hil_state_t, zacc) }, \
57 } \
59 #else
60 #define MAVLINK_MESSAGE_INFO_HIL_STATE { \
61 "HIL_STATE", \
62 16, \
63 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_state_t, time_usec) }, \
64 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_state_t, roll) }, \
65 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_state_t, pitch) }, \
66 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_state_t, yaw) }, \
67 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_state_t, rollspeed) }, \
68 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_state_t, pitchspeed) }, \
69 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_state_t, yawspeed) }, \
70 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_hil_state_t, lat) }, \
71 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_hil_state_t, lon) }, \
72 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_hil_state_t, alt) }, \
73 { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 44, offsetof(mavlink_hil_state_t, vx) }, \
74 { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 46, offsetof(mavlink_hil_state_t, vy) }, \
75 { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 48, offsetof(mavlink_hil_state_t, vz) }, \
76 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 50, offsetof(mavlink_hil_state_t, xacc) }, \
77 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 52, offsetof(mavlink_hil_state_t, yacc) }, \
78 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 54, offsetof(mavlink_hil_state_t, zacc) }, \
79 } \
81 #endif
83 /**
84 * @brief Pack a hil_state message
85 * @param system_id ID of this system
86 * @param component_id ID of this component (e.g. 200 for IMU)
87 * @param msg The MAVLink message to compress the data into
89 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
90 * @param roll Roll angle (rad)
91 * @param pitch Pitch angle (rad)
92 * @param yaw Yaw angle (rad)
93 * @param rollspeed Body frame roll / phi angular speed (rad/s)
94 * @param pitchspeed Body frame pitch / theta angular speed (rad/s)
95 * @param yawspeed Body frame yaw / psi angular speed (rad/s)
96 * @param lat Latitude, expressed as * 1E7
97 * @param lon Longitude, expressed as * 1E7
98 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
99 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
100 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
101 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
102 * @param xacc X acceleration (mg)
103 * @param yacc Y acceleration (mg)
104 * @param zacc Z acceleration (mg)
105 * @return length of the message in bytes (excluding serial stream start sign)
107 static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
108 uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
110 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
111 char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
112 _mav_put_uint64_t(buf, 0, time_usec);
113 _mav_put_float(buf, 8, roll);
114 _mav_put_float(buf, 12, pitch);
115 _mav_put_float(buf, 16, yaw);
116 _mav_put_float(buf, 20, rollspeed);
117 _mav_put_float(buf, 24, pitchspeed);
118 _mav_put_float(buf, 28, yawspeed);
119 _mav_put_int32_t(buf, 32, lat);
120 _mav_put_int32_t(buf, 36, lon);
121 _mav_put_int32_t(buf, 40, alt);
122 _mav_put_int16_t(buf, 44, vx);
123 _mav_put_int16_t(buf, 46, vy);
124 _mav_put_int16_t(buf, 48, vz);
125 _mav_put_int16_t(buf, 50, xacc);
126 _mav_put_int16_t(buf, 52, yacc);
127 _mav_put_int16_t(buf, 54, zacc);
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
130 #else
131 mavlink_hil_state_t packet;
132 packet.time_usec = time_usec;
133 packet.roll = roll;
134 packet.pitch = pitch;
135 packet.yaw = yaw;
136 packet.rollspeed = rollspeed;
137 packet.pitchspeed = pitchspeed;
138 packet.yawspeed = yawspeed;
139 packet.lat = lat;
140 packet.lon = lon;
141 packet.alt = alt;
142 packet.vx = vx;
143 packet.vy = vy;
144 packet.vz = vz;
145 packet.xacc = xacc;
146 packet.yacc = yacc;
147 packet.zacc = zacc;
149 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
150 #endif
152 msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
153 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
157 * @brief Pack a hil_state message on a channel
158 * @param system_id ID of this system
159 * @param component_id ID of this component (e.g. 200 for IMU)
160 * @param chan The MAVLink channel this message will be sent over
161 * @param msg The MAVLink message to compress the data into
162 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
163 * @param roll Roll angle (rad)
164 * @param pitch Pitch angle (rad)
165 * @param yaw Yaw angle (rad)
166 * @param rollspeed Body frame roll / phi angular speed (rad/s)
167 * @param pitchspeed Body frame pitch / theta angular speed (rad/s)
168 * @param yawspeed Body frame yaw / psi angular speed (rad/s)
169 * @param lat Latitude, expressed as * 1E7
170 * @param lon Longitude, expressed as * 1E7
171 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
172 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
173 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
174 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
175 * @param xacc X acceleration (mg)
176 * @param yacc Y acceleration (mg)
177 * @param zacc Z acceleration (mg)
178 * @return length of the message in bytes (excluding serial stream start sign)
180 static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
181 mavlink_message_t* msg,
182 uint64_t time_usec,float roll,float pitch,float yaw,float rollspeed,float pitchspeed,float yawspeed,int32_t lat,int32_t lon,int32_t alt,int16_t vx,int16_t vy,int16_t vz,int16_t xacc,int16_t yacc,int16_t zacc)
184 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
185 char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
186 _mav_put_uint64_t(buf, 0, time_usec);
187 _mav_put_float(buf, 8, roll);
188 _mav_put_float(buf, 12, pitch);
189 _mav_put_float(buf, 16, yaw);
190 _mav_put_float(buf, 20, rollspeed);
191 _mav_put_float(buf, 24, pitchspeed);
192 _mav_put_float(buf, 28, yawspeed);
193 _mav_put_int32_t(buf, 32, lat);
194 _mav_put_int32_t(buf, 36, lon);
195 _mav_put_int32_t(buf, 40, alt);
196 _mav_put_int16_t(buf, 44, vx);
197 _mav_put_int16_t(buf, 46, vy);
198 _mav_put_int16_t(buf, 48, vz);
199 _mav_put_int16_t(buf, 50, xacc);
200 _mav_put_int16_t(buf, 52, yacc);
201 _mav_put_int16_t(buf, 54, zacc);
203 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
204 #else
205 mavlink_hil_state_t packet;
206 packet.time_usec = time_usec;
207 packet.roll = roll;
208 packet.pitch = pitch;
209 packet.yaw = yaw;
210 packet.rollspeed = rollspeed;
211 packet.pitchspeed = pitchspeed;
212 packet.yawspeed = yawspeed;
213 packet.lat = lat;
214 packet.lon = lon;
215 packet.alt = alt;
216 packet.vx = vx;
217 packet.vy = vy;
218 packet.vz = vz;
219 packet.xacc = xacc;
220 packet.yacc = yacc;
221 packet.zacc = zacc;
223 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
224 #endif
226 msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
227 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
231 * @brief Encode a hil_state struct
233 * @param system_id ID of this system
234 * @param component_id ID of this component (e.g. 200 for IMU)
235 * @param msg The MAVLink message to compress the data into
236 * @param hil_state C-struct to read the message contents from
238 static inline uint16_t mavlink_msg_hil_state_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
240 return mavlink_msg_hil_state_pack(system_id, component_id, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
244 * @brief Encode a hil_state struct on a channel
246 * @param system_id ID of this system
247 * @param component_id ID of this component (e.g. 200 for IMU)
248 * @param chan The MAVLink channel this message will be sent over
249 * @param msg The MAVLink message to compress the data into
250 * @param hil_state C-struct to read the message contents from
252 static inline uint16_t mavlink_msg_hil_state_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
254 return mavlink_msg_hil_state_pack_chan(system_id, component_id, chan, msg, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
258 * @brief Send a hil_state message
259 * @param chan MAVLink channel to send the message
261 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
262 * @param roll Roll angle (rad)
263 * @param pitch Pitch angle (rad)
264 * @param yaw Yaw angle (rad)
265 * @param rollspeed Body frame roll / phi angular speed (rad/s)
266 * @param pitchspeed Body frame pitch / theta angular speed (rad/s)
267 * @param yawspeed Body frame yaw / psi angular speed (rad/s)
268 * @param lat Latitude, expressed as * 1E7
269 * @param lon Longitude, expressed as * 1E7
270 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
271 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
272 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
273 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
274 * @param xacc X acceleration (mg)
275 * @param yacc Y acceleration (mg)
276 * @param zacc Z acceleration (mg)
278 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
280 static inline void mavlink_msg_hil_state_send(mavlink_channel_t chan, uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
282 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
283 char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
284 _mav_put_uint64_t(buf, 0, time_usec);
285 _mav_put_float(buf, 8, roll);
286 _mav_put_float(buf, 12, pitch);
287 _mav_put_float(buf, 16, yaw);
288 _mav_put_float(buf, 20, rollspeed);
289 _mav_put_float(buf, 24, pitchspeed);
290 _mav_put_float(buf, 28, yawspeed);
291 _mav_put_int32_t(buf, 32, lat);
292 _mav_put_int32_t(buf, 36, lon);
293 _mav_put_int32_t(buf, 40, alt);
294 _mav_put_int16_t(buf, 44, vx);
295 _mav_put_int16_t(buf, 46, vy);
296 _mav_put_int16_t(buf, 48, vz);
297 _mav_put_int16_t(buf, 50, xacc);
298 _mav_put_int16_t(buf, 52, yacc);
299 _mav_put_int16_t(buf, 54, zacc);
301 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, buf, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
302 #else
303 mavlink_hil_state_t packet;
304 packet.time_usec = time_usec;
305 packet.roll = roll;
306 packet.pitch = pitch;
307 packet.yaw = yaw;
308 packet.rollspeed = rollspeed;
309 packet.pitchspeed = pitchspeed;
310 packet.yawspeed = yawspeed;
311 packet.lat = lat;
312 packet.lon = lon;
313 packet.alt = alt;
314 packet.vx = vx;
315 packet.vy = vy;
316 packet.vz = vz;
317 packet.xacc = xacc;
318 packet.yacc = yacc;
319 packet.zacc = zacc;
321 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)&packet, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
322 #endif
326 * @brief Send a hil_state message
327 * @param chan MAVLink channel to send the message
328 * @param struct The MAVLink struct to serialize
330 static inline void mavlink_msg_hil_state_send_struct(mavlink_channel_t chan, const mavlink_hil_state_t* hil_state)
332 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
333 mavlink_msg_hil_state_send(chan, hil_state->time_usec, hil_state->roll, hil_state->pitch, hil_state->yaw, hil_state->rollspeed, hil_state->pitchspeed, hil_state->yawspeed, hil_state->lat, hil_state->lon, hil_state->alt, hil_state->vx, hil_state->vy, hil_state->vz, hil_state->xacc, hil_state->yacc, hil_state->zacc);
334 #else
335 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)hil_state, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
336 #endif
339 #if MAVLINK_MSG_ID_HIL_STATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
341 This varient of _send() can be used to save stack space by re-using
342 memory from the receive buffer. The caller provides a
343 mavlink_message_t which is the size of a full mavlink message. This
344 is usually the receive buffer for the channel, and allows a reply to an
345 incoming message with minimum stack space usage.
347 static inline void mavlink_msg_hil_state_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, int32_t lat, int32_t lon, int32_t alt, int16_t vx, int16_t vy, int16_t vz, int16_t xacc, int16_t yacc, int16_t zacc)
349 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
350 char *buf = (char *)msgbuf;
351 _mav_put_uint64_t(buf, 0, time_usec);
352 _mav_put_float(buf, 8, roll);
353 _mav_put_float(buf, 12, pitch);
354 _mav_put_float(buf, 16, yaw);
355 _mav_put_float(buf, 20, rollspeed);
356 _mav_put_float(buf, 24, pitchspeed);
357 _mav_put_float(buf, 28, yawspeed);
358 _mav_put_int32_t(buf, 32, lat);
359 _mav_put_int32_t(buf, 36, lon);
360 _mav_put_int32_t(buf, 40, alt);
361 _mav_put_int16_t(buf, 44, vx);
362 _mav_put_int16_t(buf, 46, vy);
363 _mav_put_int16_t(buf, 48, vz);
364 _mav_put_int16_t(buf, 50, xacc);
365 _mav_put_int16_t(buf, 52, yacc);
366 _mav_put_int16_t(buf, 54, zacc);
368 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, buf, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
369 #else
370 mavlink_hil_state_t *packet = (mavlink_hil_state_t *)msgbuf;
371 packet->time_usec = time_usec;
372 packet->roll = roll;
373 packet->pitch = pitch;
374 packet->yaw = yaw;
375 packet->rollspeed = rollspeed;
376 packet->pitchspeed = pitchspeed;
377 packet->yawspeed = yawspeed;
378 packet->lat = lat;
379 packet->lon = lon;
380 packet->alt = alt;
381 packet->vx = vx;
382 packet->vy = vy;
383 packet->vz = vz;
384 packet->xacc = xacc;
385 packet->yacc = yacc;
386 packet->zacc = zacc;
388 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_STATE, (const char *)packet, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
389 #endif
391 #endif
393 #endif
395 // MESSAGE HIL_STATE UNPACKING
399 * @brief Get field time_usec from hil_state message
401 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
403 static inline uint64_t mavlink_msg_hil_state_get_time_usec(const mavlink_message_t* msg)
405 return _MAV_RETURN_uint64_t(msg, 0);
409 * @brief Get field roll from hil_state message
411 * @return Roll angle (rad)
413 static inline float mavlink_msg_hil_state_get_roll(const mavlink_message_t* msg)
415 return _MAV_RETURN_float(msg, 8);
419 * @brief Get field pitch from hil_state message
421 * @return Pitch angle (rad)
423 static inline float mavlink_msg_hil_state_get_pitch(const mavlink_message_t* msg)
425 return _MAV_RETURN_float(msg, 12);
429 * @brief Get field yaw from hil_state message
431 * @return Yaw angle (rad)
433 static inline float mavlink_msg_hil_state_get_yaw(const mavlink_message_t* msg)
435 return _MAV_RETURN_float(msg, 16);
439 * @brief Get field rollspeed from hil_state message
441 * @return Body frame roll / phi angular speed (rad/s)
443 static inline float mavlink_msg_hil_state_get_rollspeed(const mavlink_message_t* msg)
445 return _MAV_RETURN_float(msg, 20);
449 * @brief Get field pitchspeed from hil_state message
451 * @return Body frame pitch / theta angular speed (rad/s)
453 static inline float mavlink_msg_hil_state_get_pitchspeed(const mavlink_message_t* msg)
455 return _MAV_RETURN_float(msg, 24);
459 * @brief Get field yawspeed from hil_state message
461 * @return Body frame yaw / psi angular speed (rad/s)
463 static inline float mavlink_msg_hil_state_get_yawspeed(const mavlink_message_t* msg)
465 return _MAV_RETURN_float(msg, 28);
469 * @brief Get field lat from hil_state message
471 * @return Latitude, expressed as * 1E7
473 static inline int32_t mavlink_msg_hil_state_get_lat(const mavlink_message_t* msg)
475 return _MAV_RETURN_int32_t(msg, 32);
479 * @brief Get field lon from hil_state message
481 * @return Longitude, expressed as * 1E7
483 static inline int32_t mavlink_msg_hil_state_get_lon(const mavlink_message_t* msg)
485 return _MAV_RETURN_int32_t(msg, 36);
489 * @brief Get field alt from hil_state message
491 * @return Altitude in meters, expressed as * 1000 (millimeters)
493 static inline int32_t mavlink_msg_hil_state_get_alt(const mavlink_message_t* msg)
495 return _MAV_RETURN_int32_t(msg, 40);
499 * @brief Get field vx from hil_state message
501 * @return Ground X Speed (Latitude), expressed as m/s * 100
503 static inline int16_t mavlink_msg_hil_state_get_vx(const mavlink_message_t* msg)
505 return _MAV_RETURN_int16_t(msg, 44);
509 * @brief Get field vy from hil_state message
511 * @return Ground Y Speed (Longitude), expressed as m/s * 100
513 static inline int16_t mavlink_msg_hil_state_get_vy(const mavlink_message_t* msg)
515 return _MAV_RETURN_int16_t(msg, 46);
519 * @brief Get field vz from hil_state message
521 * @return Ground Z Speed (Altitude), expressed as m/s * 100
523 static inline int16_t mavlink_msg_hil_state_get_vz(const mavlink_message_t* msg)
525 return _MAV_RETURN_int16_t(msg, 48);
529 * @brief Get field xacc from hil_state message
531 * @return X acceleration (mg)
533 static inline int16_t mavlink_msg_hil_state_get_xacc(const mavlink_message_t* msg)
535 return _MAV_RETURN_int16_t(msg, 50);
539 * @brief Get field yacc from hil_state message
541 * @return Y acceleration (mg)
543 static inline int16_t mavlink_msg_hil_state_get_yacc(const mavlink_message_t* msg)
545 return _MAV_RETURN_int16_t(msg, 52);
549 * @brief Get field zacc from hil_state message
551 * @return Z acceleration (mg)
553 static inline int16_t mavlink_msg_hil_state_get_zacc(const mavlink_message_t* msg)
555 return _MAV_RETURN_int16_t(msg, 54);
559 * @brief Decode a hil_state message into a struct
561 * @param msg The message to decode
562 * @param hil_state C-struct to decode the message contents into
564 static inline void mavlink_msg_hil_state_decode(const mavlink_message_t* msg, mavlink_hil_state_t* hil_state)
566 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
567 hil_state->time_usec = mavlink_msg_hil_state_get_time_usec(msg);
568 hil_state->roll = mavlink_msg_hil_state_get_roll(msg);
569 hil_state->pitch = mavlink_msg_hil_state_get_pitch(msg);
570 hil_state->yaw = mavlink_msg_hil_state_get_yaw(msg);
571 hil_state->rollspeed = mavlink_msg_hil_state_get_rollspeed(msg);
572 hil_state->pitchspeed = mavlink_msg_hil_state_get_pitchspeed(msg);
573 hil_state->yawspeed = mavlink_msg_hil_state_get_yawspeed(msg);
574 hil_state->lat = mavlink_msg_hil_state_get_lat(msg);
575 hil_state->lon = mavlink_msg_hil_state_get_lon(msg);
576 hil_state->alt = mavlink_msg_hil_state_get_alt(msg);
577 hil_state->vx = mavlink_msg_hil_state_get_vx(msg);
578 hil_state->vy = mavlink_msg_hil_state_get_vy(msg);
579 hil_state->vz = mavlink_msg_hil_state_get_vz(msg);
580 hil_state->xacc = mavlink_msg_hil_state_get_xacc(msg);
581 hil_state->yacc = mavlink_msg_hil_state_get_yacc(msg);
582 hil_state->zacc = mavlink_msg_hil_state_get_zacc(msg);
583 #else
584 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_STATE_LEN? msg->len : MAVLINK_MSG_ID_HIL_STATE_LEN;
585 memset(hil_state, 0, MAVLINK_MSG_ID_HIL_STATE_LEN);
586 memcpy(hil_state, _MAV_PAYLOAD(msg), len);
587 #endif