Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_hil_state.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE HIL_STATE PACKING
3
4#define MAVLINK_MSG_ID_HIL_STATE 90
5
6
7typedef struct __mavlink_hil_state_t {
8 uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.*/
9 float roll; /*< [rad] Roll angle*/
10 float pitch; /*< [rad] Pitch angle*/
11 float yaw; /*< [rad] Yaw angle*/
12 float rollspeed; /*< [rad/s] Body frame roll / phi angular speed*/
13 float pitchspeed; /*< [rad/s] Body frame pitch / theta angular speed*/
14 float yawspeed; /*< [rad/s] Body frame yaw / psi angular speed*/
15 int32_t lat; /*< [degE7] Latitude*/
16 int32_t lon; /*< [degE7] Longitude*/
17 int32_t alt; /*< [mm] Altitude*/
18 int16_t vx; /*< [cm/s] Ground X Speed (Latitude)*/
19 int16_t vy; /*< [cm/s] Ground Y Speed (Longitude)*/
20 int16_t vz; /*< [cm/s] Ground Z Speed (Altitude)*/
21 int16_t xacc; /*< [mG] X acceleration*/
22 int16_t yacc; /*< [mG] Y acceleration*/
23 int16_t zacc; /*< [mG] Z acceleration*/
24} mavlink_hil_state_t;
25
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
30
31#define MAVLINK_MSG_ID_HIL_STATE_CRC 183
32#define MAVLINK_MSG_ID_90_CRC 183
33
34
35
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 } \
58}
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 } \
80}
81#endif
82
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
88 *
89 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
90 * @param roll [rad] Roll angle
91 * @param pitch [rad] Pitch angle
92 * @param yaw [rad] Yaw angle
93 * @param rollspeed [rad/s] Body frame roll / phi angular speed
94 * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
95 * @param yawspeed [rad/s] Body frame yaw / psi angular speed
96 * @param lat [degE7] Latitude
97 * @param lon [degE7] Longitude
98 * @param alt [mm] Altitude
99 * @param vx [cm/s] Ground X Speed (Latitude)
100 * @param vy [cm/s] Ground Y Speed (Longitude)
101 * @param vz [cm/s] Ground Z Speed (Altitude)
102 * @param xacc [mG] X acceleration
103 * @param yacc [mG] Y acceleration
104 * @param zacc [mG] Z acceleration
105 * @return length of the message in bytes (excluding serial stream start sign)
106 */
107static 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)
109{
110#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
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);
128
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;
148
149 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
150#endif
151
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);
154}
155
156/**
157 * @brief Pack a hil_state message
158 * @param system_id ID of this system
159 * @param component_id ID of this component (e.g. 200 for IMU)
160 * @param status MAVLink status structure
161 * @param msg The MAVLink message to compress the data into
162 *
163 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
164 * @param roll [rad] Roll angle
165 * @param pitch [rad] Pitch angle
166 * @param yaw [rad] Yaw angle
167 * @param rollspeed [rad/s] Body frame roll / phi angular speed
168 * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
169 * @param yawspeed [rad/s] Body frame yaw / psi angular speed
170 * @param lat [degE7] Latitude
171 * @param lon [degE7] Longitude
172 * @param alt [mm] Altitude
173 * @param vx [cm/s] Ground X Speed (Latitude)
174 * @param vy [cm/s] Ground Y Speed (Longitude)
175 * @param vz [cm/s] Ground Z Speed (Altitude)
176 * @param xacc [mG] X acceleration
177 * @param yacc [mG] Y acceleration
178 * @param zacc [mG] Z acceleration
179 * @return length of the message in bytes (excluding serial stream start sign)
180 */
181static inline uint16_t mavlink_msg_hil_state_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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)
183{
184#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
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);
202
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;
222
223 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
224#endif
225
226 msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
227#if MAVLINK_CRC_EXTRA
228 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN, MAVLINK_MSG_ID_HIL_STATE_CRC);
229#else
230 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_STATE_MIN_LEN, MAVLINK_MSG_ID_HIL_STATE_LEN);
231#endif
232}
233
234/**
235 * @brief Pack a hil_state message on a channel
236 * @param system_id ID of this system
237 * @param component_id ID of this component (e.g. 200 for IMU)
238 * @param chan The MAVLink channel this message will be sent over
239 * @param msg The MAVLink message to compress the data into
240 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
241 * @param roll [rad] Roll angle
242 * @param pitch [rad] Pitch angle
243 * @param yaw [rad] Yaw angle
244 * @param rollspeed [rad/s] Body frame roll / phi angular speed
245 * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
246 * @param yawspeed [rad/s] Body frame yaw / psi angular speed
247 * @param lat [degE7] Latitude
248 * @param lon [degE7] Longitude
249 * @param alt [mm] Altitude
250 * @param vx [cm/s] Ground X Speed (Latitude)
251 * @param vy [cm/s] Ground Y Speed (Longitude)
252 * @param vz [cm/s] Ground Z Speed (Altitude)
253 * @param xacc [mG] X acceleration
254 * @param yacc [mG] Y acceleration
255 * @param zacc [mG] Z acceleration
256 * @return length of the message in bytes (excluding serial stream start sign)
257 */
258static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
259 mavlink_message_t* msg,
260 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)
261{
262#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
264 _mav_put_uint64_t(buf, 0, time_usec);
265 _mav_put_float(buf, 8, roll);
266 _mav_put_float(buf, 12, pitch);
267 _mav_put_float(buf, 16, yaw);
268 _mav_put_float(buf, 20, rollspeed);
269 _mav_put_float(buf, 24, pitchspeed);
270 _mav_put_float(buf, 28, yawspeed);
271 _mav_put_int32_t(buf, 32, lat);
272 _mav_put_int32_t(buf, 36, lon);
273 _mav_put_int32_t(buf, 40, alt);
274 _mav_put_int16_t(buf, 44, vx);
275 _mav_put_int16_t(buf, 46, vy);
276 _mav_put_int16_t(buf, 48, vz);
277 _mav_put_int16_t(buf, 50, xacc);
278 _mav_put_int16_t(buf, 52, yacc);
279 _mav_put_int16_t(buf, 54, zacc);
280
281 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_STATE_LEN);
282#else
283 mavlink_hil_state_t packet;
284 packet.time_usec = time_usec;
285 packet.roll = roll;
286 packet.pitch = pitch;
287 packet.yaw = yaw;
288 packet.rollspeed = rollspeed;
289 packet.pitchspeed = pitchspeed;
290 packet.yawspeed = yawspeed;
291 packet.lat = lat;
292 packet.lon = lon;
293 packet.alt = alt;
294 packet.vx = vx;
295 packet.vy = vy;
296 packet.vz = vz;
297 packet.xacc = xacc;
298 packet.yacc = yacc;
299 packet.zacc = zacc;
300
301 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_STATE_LEN);
302#endif
303
304 msg->msgid = MAVLINK_MSG_ID_HIL_STATE;
305 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);
306}
307
308/**
309 * @brief Encode a hil_state struct
310 *
311 * @param system_id ID of this system
312 * @param component_id ID of this component (e.g. 200 for IMU)
313 * @param msg The MAVLink message to compress the data into
314 * @param hil_state C-struct to read the message contents from
315 */
316static 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)
317{
318 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);
319}
320
321/**
322 * @brief Encode a hil_state struct on a channel
323 *
324 * @param system_id ID of this system
325 * @param component_id ID of this component (e.g. 200 for IMU)
326 * @param chan The MAVLink channel this message will be sent over
327 * @param msg The MAVLink message to compress the data into
328 * @param hil_state C-struct to read the message contents from
329 */
330static 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)
331{
332 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);
333}
334
335/**
336 * @brief Encode a hil_state struct with provided status structure
337 *
338 * @param system_id ID of this system
339 * @param component_id ID of this component (e.g. 200 for IMU)
340 * @param status MAVLink status structure
341 * @param msg The MAVLink message to compress the data into
342 * @param hil_state C-struct to read the message contents from
343 */
344static inline uint16_t mavlink_msg_hil_state_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_state_t* hil_state)
345{
346 return mavlink_msg_hil_state_pack_status(system_id, component_id, _status, 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);
347}
348
349/**
350 * @brief Send a hil_state message
351 * @param chan MAVLink channel to send the message
352 *
353 * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
354 * @param roll [rad] Roll angle
355 * @param pitch [rad] Pitch angle
356 * @param yaw [rad] Yaw angle
357 * @param rollspeed [rad/s] Body frame roll / phi angular speed
358 * @param pitchspeed [rad/s] Body frame pitch / theta angular speed
359 * @param yawspeed [rad/s] Body frame yaw / psi angular speed
360 * @param lat [degE7] Latitude
361 * @param lon [degE7] Longitude
362 * @param alt [mm] Altitude
363 * @param vx [cm/s] Ground X Speed (Latitude)
364 * @param vy [cm/s] Ground Y Speed (Longitude)
365 * @param vz [cm/s] Ground Z Speed (Altitude)
366 * @param xacc [mG] X acceleration
367 * @param yacc [mG] Y acceleration
368 * @param zacc [mG] Z acceleration
369 */
370#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
371
372static 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)
373{
374#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
375 char buf[MAVLINK_MSG_ID_HIL_STATE_LEN];
376 _mav_put_uint64_t(buf, 0, time_usec);
377 _mav_put_float(buf, 8, roll);
378 _mav_put_float(buf, 12, pitch);
379 _mav_put_float(buf, 16, yaw);
380 _mav_put_float(buf, 20, rollspeed);
381 _mav_put_float(buf, 24, pitchspeed);
382 _mav_put_float(buf, 28, yawspeed);
383 _mav_put_int32_t(buf, 32, lat);
384 _mav_put_int32_t(buf, 36, lon);
385 _mav_put_int32_t(buf, 40, alt);
386 _mav_put_int16_t(buf, 44, vx);
387 _mav_put_int16_t(buf, 46, vy);
388 _mav_put_int16_t(buf, 48, vz);
389 _mav_put_int16_t(buf, 50, xacc);
390 _mav_put_int16_t(buf, 52, yacc);
391 _mav_put_int16_t(buf, 54, zacc);
392
393 _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);
394#else
395 mavlink_hil_state_t packet;
396 packet.time_usec = time_usec;
397 packet.roll = roll;
398 packet.pitch = pitch;
399 packet.yaw = yaw;
400 packet.rollspeed = rollspeed;
401 packet.pitchspeed = pitchspeed;
402 packet.yawspeed = yawspeed;
403 packet.lat = lat;
404 packet.lon = lon;
405 packet.alt = alt;
406 packet.vx = vx;
407 packet.vy = vy;
408 packet.vz = vz;
409 packet.xacc = xacc;
410 packet.yacc = yacc;
411 packet.zacc = zacc;
412
413 _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);
414#endif
415}
416
417/**
418 * @brief Send a hil_state message
419 * @param chan MAVLink channel to send the message
420 * @param struct The MAVLink struct to serialize
421 */
422static inline void mavlink_msg_hil_state_send_struct(mavlink_channel_t chan, const mavlink_hil_state_t* hil_state)
423{
424#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
425 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);
426#else
427 _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);
428#endif
429}
430
431#if MAVLINK_MSG_ID_HIL_STATE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
432/*
433 This variant of _send() can be used to save stack space by reusing
434 memory from the receive buffer. The caller provides a
435 mavlink_message_t which is the size of a full mavlink message. This
436 is usually the receive buffer for the channel, and allows a reply to an
437 incoming message with minimum stack space usage.
438 */
439static 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)
440{
441#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
442 char *buf = (char *)msgbuf;
443 _mav_put_uint64_t(buf, 0, time_usec);
444 _mav_put_float(buf, 8, roll);
445 _mav_put_float(buf, 12, pitch);
446 _mav_put_float(buf, 16, yaw);
447 _mav_put_float(buf, 20, rollspeed);
448 _mav_put_float(buf, 24, pitchspeed);
449 _mav_put_float(buf, 28, yawspeed);
450 _mav_put_int32_t(buf, 32, lat);
451 _mav_put_int32_t(buf, 36, lon);
452 _mav_put_int32_t(buf, 40, alt);
453 _mav_put_int16_t(buf, 44, vx);
454 _mav_put_int16_t(buf, 46, vy);
455 _mav_put_int16_t(buf, 48, vz);
456 _mav_put_int16_t(buf, 50, xacc);
457 _mav_put_int16_t(buf, 52, yacc);
458 _mav_put_int16_t(buf, 54, zacc);
459
460 _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);
461#else
462 mavlink_hil_state_t *packet = (mavlink_hil_state_t *)msgbuf;
463 packet->time_usec = time_usec;
464 packet->roll = roll;
465 packet->pitch = pitch;
466 packet->yaw = yaw;
467 packet->rollspeed = rollspeed;
468 packet->pitchspeed = pitchspeed;
469 packet->yawspeed = yawspeed;
470 packet->lat = lat;
471 packet->lon = lon;
472 packet->alt = alt;
473 packet->vx = vx;
474 packet->vy = vy;
475 packet->vz = vz;
476 packet->xacc = xacc;
477 packet->yacc = yacc;
478 packet->zacc = zacc;
479
480 _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);
481#endif
482}
483#endif
484
485#endif
486
487// MESSAGE HIL_STATE UNPACKING
488
489
490/**
491 * @brief Get field time_usec from hil_state message
492 *
493 * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude of the number.
494 */
495static inline uint64_t mavlink_msg_hil_state_get_time_usec(const mavlink_message_t* msg)
496{
497 return _MAV_RETURN_uint64_t(msg, 0);
498}
499
500/**
501 * @brief Get field roll from hil_state message
502 *
503 * @return [rad] Roll angle
504 */
505static inline float mavlink_msg_hil_state_get_roll(const mavlink_message_t* msg)
506{
507 return _MAV_RETURN_float(msg, 8);
508}
509
510/**
511 * @brief Get field pitch from hil_state message
512 *
513 * @return [rad] Pitch angle
514 */
515static inline float mavlink_msg_hil_state_get_pitch(const mavlink_message_t* msg)
516{
517 return _MAV_RETURN_float(msg, 12);
518}
519
520/**
521 * @brief Get field yaw from hil_state message
522 *
523 * @return [rad] Yaw angle
524 */
525static inline float mavlink_msg_hil_state_get_yaw(const mavlink_message_t* msg)
526{
527 return _MAV_RETURN_float(msg, 16);
528}
529
530/**
531 * @brief Get field rollspeed from hil_state message
532 *
533 * @return [rad/s] Body frame roll / phi angular speed
534 */
535static inline float mavlink_msg_hil_state_get_rollspeed(const mavlink_message_t* msg)
536{
537 return _MAV_RETURN_float(msg, 20);
538}
539
540/**
541 * @brief Get field pitchspeed from hil_state message
542 *
543 * @return [rad/s] Body frame pitch / theta angular speed
544 */
545static inline float mavlink_msg_hil_state_get_pitchspeed(const mavlink_message_t* msg)
546{
547 return _MAV_RETURN_float(msg, 24);
548}
549
550/**
551 * @brief Get field yawspeed from hil_state message
552 *
553 * @return [rad/s] Body frame yaw / psi angular speed
554 */
555static inline float mavlink_msg_hil_state_get_yawspeed(const mavlink_message_t* msg)
556{
557 return _MAV_RETURN_float(msg, 28);
558}
559
560/**
561 * @brief Get field lat from hil_state message
562 *
563 * @return [degE7] Latitude
564 */
565static inline int32_t mavlink_msg_hil_state_get_lat(const mavlink_message_t* msg)
566{
567 return _MAV_RETURN_int32_t(msg, 32);
568}
569
570/**
571 * @brief Get field lon from hil_state message
572 *
573 * @return [degE7] Longitude
574 */
575static inline int32_t mavlink_msg_hil_state_get_lon(const mavlink_message_t* msg)
576{
577 return _MAV_RETURN_int32_t(msg, 36);
578}
579
580/**
581 * @brief Get field alt from hil_state message
582 *
583 * @return [mm] Altitude
584 */
585static inline int32_t mavlink_msg_hil_state_get_alt(const mavlink_message_t* msg)
586{
587 return _MAV_RETURN_int32_t(msg, 40);
588}
589
590/**
591 * @brief Get field vx from hil_state message
592 *
593 * @return [cm/s] Ground X Speed (Latitude)
594 */
595static inline int16_t mavlink_msg_hil_state_get_vx(const mavlink_message_t* msg)
596{
597 return _MAV_RETURN_int16_t(msg, 44);
598}
599
600/**
601 * @brief Get field vy from hil_state message
602 *
603 * @return [cm/s] Ground Y Speed (Longitude)
604 */
605static inline int16_t mavlink_msg_hil_state_get_vy(const mavlink_message_t* msg)
606{
607 return _MAV_RETURN_int16_t(msg, 46);
608}
609
610/**
611 * @brief Get field vz from hil_state message
612 *
613 * @return [cm/s] Ground Z Speed (Altitude)
614 */
615static inline int16_t mavlink_msg_hil_state_get_vz(const mavlink_message_t* msg)
616{
617 return _MAV_RETURN_int16_t(msg, 48);
618}
619
620/**
621 * @brief Get field xacc from hil_state message
622 *
623 * @return [mG] X acceleration
624 */
625static inline int16_t mavlink_msg_hil_state_get_xacc(const mavlink_message_t* msg)
626{
627 return _MAV_RETURN_int16_t(msg, 50);
628}
629
630/**
631 * @brief Get field yacc from hil_state message
632 *
633 * @return [mG] Y acceleration
634 */
635static inline int16_t mavlink_msg_hil_state_get_yacc(const mavlink_message_t* msg)
636{
637 return _MAV_RETURN_int16_t(msg, 52);
638}
639
640/**
641 * @brief Get field zacc from hil_state message
642 *
643 * @return [mG] Z acceleration
644 */
645static inline int16_t mavlink_msg_hil_state_get_zacc(const mavlink_message_t* msg)
646{
647 return _MAV_RETURN_int16_t(msg, 54);
648}
649
650/**
651 * @brief Decode a hil_state message into a struct
652 *
653 * @param msg The message to decode
654 * @param hil_state C-struct to decode the message contents into
655 */
656static inline void mavlink_msg_hil_state_decode(const mavlink_message_t* msg, mavlink_hil_state_t* hil_state)
657{
658#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
659 hil_state->time_usec = mavlink_msg_hil_state_get_time_usec(msg);
660 hil_state->roll = mavlink_msg_hil_state_get_roll(msg);
661 hil_state->pitch = mavlink_msg_hil_state_get_pitch(msg);
662 hil_state->yaw = mavlink_msg_hil_state_get_yaw(msg);
663 hil_state->rollspeed = mavlink_msg_hil_state_get_rollspeed(msg);
664 hil_state->pitchspeed = mavlink_msg_hil_state_get_pitchspeed(msg);
665 hil_state->yawspeed = mavlink_msg_hil_state_get_yawspeed(msg);
666 hil_state->lat = mavlink_msg_hil_state_get_lat(msg);
667 hil_state->lon = mavlink_msg_hil_state_get_lon(msg);
668 hil_state->alt = mavlink_msg_hil_state_get_alt(msg);
669 hil_state->vx = mavlink_msg_hil_state_get_vx(msg);
670 hil_state->vy = mavlink_msg_hil_state_get_vy(msg);
671 hil_state->vz = mavlink_msg_hil_state_get_vz(msg);
672 hil_state->xacc = mavlink_msg_hil_state_get_xacc(msg);
673 hil_state->yacc = mavlink_msg_hil_state_get_yacc(msg);
674 hil_state->zacc = mavlink_msg_hil_state_get_zacc(msg);
675#else
676 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_STATE_LEN? msg->len : MAVLINK_MSG_ID_HIL_STATE_LEN;
677 memset(hil_state, 0, MAVLINK_MSG_ID_HIL_STATE_LEN);
678 memcpy(hil_state, _MAV_PAYLOAD(msg), len);
679#endif
680}