before merging master
[inav.git] / lib / main / MAVLink / common / mavlink_msg_hil_sensor.h
blob007c5a6989a7e606a0d43dbe3b2b41c8aa5e3380
1 #pragma once
2 // MESSAGE HIL_SENSOR PACKING
4 #define MAVLINK_MSG_ID_HIL_SENSOR 107
7 typedef 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, bit 0 = xacc, bit 12: temperature, bit 31: full reset of attitude/position/velocities/etc was performed in sim.*/
23 uint8_t id; /*< Sensor ID (zero indexed). Used for multiple sensor inputs*/
24 } mavlink_hil_sensor_t;
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
31 #define MAVLINK_MSG_ID_HIL_SENSOR_CRC 108
32 #define MAVLINK_MSG_ID_107_CRC 108
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 } \
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 } \
81 #endif
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
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, bit 0 = xacc, bit 12: temperature, bit 31: full reset of attitude/position/velocities/etc was performed in sim.
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)
107 static 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)
110 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
111 char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
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);
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;
149 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
150 #endif
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);
157 * @brief Pack a hil_sensor 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 [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.
163 * @param xacc [m/s/s] X acceleration
164 * @param yacc [m/s/s] Y acceleration
165 * @param zacc [m/s/s] Z acceleration
166 * @param xgyro [rad/s] Angular speed around X axis in body frame
167 * @param ygyro [rad/s] Angular speed around Y axis in body frame
168 * @param zgyro [rad/s] Angular speed around Z axis in body frame
169 * @param xmag [gauss] X Magnetic field
170 * @param ymag [gauss] Y Magnetic field
171 * @param zmag [gauss] Z Magnetic field
172 * @param abs_pressure [hPa] Absolute pressure
173 * @param diff_pressure [hPa] Differential pressure (airspeed)
174 * @param pressure_alt Altitude calculated from pressure
175 * @param temperature [degC] Temperature
176 * @param fields_updated Bitmap for fields that have updated since last message, bit 0 = xacc, bit 12: temperature, bit 31: full reset of attitude/position/velocities/etc was performed in sim.
177 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
178 * @return length of the message in bytes (excluding serial stream start sign)
180 static inline uint16_t mavlink_msg_hil_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
181 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)
184 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
185 char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
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);
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;
223 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
224 #endif
226 msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
227 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);
231 * @brief Encode a hil_sensor 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_sensor C-struct to read the message contents from
238 static 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)
240 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);
244 * @brief Encode a hil_sensor 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_sensor C-struct to read the message contents from
252 static 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)
254 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);
258 * @brief Send a hil_sensor message
259 * @param chan MAVLink channel to send the message
261 * @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.
262 * @param xacc [m/s/s] X acceleration
263 * @param yacc [m/s/s] Y acceleration
264 * @param zacc [m/s/s] Z acceleration
265 * @param xgyro [rad/s] Angular speed around X axis in body frame
266 * @param ygyro [rad/s] Angular speed around Y axis in body frame
267 * @param zgyro [rad/s] Angular speed around Z axis in body frame
268 * @param xmag [gauss] X Magnetic field
269 * @param ymag [gauss] Y Magnetic field
270 * @param zmag [gauss] Z Magnetic field
271 * @param abs_pressure [hPa] Absolute pressure
272 * @param diff_pressure [hPa] Differential pressure (airspeed)
273 * @param pressure_alt Altitude calculated from pressure
274 * @param temperature [degC] Temperature
275 * @param fields_updated Bitmap for fields that have updated since last message, bit 0 = xacc, bit 12: temperature, bit 31: full reset of attitude/position/velocities/etc was performed in sim.
276 * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
278 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
280 static 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)
282 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
283 char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
284 _mav_put_uint64_t(buf, 0, time_usec);
285 _mav_put_float(buf, 8, xacc);
286 _mav_put_float(buf, 12, yacc);
287 _mav_put_float(buf, 16, zacc);
288 _mav_put_float(buf, 20, xgyro);
289 _mav_put_float(buf, 24, ygyro);
290 _mav_put_float(buf, 28, zgyro);
291 _mav_put_float(buf, 32, xmag);
292 _mav_put_float(buf, 36, ymag);
293 _mav_put_float(buf, 40, zmag);
294 _mav_put_float(buf, 44, abs_pressure);
295 _mav_put_float(buf, 48, diff_pressure);
296 _mav_put_float(buf, 52, pressure_alt);
297 _mav_put_float(buf, 56, temperature);
298 _mav_put_uint32_t(buf, 60, fields_updated);
299 _mav_put_uint8_t(buf, 64, id);
301 _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);
302 #else
303 mavlink_hil_sensor_t packet;
304 packet.time_usec = time_usec;
305 packet.xacc = xacc;
306 packet.yacc = yacc;
307 packet.zacc = zacc;
308 packet.xgyro = xgyro;
309 packet.ygyro = ygyro;
310 packet.zgyro = zgyro;
311 packet.xmag = xmag;
312 packet.ymag = ymag;
313 packet.zmag = zmag;
314 packet.abs_pressure = abs_pressure;
315 packet.diff_pressure = diff_pressure;
316 packet.pressure_alt = pressure_alt;
317 packet.temperature = temperature;
318 packet.fields_updated = fields_updated;
319 packet.id = id;
321 _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);
322 #endif
326 * @brief Send a hil_sensor 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_sensor_send_struct(mavlink_channel_t chan, const mavlink_hil_sensor_t* hil_sensor)
332 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
333 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);
334 #else
335 _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);
336 #endif
339 #if MAVLINK_MSG_ID_HIL_SENSOR_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_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)
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, xacc);
353 _mav_put_float(buf, 12, yacc);
354 _mav_put_float(buf, 16, zacc);
355 _mav_put_float(buf, 20, xgyro);
356 _mav_put_float(buf, 24, ygyro);
357 _mav_put_float(buf, 28, zgyro);
358 _mav_put_float(buf, 32, xmag);
359 _mav_put_float(buf, 36, ymag);
360 _mav_put_float(buf, 40, zmag);
361 _mav_put_float(buf, 44, abs_pressure);
362 _mav_put_float(buf, 48, diff_pressure);
363 _mav_put_float(buf, 52, pressure_alt);
364 _mav_put_float(buf, 56, temperature);
365 _mav_put_uint32_t(buf, 60, fields_updated);
366 _mav_put_uint8_t(buf, 64, id);
368 _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);
369 #else
370 mavlink_hil_sensor_t *packet = (mavlink_hil_sensor_t *)msgbuf;
371 packet->time_usec = time_usec;
372 packet->xacc = xacc;
373 packet->yacc = yacc;
374 packet->zacc = zacc;
375 packet->xgyro = xgyro;
376 packet->ygyro = ygyro;
377 packet->zgyro = zgyro;
378 packet->xmag = xmag;
379 packet->ymag = ymag;
380 packet->zmag = zmag;
381 packet->abs_pressure = abs_pressure;
382 packet->diff_pressure = diff_pressure;
383 packet->pressure_alt = pressure_alt;
384 packet->temperature = temperature;
385 packet->fields_updated = fields_updated;
386 packet->id = id;
388 _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);
389 #endif
391 #endif
393 #endif
395 // MESSAGE HIL_SENSOR UNPACKING
399 * @brief Get field time_usec from hil_sensor message
401 * @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.
403 static inline uint64_t mavlink_msg_hil_sensor_get_time_usec(const mavlink_message_t* msg)
405 return _MAV_RETURN_uint64_t(msg, 0);
409 * @brief Get field xacc from hil_sensor message
411 * @return [m/s/s] X acceleration
413 static inline float mavlink_msg_hil_sensor_get_xacc(const mavlink_message_t* msg)
415 return _MAV_RETURN_float(msg, 8);
419 * @brief Get field yacc from hil_sensor message
421 * @return [m/s/s] Y acceleration
423 static inline float mavlink_msg_hil_sensor_get_yacc(const mavlink_message_t* msg)
425 return _MAV_RETURN_float(msg, 12);
429 * @brief Get field zacc from hil_sensor message
431 * @return [m/s/s] Z acceleration
433 static inline float mavlink_msg_hil_sensor_get_zacc(const mavlink_message_t* msg)
435 return _MAV_RETURN_float(msg, 16);
439 * @brief Get field xgyro from hil_sensor message
441 * @return [rad/s] Angular speed around X axis in body frame
443 static inline float mavlink_msg_hil_sensor_get_xgyro(const mavlink_message_t* msg)
445 return _MAV_RETURN_float(msg, 20);
449 * @brief Get field ygyro from hil_sensor message
451 * @return [rad/s] Angular speed around Y axis in body frame
453 static inline float mavlink_msg_hil_sensor_get_ygyro(const mavlink_message_t* msg)
455 return _MAV_RETURN_float(msg, 24);
459 * @brief Get field zgyro from hil_sensor message
461 * @return [rad/s] Angular speed around Z axis in body frame
463 static inline float mavlink_msg_hil_sensor_get_zgyro(const mavlink_message_t* msg)
465 return _MAV_RETURN_float(msg, 28);
469 * @brief Get field xmag from hil_sensor message
471 * @return [gauss] X Magnetic field
473 static inline float mavlink_msg_hil_sensor_get_xmag(const mavlink_message_t* msg)
475 return _MAV_RETURN_float(msg, 32);
479 * @brief Get field ymag from hil_sensor message
481 * @return [gauss] Y Magnetic field
483 static inline float mavlink_msg_hil_sensor_get_ymag(const mavlink_message_t* msg)
485 return _MAV_RETURN_float(msg, 36);
489 * @brief Get field zmag from hil_sensor message
491 * @return [gauss] Z Magnetic field
493 static inline float mavlink_msg_hil_sensor_get_zmag(const mavlink_message_t* msg)
495 return _MAV_RETURN_float(msg, 40);
499 * @brief Get field abs_pressure from hil_sensor message
501 * @return [hPa] Absolute pressure
503 static inline float mavlink_msg_hil_sensor_get_abs_pressure(const mavlink_message_t* msg)
505 return _MAV_RETURN_float(msg, 44);
509 * @brief Get field diff_pressure from hil_sensor message
511 * @return [hPa] Differential pressure (airspeed)
513 static inline float mavlink_msg_hil_sensor_get_diff_pressure(const mavlink_message_t* msg)
515 return _MAV_RETURN_float(msg, 48);
519 * @brief Get field pressure_alt from hil_sensor message
521 * @return Altitude calculated from pressure
523 static inline float mavlink_msg_hil_sensor_get_pressure_alt(const mavlink_message_t* msg)
525 return _MAV_RETURN_float(msg, 52);
529 * @brief Get field temperature from hil_sensor message
531 * @return [degC] Temperature
533 static inline float mavlink_msg_hil_sensor_get_temperature(const mavlink_message_t* msg)
535 return _MAV_RETURN_float(msg, 56);
539 * @brief Get field fields_updated from hil_sensor message
541 * @return Bitmap for fields that have updated since last message, bit 0 = xacc, bit 12: temperature, bit 31: full reset of attitude/position/velocities/etc was performed in sim.
543 static inline uint32_t mavlink_msg_hil_sensor_get_fields_updated(const mavlink_message_t* msg)
545 return _MAV_RETURN_uint32_t(msg, 60);
549 * @brief Get field id from hil_sensor message
551 * @return Sensor ID (zero indexed). Used for multiple sensor inputs
553 static inline uint8_t mavlink_msg_hil_sensor_get_id(const mavlink_message_t* msg)
555 return _MAV_RETURN_uint8_t(msg, 64);
559 * @brief Decode a hil_sensor message into a struct
561 * @param msg The message to decode
562 * @param hil_sensor C-struct to decode the message contents into
564 static inline void mavlink_msg_hil_sensor_decode(const mavlink_message_t* msg, mavlink_hil_sensor_t* hil_sensor)
566 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
567 hil_sensor->time_usec = mavlink_msg_hil_sensor_get_time_usec(msg);
568 hil_sensor->xacc = mavlink_msg_hil_sensor_get_xacc(msg);
569 hil_sensor->yacc = mavlink_msg_hil_sensor_get_yacc(msg);
570 hil_sensor->zacc = mavlink_msg_hil_sensor_get_zacc(msg);
571 hil_sensor->xgyro = mavlink_msg_hil_sensor_get_xgyro(msg);
572 hil_sensor->ygyro = mavlink_msg_hil_sensor_get_ygyro(msg);
573 hil_sensor->zgyro = mavlink_msg_hil_sensor_get_zgyro(msg);
574 hil_sensor->xmag = mavlink_msg_hil_sensor_get_xmag(msg);
575 hil_sensor->ymag = mavlink_msg_hil_sensor_get_ymag(msg);
576 hil_sensor->zmag = mavlink_msg_hil_sensor_get_zmag(msg);
577 hil_sensor->abs_pressure = mavlink_msg_hil_sensor_get_abs_pressure(msg);
578 hil_sensor->diff_pressure = mavlink_msg_hil_sensor_get_diff_pressure(msg);
579 hil_sensor->pressure_alt = mavlink_msg_hil_sensor_get_pressure_alt(msg);
580 hil_sensor->temperature = mavlink_msg_hil_sensor_get_temperature(msg);
581 hil_sensor->fields_updated = mavlink_msg_hil_sensor_get_fields_updated(msg);
582 hil_sensor->id = mavlink_msg_hil_sensor_get_id(msg);
583 #else
584 uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_SENSOR_LEN? msg->len : MAVLINK_MSG_ID_HIL_SENSOR_LEN;
585 memset(hil_sensor, 0, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
586 memcpy(hil_sensor, _MAV_PAYLOAD(msg), len);
587 #endif