1 // MESSAGE HIL_STATE PACKING
3 #define MAVLINK_MSG_ID_HIL_STATE 90
5 typedef struct __mavlink_hil_state_t
{
6 uint64_t time_usec
; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot)
7 float roll
; ///< Roll angle (rad)
8 float pitch
; ///< Pitch angle (rad)
9 float yaw
; ///< Yaw angle (rad)
10 float rollspeed
; ///< Roll angular speed (rad/s)
11 float pitchspeed
; ///< Pitch angular speed (rad/s)
12 float yawspeed
; ///< Yaw angular speed (rad/s)
13 int32_t lat
; ///< Latitude, expressed as * 1E7
14 int32_t lon
; ///< Longitude, expressed as * 1E7
15 int32_t alt
; ///< Altitude in meters, expressed as * 1000 (millimeters)
16 int16_t vx
; ///< Ground X Speed (Latitude), expressed as m/s * 100
17 int16_t vy
; ///< Ground Y Speed (Longitude), expressed as m/s * 100
18 int16_t vz
; ///< Ground Z Speed (Altitude), expressed as m/s * 100
19 int16_t xacc
; ///< X acceleration (mg)
20 int16_t yacc
; ///< Y acceleration (mg)
21 int16_t zacc
; ///< Z acceleration (mg)
22 } mavlink_hil_state_t
;
24 #define MAVLINK_MSG_ID_HIL_STATE_LEN 56
25 #define MAVLINK_MSG_ID_90_LEN 56
28 #define MAVLINK_MESSAGE_INFO_HIL_STATE \
33 { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_state_t, time_usec) }, \
34 { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_state_t, roll) }, \
35 { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_state_t, pitch) }, \
36 { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_state_t, yaw) }, \
37 { "rollspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_state_t, rollspeed) }, \
38 { "pitchspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_state_t, pitchspeed) }, \
39 { "yawspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_state_t, yawspeed) }, \
40 { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 32, offsetof(mavlink_hil_state_t, lat) }, \
41 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 36, offsetof(mavlink_hil_state_t, lon) }, \
42 { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 40, offsetof(mavlink_hil_state_t, alt) }, \
43 { "vx", NULL, MAVLINK_TYPE_INT16_T, 0, 44, offsetof(mavlink_hil_state_t, vx) }, \
44 { "vy", NULL, MAVLINK_TYPE_INT16_T, 0, 46, offsetof(mavlink_hil_state_t, vy) }, \
45 { "vz", NULL, MAVLINK_TYPE_INT16_T, 0, 48, offsetof(mavlink_hil_state_t, vz) }, \
46 { "xacc", NULL, MAVLINK_TYPE_INT16_T, 0, 50, offsetof(mavlink_hil_state_t, xacc) }, \
47 { "yacc", NULL, MAVLINK_TYPE_INT16_T, 0, 52, offsetof(mavlink_hil_state_t, yacc) }, \
48 { "zacc", NULL, MAVLINK_TYPE_INT16_T, 0, 54, offsetof(mavlink_hil_state_t, zacc) }, \
54 * @brief Pack a hil_state message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
59 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
60 * @param roll Roll angle (rad)
61 * @param pitch Pitch angle (rad)
62 * @param yaw Yaw angle (rad)
63 * @param rollspeed Roll angular speed (rad/s)
64 * @param pitchspeed Pitch angular speed (rad/s)
65 * @param yawspeed Yaw angular speed (rad/s)
66 * @param lat Latitude, expressed as * 1E7
67 * @param lon Longitude, expressed as * 1E7
68 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
69 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
70 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
71 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
72 * @param xacc X acceleration (mg)
73 * @param yacc Y acceleration (mg)
74 * @param zacc Z acceleration (mg)
75 * @return length of the message in bytes (excluding serial stream start sign)
77 static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
*msg
,
78 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
)
80 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
82 _mav_put_uint64_t(buf
, 0, time_usec
);
83 _mav_put_float(buf
, 8, roll
);
84 _mav_put_float(buf
, 12, pitch
);
85 _mav_put_float(buf
, 16, yaw
);
86 _mav_put_float(buf
, 20, rollspeed
);
87 _mav_put_float(buf
, 24, pitchspeed
);
88 _mav_put_float(buf
, 28, yawspeed
);
89 _mav_put_int32_t(buf
, 32, lat
);
90 _mav_put_int32_t(buf
, 36, lon
);
91 _mav_put_int32_t(buf
, 40, alt
);
92 _mav_put_int16_t(buf
, 44, vx
);
93 _mav_put_int16_t(buf
, 46, vy
);
94 _mav_put_int16_t(buf
, 48, vz
);
95 _mav_put_int16_t(buf
, 50, xacc
);
96 _mav_put_int16_t(buf
, 52, yacc
);
97 _mav_put_int16_t(buf
, 54, zacc
);
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 56);
101 mavlink_hil_state_t packet
;
102 packet
.time_usec
= time_usec
;
104 packet
.pitch
= pitch
;
106 packet
.rollspeed
= rollspeed
;
107 packet
.pitchspeed
= pitchspeed
;
108 packet
.yawspeed
= yawspeed
;
119 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 56);
120 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 msg
->msgid
= MAVLINK_MSG_ID_HIL_STATE
;
123 return mavlink_finalize_message(msg
, system_id
, component_id
, 56, 183);
127 * @brief Pack a hil_state 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 was sent over
131 * @param msg The MAVLink message to compress the data into
132 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
133 * @param roll Roll angle (rad)
134 * @param pitch Pitch angle (rad)
135 * @param yaw Yaw angle (rad)
136 * @param rollspeed Roll angular speed (rad/s)
137 * @param pitchspeed Pitch angular speed (rad/s)
138 * @param yawspeed Yaw angular speed (rad/s)
139 * @param lat Latitude, expressed as * 1E7
140 * @param lon Longitude, expressed as * 1E7
141 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
142 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
143 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
144 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
145 * @param xacc X acceleration (mg)
146 * @param yacc Y acceleration (mg)
147 * @param zacc Z acceleration (mg)
148 * @return length of the message in bytes (excluding serial stream start sign)
150 static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
151 mavlink_message_t
*msg
,
152 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
)
154 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
156 _mav_put_uint64_t(buf
, 0, time_usec
);
157 _mav_put_float(buf
, 8, roll
);
158 _mav_put_float(buf
, 12, pitch
);
159 _mav_put_float(buf
, 16, yaw
);
160 _mav_put_float(buf
, 20, rollspeed
);
161 _mav_put_float(buf
, 24, pitchspeed
);
162 _mav_put_float(buf
, 28, yawspeed
);
163 _mav_put_int32_t(buf
, 32, lat
);
164 _mav_put_int32_t(buf
, 36, lon
);
165 _mav_put_int32_t(buf
, 40, alt
);
166 _mav_put_int16_t(buf
, 44, vx
);
167 _mav_put_int16_t(buf
, 46, vy
);
168 _mav_put_int16_t(buf
, 48, vz
);
169 _mav_put_int16_t(buf
, 50, xacc
);
170 _mav_put_int16_t(buf
, 52, yacc
);
171 _mav_put_int16_t(buf
, 54, zacc
);
173 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, 56);
175 mavlink_hil_state_t packet
;
176 packet
.time_usec
= time_usec
;
178 packet
.pitch
= pitch
;
180 packet
.rollspeed
= rollspeed
;
181 packet
.pitchspeed
= pitchspeed
;
182 packet
.yawspeed
= yawspeed
;
193 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, 56);
194 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
196 msg
->msgid
= MAVLINK_MSG_ID_HIL_STATE
;
197 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, 56, 183);
201 * @brief Encode a hil_state struct into a message
203 * @param system_id ID of this system
204 * @param component_id ID of this component (e.g. 200 for IMU)
205 * @param msg The MAVLink message to compress the data into
206 * @param hil_state C-struct to read the message contents from
208 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
)
210 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
);
214 * @brief Send a hil_state message
215 * @param chan MAVLink channel to send the message
217 * @param time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
218 * @param roll Roll angle (rad)
219 * @param pitch Pitch angle (rad)
220 * @param yaw Yaw angle (rad)
221 * @param rollspeed Roll angular speed (rad/s)
222 * @param pitchspeed Pitch angular speed (rad/s)
223 * @param yawspeed Yaw angular speed (rad/s)
224 * @param lat Latitude, expressed as * 1E7
225 * @param lon Longitude, expressed as * 1E7
226 * @param alt Altitude in meters, expressed as * 1000 (millimeters)
227 * @param vx Ground X Speed (Latitude), expressed as m/s * 100
228 * @param vy Ground Y Speed (Longitude), expressed as m/s * 100
229 * @param vz Ground Z Speed (Altitude), expressed as m/s * 100
230 * @param xacc X acceleration (mg)
231 * @param yacc Y acceleration (mg)
232 * @param zacc Z acceleration (mg)
234 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
236 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
)
238 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
240 _mav_put_uint64_t(buf
, 0, time_usec
);
241 _mav_put_float(buf
, 8, roll
);
242 _mav_put_float(buf
, 12, pitch
);
243 _mav_put_float(buf
, 16, yaw
);
244 _mav_put_float(buf
, 20, rollspeed
);
245 _mav_put_float(buf
, 24, pitchspeed
);
246 _mav_put_float(buf
, 28, yawspeed
);
247 _mav_put_int32_t(buf
, 32, lat
);
248 _mav_put_int32_t(buf
, 36, lon
);
249 _mav_put_int32_t(buf
, 40, alt
);
250 _mav_put_int16_t(buf
, 44, vx
);
251 _mav_put_int16_t(buf
, 46, vy
);
252 _mav_put_int16_t(buf
, 48, vz
);
253 _mav_put_int16_t(buf
, 50, xacc
);
254 _mav_put_int16_t(buf
, 52, yacc
);
255 _mav_put_int16_t(buf
, 54, zacc
);
257 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_HIL_STATE
, buf
, 56, 183);
259 mavlink_hil_state_t packet
;
260 packet
.time_usec
= time_usec
;
262 packet
.pitch
= pitch
;
264 packet
.rollspeed
= rollspeed
;
265 packet
.pitchspeed
= pitchspeed
;
266 packet
.yawspeed
= yawspeed
;
277 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_HIL_STATE
, (const char *)&packet
, 56, 183);
278 #endif // if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
281 #endif // ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
283 // MESSAGE HIL_STATE UNPACKING
287 * @brief Get field time_usec from hil_state message
289 * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot)
291 static inline uint64_t mavlink_msg_hil_state_get_time_usec(const mavlink_message_t
*msg
)
293 return _MAV_RETURN_uint64_t(msg
, 0);
297 * @brief Get field roll from hil_state message
299 * @return Roll angle (rad)
301 static inline float mavlink_msg_hil_state_get_roll(const mavlink_message_t
*msg
)
303 return _MAV_RETURN_float(msg
, 8);
307 * @brief Get field pitch from hil_state message
309 * @return Pitch angle (rad)
311 static inline float mavlink_msg_hil_state_get_pitch(const mavlink_message_t
*msg
)
313 return _MAV_RETURN_float(msg
, 12);
317 * @brief Get field yaw from hil_state message
319 * @return Yaw angle (rad)
321 static inline float mavlink_msg_hil_state_get_yaw(const mavlink_message_t
*msg
)
323 return _MAV_RETURN_float(msg
, 16);
327 * @brief Get field rollspeed from hil_state message
329 * @return Roll angular speed (rad/s)
331 static inline float mavlink_msg_hil_state_get_rollspeed(const mavlink_message_t
*msg
)
333 return _MAV_RETURN_float(msg
, 20);
337 * @brief Get field pitchspeed from hil_state message
339 * @return Pitch angular speed (rad/s)
341 static inline float mavlink_msg_hil_state_get_pitchspeed(const mavlink_message_t
*msg
)
343 return _MAV_RETURN_float(msg
, 24);
347 * @brief Get field yawspeed from hil_state message
349 * @return Yaw angular speed (rad/s)
351 static inline float mavlink_msg_hil_state_get_yawspeed(const mavlink_message_t
*msg
)
353 return _MAV_RETURN_float(msg
, 28);
357 * @brief Get field lat from hil_state message
359 * @return Latitude, expressed as * 1E7
361 static inline int32_t mavlink_msg_hil_state_get_lat(const mavlink_message_t
*msg
)
363 return _MAV_RETURN_int32_t(msg
, 32);
367 * @brief Get field lon from hil_state message
369 * @return Longitude, expressed as * 1E7
371 static inline int32_t mavlink_msg_hil_state_get_lon(const mavlink_message_t
*msg
)
373 return _MAV_RETURN_int32_t(msg
, 36);
377 * @brief Get field alt from hil_state message
379 * @return Altitude in meters, expressed as * 1000 (millimeters)
381 static inline int32_t mavlink_msg_hil_state_get_alt(const mavlink_message_t
*msg
)
383 return _MAV_RETURN_int32_t(msg
, 40);
387 * @brief Get field vx from hil_state message
389 * @return Ground X Speed (Latitude), expressed as m/s * 100
391 static inline int16_t mavlink_msg_hil_state_get_vx(const mavlink_message_t
*msg
)
393 return _MAV_RETURN_int16_t(msg
, 44);
397 * @brief Get field vy from hil_state message
399 * @return Ground Y Speed (Longitude), expressed as m/s * 100
401 static inline int16_t mavlink_msg_hil_state_get_vy(const mavlink_message_t
*msg
)
403 return _MAV_RETURN_int16_t(msg
, 46);
407 * @brief Get field vz from hil_state message
409 * @return Ground Z Speed (Altitude), expressed as m/s * 100
411 static inline int16_t mavlink_msg_hil_state_get_vz(const mavlink_message_t
*msg
)
413 return _MAV_RETURN_int16_t(msg
, 48);
417 * @brief Get field xacc from hil_state message
419 * @return X acceleration (mg)
421 static inline int16_t mavlink_msg_hil_state_get_xacc(const mavlink_message_t
*msg
)
423 return _MAV_RETURN_int16_t(msg
, 50);
427 * @brief Get field yacc from hil_state message
429 * @return Y acceleration (mg)
431 static inline int16_t mavlink_msg_hil_state_get_yacc(const mavlink_message_t
*msg
)
433 return _MAV_RETURN_int16_t(msg
, 52);
437 * @brief Get field zacc from hil_state message
439 * @return Z acceleration (mg)
441 static inline int16_t mavlink_msg_hil_state_get_zacc(const mavlink_message_t
*msg
)
443 return _MAV_RETURN_int16_t(msg
, 54);
447 * @brief Decode a hil_state message into a struct
449 * @param msg The message to decode
450 * @param hil_state C-struct to decode the message contents into
452 static inline void mavlink_msg_hil_state_decode(const mavlink_message_t
*msg
, mavlink_hil_state_t
*hil_state
)
454 #if MAVLINK_NEED_BYTE_SWAP
455 hil_state
->time_usec
= mavlink_msg_hil_state_get_time_usec(msg
);
456 hil_state
->roll
= mavlink_msg_hil_state_get_roll(msg
);
457 hil_state
->pitch
= mavlink_msg_hil_state_get_pitch(msg
);
458 hil_state
->yaw
= mavlink_msg_hil_state_get_yaw(msg
);
459 hil_state
->rollspeed
= mavlink_msg_hil_state_get_rollspeed(msg
);
460 hil_state
->pitchspeed
= mavlink_msg_hil_state_get_pitchspeed(msg
);
461 hil_state
->yawspeed
= mavlink_msg_hil_state_get_yawspeed(msg
);
462 hil_state
->lat
= mavlink_msg_hil_state_get_lat(msg
);
463 hil_state
->lon
= mavlink_msg_hil_state_get_lon(msg
);
464 hil_state
->alt
= mavlink_msg_hil_state_get_alt(msg
);
465 hil_state
->vx
= mavlink_msg_hil_state_get_vx(msg
);
466 hil_state
->vy
= mavlink_msg_hil_state_get_vy(msg
);
467 hil_state
->vz
= mavlink_msg_hil_state_get_vz(msg
);
468 hil_state
->xacc
= mavlink_msg_hil_state_get_xacc(msg
);
469 hil_state
->yacc
= mavlink_msg_hil_state_get_yacc(msg
);
470 hil_state
->zacc
= mavlink_msg_hil_state_get_zacc(msg
);
472 memcpy(hil_state
, _MAV_PAYLOAD(msg
), 56);