Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_hil_sensor.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE HIL_SENSOR PACKING
3
4#define MAVLINK_MSG_ID_HIL_SENSOR 107
5
6
7typedef struct __mavlink_hil_sensor_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 xacc; /*< [m/s/s] X acceleration*/
10 float yacc; /*< [m/s/s] Y acceleration*/
11 float zacc; /*< [m/s/s] Z acceleration*/
12 float xgyro; /*< [rad/s] Angular speed around X axis in body frame*/
13 float ygyro; /*< [rad/s] Angular speed around Y axis in body frame*/
14 float zgyro; /*< [rad/s] Angular speed around Z axis in body frame*/
15 float xmag; /*< [gauss] X Magnetic field*/
16 float ymag; /*< [gauss] Y Magnetic field*/
17 float zmag; /*< [gauss] Z Magnetic field*/
18 float abs_pressure; /*< [hPa] Absolute pressure*/
19 float diff_pressure; /*< [hPa] Differential pressure (airspeed)*/
20 float pressure_alt; /*< Altitude calculated from pressure*/
21 float temperature; /*< [degC] Temperature*/
22 uint32_t fields_updated; /*< Bitmap for fields that have updated since last message*/
23 uint8_t id; /*< Sensor ID (zero indexed). Used for multiple sensor inputs*/
24} mavlink_hil_sensor_t;
25
26#define MAVLINK_MSG_ID_HIL_SENSOR_LEN 65
27#define MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN 64
28#define MAVLINK_MSG_ID_107_LEN 65
29#define MAVLINK_MSG_ID_107_MIN_LEN 64
30
31#define MAVLINK_MSG_ID_HIL_SENSOR_CRC 108
32#define MAVLINK_MSG_ID_107_CRC 108
33
34
35
36#if MAVLINK_COMMAND_24BIT
37#define MAVLINK_MESSAGE_INFO_HIL_SENSOR {
38 107,
39 "HIL_SENSOR",
40 16,
41 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_sensor_t, time_usec) },
42 { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_sensor_t, xacc) },
43 { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_sensor_t, yacc) },
44 { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_sensor_t, zacc) },
45 { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_sensor_t, xgyro) },
46 { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_sensor_t, ygyro) },
47 { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_sensor_t, zgyro) },
48 { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_sensor_t, xmag) },
49 { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_sensor_t, ymag) },
50 { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_hil_sensor_t, zmag) },
51 { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_hil_sensor_t, abs_pressure) },
52 { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_hil_sensor_t, diff_pressure) },
53 { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_hil_sensor_t, pressure_alt) },
54 { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_hil_sensor_t, temperature) },
55 { "fields_updated", NULL, MAVLINK_TYPE_UINT32_T, 0, 60, offsetof(mavlink_hil_sensor_t, fields_updated) },
56 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 64, offsetof(mavlink_hil_sensor_t, id) },
57 } \
58}
59#else
60#define MAVLINK_MESSAGE_INFO_HIL_SENSOR {
61 "HIL_SENSOR",
62 16,
63 { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_sensor_t, time_usec) },
64 { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_sensor_t, xacc) },
65 { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_sensor_t, yacc) },
66 { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_sensor_t, zacc) },
67 { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_sensor_t, xgyro) },
68 { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_sensor_t, ygyro) },
69 { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_sensor_t, zgyro) },
70 { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_sensor_t, xmag) },
71 { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_sensor_t, ymag) },
72 { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_hil_sensor_t, zmag) },
73 { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_hil_sensor_t, abs_pressure) },
74 { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_hil_sensor_t, diff_pressure) },
75 { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_hil_sensor_t, pressure_alt) },
76 { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_hil_sensor_t, temperature) },
77 { "fields_updated", NULL, MAVLINK_TYPE_UINT32_T, 0, 60, offsetof(mavlink_hil_sensor_t, fields_updated) },
78 { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 64, offsetof(mavlink_hil_sensor_t, id) },
79 } \
80}
81#endif
82
83/**
84 * @brief Pack a hil_sensor 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 xacc [m/s/s] X acceleration
91 * @param yacc [m/s/s] Y acceleration
92 * @param zacc [m/s/s] Z acceleration
93 * @param xgyro [rad/s] Angular speed around X axis in body frame
94 * @param ygyro [rad/s] Angular speed around Y axis in body frame
95 * @param zgyro [rad/s] Angular speed around Z axis in body frame
96 * @param xmag [gauss] X Magnetic field
97 * @param ymag [gauss] Y Magnetic field
98 * @param zmag [gauss] Z Magnetic field
99 * @param abs_pressure [hPa] Absolute pressure
100 * @param diff_pressure [hPa] Differential pressure (airspeed)
101 * @param pressure_alt Altitude calculated from pressure
102 * @param temperature [degC] Temperature
103 * @param fields_updated Bitmap for fields that have updated since last message
104 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
105 * @return length of the message in bytes (excluding serial stream start sign)
106 */
107static inline uint16_t mavlink_msg_hil_sensor_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
108 uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint32_t fields_updated, uint8_t id)
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, xacc);
114 _mav_put_float(buf, 12, yacc);
115 _mav_put_float(buf, 16, zacc);
116 _mav_put_float(buf, 20, xgyro);
117 _mav_put_float(buf, 24, ygyro);
118 _mav_put_float(buf, 28, zgyro);
119 _mav_put_float(buf, 32, xmag);
120 _mav_put_float(buf, 36, ymag);
121 _mav_put_float(buf, 40, zmag);
122 _mav_put_float(buf, 44, abs_pressure);
123 _mav_put_float(buf, 48, diff_pressure);
124 _mav_put_float(buf, 52, pressure_alt);
125 _mav_put_float(buf, 56, temperature);
126 _mav_put_uint32_t(buf, 60, fields_updated);
127 _mav_put_uint8_t(buf, 64, id);
128
129 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
130#else
131 mavlink_hil_sensor_t packet;
132 packet.time_usec = time_usec;
133 packet.xacc = xacc;
134 packet.yacc = yacc;
135 packet.zacc = zacc;
136 packet.xgyro = xgyro;
137 packet.ygyro = ygyro;
138 packet.zgyro = zgyro;
139 packet.xmag = xmag;
140 packet.ymag = ymag;
141 packet.zmag = zmag;
142 packet.abs_pressure = abs_pressure;
143 packet.diff_pressure = diff_pressure;
144 packet.pressure_alt = pressure_alt;
145 packet.temperature = temperature;
146 packet.fields_updated = fields_updated;
147 packet.id = id;
148
149 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
150#endif
151
152 msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
153 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
154}
155
156/**
157 * @brief Pack a hil_sensor 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 xacc [m/s/s] X acceleration
165 * @param yacc [m/s/s] Y acceleration
166 * @param zacc [m/s/s] Z acceleration
167 * @param xgyro [rad/s] Angular speed around X axis in body frame
168 * @param ygyro [rad/s] Angular speed around Y axis in body frame
169 * @param zgyro [rad/s] Angular speed around Z axis in body frame
170 * @param xmag [gauss] X Magnetic field
171 * @param ymag [gauss] Y Magnetic field
172 * @param zmag [gauss] Z Magnetic field
173 * @param abs_pressure [hPa] Absolute pressure
174 * @param diff_pressure [hPa] Differential pressure (airspeed)
175 * @param pressure_alt Altitude calculated from pressure
176 * @param temperature [degC] Temperature
177 * @param fields_updated Bitmap for fields that have updated since last message
178 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
179 * @return length of the message in bytes (excluding serial stream start sign)
180 */
181static inline uint16_t mavlink_msg_hil_sensor_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
182 uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint32_t fields_updated, uint8_t id)
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, xacc);
188 _mav_put_float(buf, 12, yacc);
189 _mav_put_float(buf, 16, zacc);
190 _mav_put_float(buf, 20, xgyro);
191 _mav_put_float(buf, 24, ygyro);
192 _mav_put_float(buf, 28, zgyro);
193 _mav_put_float(buf, 32, xmag);
194 _mav_put_float(buf, 36, ymag);
195 _mav_put_float(buf, 40, zmag);
196 _mav_put_float(buf, 44, abs_pressure);
197 _mav_put_float(buf, 48, diff_pressure);
198 _mav_put_float(buf, 52, pressure_alt);
199 _mav_put_float(buf, 56, temperature);
200 _mav_put_uint32_t(buf, 60, fields_updated);
201 _mav_put_uint8_t(buf, 64, id);
202
203 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
204#else
205 mavlink_hil_sensor_t packet;
206 packet.time_usec = time_usec;
207 packet.xacc = xacc;
208 packet.yacc = yacc;
209 packet.zacc = zacc;
210 packet.xgyro = xgyro;
211 packet.ygyro = ygyro;
212 packet.zgyro = zgyro;
213 packet.xmag = xmag;
214 packet.ymag = ymag;
215 packet.zmag = zmag;
216 packet.abs_pressure = abs_pressure;
217 packet.diff_pressure = diff_pressure;
218 packet.pressure_alt = pressure_alt;
219 packet.temperature = temperature;
220 packet.fields_updated = fields_updated;
221 packet.id = id;
222
223 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
224#endif
225
226 msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
227#if MAVLINK_CRC_EXTRA
228 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
229#else
230 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
231#endif
232}
233
234/**
235 * @brief Pack a hil_sensor 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 xacc [m/s/s] X acceleration
242 * @param yacc [m/s/s] Y acceleration
243 * @param zacc [m/s/s] Z acceleration
244 * @param xgyro [rad/s] Angular speed around X axis in body frame
245 * @param ygyro [rad/s] Angular speed around Y axis in body frame
246 * @param zgyro [rad/s] Angular speed around Z axis in body frame
247 * @param xmag [gauss] X Magnetic field
248 * @param ymag [gauss] Y Magnetic field
249 * @param zmag [gauss] Z Magnetic field
250 * @param abs_pressure [hPa] Absolute pressure
251 * @param diff_pressure [hPa] Differential pressure (airspeed)
252 * @param pressure_alt Altitude calculated from pressure
253 * @param temperature [degC] Temperature
254 * @param fields_updated Bitmap for fields that have updated since last message
255 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
256 * @return length of the message in bytes (excluding serial stream start sign)
257 */
258static inline uint16_t mavlink_msg_hil_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
259 mavlink_message_t* msg,
260 uint64_t time_usec,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,float xmag,float ymag,float zmag,float abs_pressure,float diff_pressure,float pressure_alt,float temperature,uint32_t fields_updated,uint8_t id)
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, xacc);
266 _mav_put_float(buf, 12, yacc);
267 _mav_put_float(buf, 16, zacc);
268 _mav_put_float(buf, 20, xgyro);
269 _mav_put_float(buf, 24, ygyro);
270 _mav_put_float(buf, 28, zgyro);
271 _mav_put_float(buf, 32, xmag);
272 _mav_put_float(buf, 36, ymag);
273 _mav_put_float(buf, 40, zmag);
274 _mav_put_float(buf, 44, abs_pressure);
275 _mav_put_float(buf, 48, diff_pressure);
276 _mav_put_float(buf, 52, pressure_alt);
277 _mav_put_float(buf, 56, temperature);
278 _mav_put_uint32_t(buf, 60, fields_updated);
279 _mav_put_uint8_t(buf, 64, id);
280
281 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
282#else
283 mavlink_hil_sensor_t packet;
284 packet.time_usec = time_usec;
285 packet.xacc = xacc;
286 packet.yacc = yacc;
287 packet.zacc = zacc;
288 packet.xgyro = xgyro;
289 packet.ygyro = ygyro;
290 packet.zgyro = zgyro;
291 packet.xmag = xmag;
292 packet.ymag = ymag;
293 packet.zmag = zmag;
294 packet.abs_pressure = abs_pressure;
295 packet.diff_pressure = diff_pressure;
296 packet.pressure_alt = pressure_alt;
297 packet.temperature = temperature;
298 packet.fields_updated = fields_updated;
299 packet.id = id;
300
301 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
302#endif
303
304 msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
305 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
306}
307
308/**
309 * @brief Encode a hil_sensor 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_sensor C-struct to read the message contents from
315 */
316static inline uint16_t mavlink_msg_hil_sensor_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_sensor_t* hil_sensor)
317{
318 return mavlink_msg_hil_sensor_pack(system_id, component_id, msg, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id);
319}
320
321/**
322 * @brief Encode a hil_sensor 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_sensor C-struct to read the message contents from
329 */
330static inline uint16_t mavlink_msg_hil_sensor_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_sensor_t* hil_sensor)
331{
332 return mavlink_msg_hil_sensor_pack_chan(system_id, component_id, chan, msg, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id);
333}
334
335/**
336 * @brief Encode a hil_sensor 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_sensor C-struct to read the message contents from
343 */
344static inline uint16_t mavlink_msg_hil_sensor_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_hil_sensor_t* hil_sensor)
345{
346 return mavlink_msg_hil_sensor_pack_status(system_id, component_id, _status, msg, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id);
347}
348
349/**
350 * @brief Send a hil_sensor 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 xacc [m/s/s] X acceleration
355 * @param yacc [m/s/s] Y acceleration
356 * @param zacc [m/s/s] Z acceleration
357 * @param xgyro [rad/s] Angular speed around X axis in body frame
358 * @param ygyro [rad/s] Angular speed around Y axis in body frame
359 * @param zgyro [rad/s] Angular speed around Z axis in body frame
360 * @param xmag [gauss] X Magnetic field
361 * @param ymag [gauss] Y Magnetic field
362 * @param zmag [gauss] Z Magnetic field
363 * @param abs_pressure [hPa] Absolute pressure
364 * @param diff_pressure [hPa] Differential pressure (airspeed)
365 * @param pressure_alt Altitude calculated from pressure
366 * @param temperature [degC] Temperature
367 * @param fields_updated Bitmap for fields that have updated since last message
368 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
369 */
370#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
371
372static inline void mavlink_msg_hil_sensor_send(mavlink_channel_t chan, uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint32_t fields_updated, uint8_t id)
373{
374#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
375 char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
376 _mav_put_uint64_t(buf, 0, time_usec);
377 _mav_put_float(buf, 8, xacc);
378 _mav_put_float(buf, 12, yacc);
379 _mav_put_float(buf, 16, zacc);
380 _mav_put_float(buf, 20, xgyro);
381 _mav_put_float(buf, 24, ygyro);
382 _mav_put_float(buf, 28, zgyro);
383 _mav_put_float(buf, 32, xmag);
384 _mav_put_float(buf, 36, ymag);
385 _mav_put_float(buf, 40, zmag);
386 _mav_put_float(buf, 44, abs_pressure);
387 _mav_put_float(buf, 48, diff_pressure);
388 _mav_put_float(buf, 52, pressure_alt);
389 _mav_put_float(buf, 56, temperature);
390 _mav_put_uint32_t(buf, 60, fields_updated);
391 _mav_put_uint8_t(buf, 64, id);
392
393 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_SENSOR, buf, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
394#else
395 mavlink_hil_sensor_t packet;
396 packet.time_usec = time_usec;
397 packet.xacc = xacc;
398 packet.yacc = yacc;
399 packet.zacc = zacc;
400 packet.xgyro = xgyro;
401 packet.ygyro = ygyro;
402 packet.zgyro = zgyro;
403 packet.xmag = xmag;
404 packet.ymag = ymag;
405 packet.zmag = zmag;
406 packet.abs_pressure = abs_pressure;
407 packet.diff_pressure = diff_pressure;
408 packet.pressure_alt = pressure_alt;
409 packet.temperature = temperature;
410 packet.fields_updated = fields_updated;
411 packet.id = id;
412
413 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_SENSOR, (const char *)&packet, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
414#endif
415}
416
417/**
418 * @brief Send a hil_sensor 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_sensor_send_struct(mavlink_channel_t chan, const mavlink_hil_sensor_t* hil_sensor)
423{
424#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
425 mavlink_msg_hil_sensor_send(chan, hil_sensor->time_usec, hil_sensor->xacc, hil_sensor->yacc, hil_sensor->zacc, hil_sensor->xgyro, hil_sensor->ygyro, hil_sensor->zgyro, hil_sensor->xmag, hil_sensor->ymag, hil_sensor->zmag, hil_sensor->abs_pressure, hil_sensor->diff_pressure, hil_sensor->pressure_alt, hil_sensor->temperature, hil_sensor->fields_updated, hil_sensor->id);
426#else
427 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_SENSOR, (const char *)hil_sensor, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
428#endif
429}
430
431#if MAVLINK_MSG_ID_HIL_SENSOR_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_sensor_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint32_t fields_updated, uint8_t id)
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, xacc);
445 _mav_put_float(buf, 12, yacc);
446 _mav_put_float(buf, 16, zacc);
447 _mav_put_float(buf, 20, xgyro);
448 _mav_put_float(buf, 24, ygyro);
449 _mav_put_float(buf, 28, zgyro);
450 _mav_put_float(buf, 32, xmag);
451 _mav_put_float(buf, 36, ymag);
452 _mav_put_float(buf, 40, zmag);
453 _mav_put_float(buf, 44, abs_pressure);
454 _mav_put_float(buf, 48, diff_pressure);
455 _mav_put_float(buf, 52, pressure_alt);
456 _mav_put_float(buf, 56, temperature);
457 _mav_put_uint32_t(buf, 60, fields_updated);
458 _mav_put_uint8_t(buf, 64, id);
459
460 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_SENSOR, buf, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
461#else
462 mavlink_hil_sensor_t *packet = (mavlink_hil_sensor_t *)msgbuf;
463 packet->time_usec = time_usec;
464 packet->xacc = xacc;
465 packet->yacc = yacc;
466 packet->zacc = zacc;
467 packet->xgyro = xgyro;
468 packet->ygyro = ygyro;
469 packet->zgyro = zgyro;
470 packet->xmag = xmag;
471 packet->ymag = ymag;
472 packet->zmag = zmag;
473 packet->abs_pressure = abs_pressure;
474 packet->diff_pressure = diff_pressure;
475 packet->pressure_alt = pressure_alt;
476 packet->temperature = temperature;
477 packet->fields_updated = fields_updated;
478 packet->id = id;
479
480 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_SENSOR, (const char *)packet, MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN, MAVLINK_MSG_ID_HIL_SENSOR_LEN, MAVLINK_MSG_ID_HIL_SENSOR_CRC);
481#endif
482}
483#endif
484
485#endif
486
487// MESSAGE HIL_SENSOR UNPACKING
488
489
490/**
491 * @brief Get field time_usec from hil_sensor 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_sensor_get_time_usec(const mavlink_message_t* msg)
496{
497 return _MAV_RETURN_uint64_t(msg, 0);
498}
499
500/**
501 * @brief Get field xacc from hil_sensor message
502 *
503 * @return [m/s/s] X acceleration
504 */
505static inline float mavlink_msg_hil_sensor_get_xacc(const mavlink_message_t* msg)
506{
507 return _MAV_RETURN_float(msg, 8);
508}
509
510/**
511 * @brief Get field yacc from hil_sensor message
512 *
513 * @return [m/s/s] Y acceleration
514 */
515static inline float mavlink_msg_hil_sensor_get_yacc(const mavlink_message_t* msg)
516{
517 return _MAV_RETURN_float(msg, 12);
518}
519
520/**
521 * @brief Get field zacc from hil_sensor message
522 *
523 * @return [m/s/s] Z acceleration
524 */
525static inline float mavlink_msg_hil_sensor_get_zacc(const mavlink_message_t* msg)
526{
527 return _MAV_RETURN_float(msg, 16);
528}
529
530/**
531 * @brief Get field xgyro from hil_sensor message
532 *
533 * @return [rad/s] Angular speed around X axis in body frame
534 */
535static inline float mavlink_msg_hil_sensor_get_xgyro(const mavlink_message_t* msg)
536{
537 return _MAV_RETURN_float(msg, 20);
538}
539
540/**
541 * @brief Get field ygyro from hil_sensor message
542 *
543 * @return [rad/s] Angular speed around Y axis in body frame
544 */
545static inline float mavlink_msg_hil_sensor_get_ygyro(const mavlink_message_t* msg)
546{
547 return _MAV_RETURN_float(msg, 24);
548}
549
550/**
551 * @brief Get field zgyro from hil_sensor message
552 *
553 * @return [rad/s] Angular speed around Z axis in body frame
554 */
555static inline float mavlink_msg_hil_sensor_get_zgyro(const mavlink_message_t* msg)
556{
557 return _MAV_RETURN_float(msg, 28);
558}
559
560/**
561 * @brief Get field xmag from hil_sensor message
562 *
563 * @return [gauss] X Magnetic field
564 */
565static inline float mavlink_msg_hil_sensor_get_xmag(const mavlink_message_t* msg)
566{
567 return _MAV_RETURN_float(msg, 32);
568}
569
570/**
571 * @brief Get field ymag from hil_sensor message
572 *
573 * @return [gauss] Y Magnetic field
574 */
575static inline float mavlink_msg_hil_sensor_get_ymag(const mavlink_message_t* msg)
576{
577 return _MAV_RETURN_float(msg, 36);
578}
579
580/**
581 * @brief Get field zmag from hil_sensor message
582 *
583 * @return [gauss] Z Magnetic field
584 */
585static inline float mavlink_msg_hil_sensor_get_zmag(const mavlink_message_t* msg)
586{
587 return _MAV_RETURN_float(msg, 40);
588}
589
590/**
591 * @brief Get field abs_pressure from hil_sensor message
592 *
593 * @return [hPa] Absolute pressure
594 */
595static inline float mavlink_msg_hil_sensor_get_abs_pressure(const mavlink_message_t* msg)
596{
597 return _MAV_RETURN_float(msg, 44);
598}
599
600/**
601 * @brief Get field diff_pressure from hil_sensor message
602 *
603 * @return [hPa] Differential pressure (airspeed)
604 */
605static inline float mavlink_msg_hil_sensor_get_diff_pressure(const mavlink_message_t* msg)
606{
607 return _MAV_RETURN_float(msg, 48);
608}
609
610/**
611 * @brief Get field pressure_alt from hil_sensor message
612 *
613 * @return Altitude calculated from pressure
614 */
615static inline float mavlink_msg_hil_sensor_get_pressure_alt(const mavlink_message_t* msg)
616{
617 return _MAV_RETURN_float(msg, 52);
618}
619
620/**
621 * @brief Get field temperature from hil_sensor message
622 *
623 * @return [degC] Temperature
624 */
625static inline float mavlink_msg_hil_sensor_get_temperature(const mavlink_message_t* msg)
626{
627 return _MAV_RETURN_float(msg, 56);
628}
629
630/**
631 * @brief Get field fields_updated from hil_sensor message
632 *
633 * @return Bitmap for fields that have updated since last message
634 */
635static inline uint32_t mavlink_msg_hil_sensor_get_fields_updated(const mavlink_message_t* msg)
636{
637 return _MAV_RETURN_uint32_t(msg, 60);
638}
639
640/**
641 * @brief Get field id from hil_sensor message
642 *
643 * @return Sensor ID (zero indexed). Used for multiple sensor inputs
644 */
645static inline uint8_t mavlink_msg_hil_sensor_get_id(const mavlink_message_t* msg)
646{
647 return _MAV_RETURN_uint8_t(msg, 64);
648}
649
650/**
651 * @brief Decode a hil_sensor message into a struct
652 *
653 * @param msg The message to decode
654 * @param hil_sensor C-struct to decode the message contents into
655 */
656static inline void mavlink_msg_hil_sensor_decode(const mavlink_message_t* msg, mavlink_hil_sensor_t* hil_sensor)
657{
658#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
659 hil_sensor->time_usec = mavlink_msg_hil_sensor_get_time_usec(msg);
660 hil_sensor->xacc = mavlink_msg_hil_sensor_get_xacc(msg);
661 hil_sensor->yacc = mavlink_msg_hil_sensor_get_yacc(msg);
662 hil_sensor->zacc = mavlink_msg_hil_sensor_get_zacc(msg);
663 hil_sensor->xgyro = mavlink_msg_hil_sensor_get_xgyro(msg);
664 hil_sensor->ygyro = mavlink_msg_hil_sensor_get_ygyro(msg);
665 hil_sensor->zgyro = mavlink_msg_hil_sensor_get_zgyro(msg);
666 hil_sensor->xmag = mavlink_msg_hil_sensor_get_xmag(msg);
667 hil_sensor->ymag = mavlink_msg_hil_sensor_get_ymag(msg);
668 hil_sensor->zmag = mavlink_msg_hil_sensor_get_zmag(msg);
669 hil_sensor->abs_pressure = mavlink_msg_hil_sensor_get_abs_pressure(msg);
670 hil_sensor->diff_pressure = mavlink_msg_hil_sensor_get_diff_pressure(msg);
671 hil_sensor->pressure_alt = mavlink_msg_hil_sensor_get_pressure_alt(msg);
672 hil_sensor->temperature = mavlink_msg_hil_sensor_get_temperature(msg);
673 hil_sensor->fields_updated = mavlink_msg_hil_sensor_get_fields_updated(msg);
674 hil_sensor->id = mavlink_msg_hil_sensor_get_id(msg);
675#else
676 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_SENSOR_LEN? msg->len : MAVLINK_MSG_ID_HIL_SENSOR_LEN;
677 memset(hil_sensor, 0, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
678 memcpy(hil_sensor, _MAV_PAYLOAD(msg), len);
679#endif
680}