mavlink_msg_hil_sensor.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. #pragma once
  2. // MESSAGE HIL_SENSOR PACKING
  3. #define MAVLINK_MSG_ID_HIL_SENSOR 107
  4. typedef struct __mavlink_hil_sensor_t {
  5. 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.*/
  6. float xacc; /*< [m/s/s] X acceleration*/
  7. float yacc; /*< [m/s/s] Y acceleration*/
  8. float zacc; /*< [m/s/s] Z acceleration*/
  9. float xgyro; /*< [rad/s] Angular speed around X axis in body frame*/
  10. float ygyro; /*< [rad/s] Angular speed around Y axis in body frame*/
  11. float zgyro; /*< [rad/s] Angular speed around Z axis in body frame*/
  12. float xmag; /*< [gauss] X Magnetic field*/
  13. float ymag; /*< [gauss] Y Magnetic field*/
  14. float zmag; /*< [gauss] Z Magnetic field*/
  15. float abs_pressure; /*< [hPa] Absolute pressure*/
  16. float diff_pressure; /*< [hPa] Differential pressure (airspeed)*/
  17. float pressure_alt; /*< Altitude calculated from pressure*/
  18. float temperature; /*< [degC] Temperature*/
  19. uint32_t fields_updated; /*< Bitmap for fields that have updated since last message*/
  20. uint8_t id; /*< Sensor ID (zero indexed). Used for multiple sensor inputs*/
  21. } mavlink_hil_sensor_t;
  22. #define MAVLINK_MSG_ID_HIL_SENSOR_LEN 65
  23. #define MAVLINK_MSG_ID_HIL_SENSOR_MIN_LEN 64
  24. #define MAVLINK_MSG_ID_107_LEN 65
  25. #define MAVLINK_MSG_ID_107_MIN_LEN 64
  26. #define MAVLINK_MSG_ID_HIL_SENSOR_CRC 108
  27. #define MAVLINK_MSG_ID_107_CRC 108
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_HIL_SENSOR { \
  30. 107, \
  31. "HIL_SENSOR", \
  32. 16, \
  33. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_sensor_t, time_usec) }, \
  34. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_sensor_t, xacc) }, \
  35. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_sensor_t, yacc) }, \
  36. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_sensor_t, zacc) }, \
  37. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_sensor_t, xgyro) }, \
  38. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_sensor_t, ygyro) }, \
  39. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_sensor_t, zgyro) }, \
  40. { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_sensor_t, xmag) }, \
  41. { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_sensor_t, ymag) }, \
  42. { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_hil_sensor_t, zmag) }, \
  43. { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_hil_sensor_t, abs_pressure) }, \
  44. { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_hil_sensor_t, diff_pressure) }, \
  45. { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_hil_sensor_t, pressure_alt) }, \
  46. { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_hil_sensor_t, temperature) }, \
  47. { "fields_updated", NULL, MAVLINK_TYPE_UINT32_T, 0, 60, offsetof(mavlink_hil_sensor_t, fields_updated) }, \
  48. { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 64, offsetof(mavlink_hil_sensor_t, id) }, \
  49. } \
  50. }
  51. #else
  52. #define MAVLINK_MESSAGE_INFO_HIL_SENSOR { \
  53. "HIL_SENSOR", \
  54. 16, \
  55. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_sensor_t, time_usec) }, \
  56. { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_hil_sensor_t, xacc) }, \
  57. { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_hil_sensor_t, yacc) }, \
  58. { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_hil_sensor_t, zacc) }, \
  59. { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_hil_sensor_t, xgyro) }, \
  60. { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_hil_sensor_t, ygyro) }, \
  61. { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_hil_sensor_t, zgyro) }, \
  62. { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_hil_sensor_t, xmag) }, \
  63. { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_hil_sensor_t, ymag) }, \
  64. { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_hil_sensor_t, zmag) }, \
  65. { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_hil_sensor_t, abs_pressure) }, \
  66. { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_hil_sensor_t, diff_pressure) }, \
  67. { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_hil_sensor_t, pressure_alt) }, \
  68. { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_hil_sensor_t, temperature) }, \
  69. { "fields_updated", NULL, MAVLINK_TYPE_UINT32_T, 0, 60, offsetof(mavlink_hil_sensor_t, fields_updated) }, \
  70. { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 64, offsetof(mavlink_hil_sensor_t, id) }, \
  71. } \
  72. }
  73. #endif
  74. /**
  75. * @brief Pack a hil_sensor message
  76. * @param system_id ID of this system
  77. * @param component_id ID of this component (e.g. 200 for IMU)
  78. * @param msg The MAVLink message to compress the data into
  79. *
  80. * @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.
  81. * @param xacc [m/s/s] X acceleration
  82. * @param yacc [m/s/s] Y acceleration
  83. * @param zacc [m/s/s] Z acceleration
  84. * @param xgyro [rad/s] Angular speed around X axis in body frame
  85. * @param ygyro [rad/s] Angular speed around Y axis in body frame
  86. * @param zgyro [rad/s] Angular speed around Z axis in body frame
  87. * @param xmag [gauss] X Magnetic field
  88. * @param ymag [gauss] Y Magnetic field
  89. * @param zmag [gauss] Z Magnetic field
  90. * @param abs_pressure [hPa] Absolute pressure
  91. * @param diff_pressure [hPa] Differential pressure (airspeed)
  92. * @param pressure_alt Altitude calculated from pressure
  93. * @param temperature [degC] Temperature
  94. * @param fields_updated Bitmap for fields that have updated since last message
  95. * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_hil_sensor_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  99. 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)
  100. {
  101. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  102. char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
  103. _mav_put_uint64_t(buf, 0, time_usec);
  104. _mav_put_float(buf, 8, xacc);
  105. _mav_put_float(buf, 12, yacc);
  106. _mav_put_float(buf, 16, zacc);
  107. _mav_put_float(buf, 20, xgyro);
  108. _mav_put_float(buf, 24, ygyro);
  109. _mav_put_float(buf, 28, zgyro);
  110. _mav_put_float(buf, 32, xmag);
  111. _mav_put_float(buf, 36, ymag);
  112. _mav_put_float(buf, 40, zmag);
  113. _mav_put_float(buf, 44, abs_pressure);
  114. _mav_put_float(buf, 48, diff_pressure);
  115. _mav_put_float(buf, 52, pressure_alt);
  116. _mav_put_float(buf, 56, temperature);
  117. _mav_put_uint32_t(buf, 60, fields_updated);
  118. _mav_put_uint8_t(buf, 64, id);
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
  120. #else
  121. mavlink_hil_sensor_t packet;
  122. packet.time_usec = time_usec;
  123. packet.xacc = xacc;
  124. packet.yacc = yacc;
  125. packet.zacc = zacc;
  126. packet.xgyro = xgyro;
  127. packet.ygyro = ygyro;
  128. packet.zgyro = zgyro;
  129. packet.xmag = xmag;
  130. packet.ymag = ymag;
  131. packet.zmag = zmag;
  132. packet.abs_pressure = abs_pressure;
  133. packet.diff_pressure = diff_pressure;
  134. packet.pressure_alt = pressure_alt;
  135. packet.temperature = temperature;
  136. packet.fields_updated = fields_updated;
  137. packet.id = id;
  138. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
  139. #endif
  140. msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
  141. 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);
  142. }
  143. /**
  144. * @brief Pack a hil_sensor message on a channel
  145. * @param system_id ID of this system
  146. * @param component_id ID of this component (e.g. 200 for IMU)
  147. * @param chan The MAVLink channel this message will be sent over
  148. * @param msg The MAVLink message to compress the data into
  149. * @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.
  150. * @param xacc [m/s/s] X acceleration
  151. * @param yacc [m/s/s] Y acceleration
  152. * @param zacc [m/s/s] Z acceleration
  153. * @param xgyro [rad/s] Angular speed around X axis in body frame
  154. * @param ygyro [rad/s] Angular speed around Y axis in body frame
  155. * @param zgyro [rad/s] Angular speed around Z axis in body frame
  156. * @param xmag [gauss] X Magnetic field
  157. * @param ymag [gauss] Y Magnetic field
  158. * @param zmag [gauss] Z Magnetic field
  159. * @param abs_pressure [hPa] Absolute pressure
  160. * @param diff_pressure [hPa] Differential pressure (airspeed)
  161. * @param pressure_alt Altitude calculated from pressure
  162. * @param temperature [degC] Temperature
  163. * @param fields_updated Bitmap for fields that have updated since last message
  164. * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
  165. * @return length of the message in bytes (excluding serial stream start sign)
  166. */
  167. static inline uint16_t mavlink_msg_hil_sensor_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  168. mavlink_message_t* msg,
  169. 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)
  170. {
  171. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  172. char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
  173. _mav_put_uint64_t(buf, 0, time_usec);
  174. _mav_put_float(buf, 8, xacc);
  175. _mav_put_float(buf, 12, yacc);
  176. _mav_put_float(buf, 16, zacc);
  177. _mav_put_float(buf, 20, xgyro);
  178. _mav_put_float(buf, 24, ygyro);
  179. _mav_put_float(buf, 28, zgyro);
  180. _mav_put_float(buf, 32, xmag);
  181. _mav_put_float(buf, 36, ymag);
  182. _mav_put_float(buf, 40, zmag);
  183. _mav_put_float(buf, 44, abs_pressure);
  184. _mav_put_float(buf, 48, diff_pressure);
  185. _mav_put_float(buf, 52, pressure_alt);
  186. _mav_put_float(buf, 56, temperature);
  187. _mav_put_uint32_t(buf, 60, fields_updated);
  188. _mav_put_uint8_t(buf, 64, id);
  189. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
  190. #else
  191. mavlink_hil_sensor_t packet;
  192. packet.time_usec = time_usec;
  193. packet.xacc = xacc;
  194. packet.yacc = yacc;
  195. packet.zacc = zacc;
  196. packet.xgyro = xgyro;
  197. packet.ygyro = ygyro;
  198. packet.zgyro = zgyro;
  199. packet.xmag = xmag;
  200. packet.ymag = ymag;
  201. packet.zmag = zmag;
  202. packet.abs_pressure = abs_pressure;
  203. packet.diff_pressure = diff_pressure;
  204. packet.pressure_alt = pressure_alt;
  205. packet.temperature = temperature;
  206. packet.fields_updated = fields_updated;
  207. packet.id = id;
  208. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
  209. #endif
  210. msg->msgid = MAVLINK_MSG_ID_HIL_SENSOR;
  211. 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);
  212. }
  213. /**
  214. * @brief Encode a hil_sensor struct
  215. *
  216. * @param system_id ID of this system
  217. * @param component_id ID of this component (e.g. 200 for IMU)
  218. * @param msg The MAVLink message to compress the data into
  219. * @param hil_sensor C-struct to read the message contents from
  220. */
  221. 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)
  222. {
  223. 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);
  224. }
  225. /**
  226. * @brief Encode a hil_sensor struct on a channel
  227. *
  228. * @param system_id ID of this system
  229. * @param component_id ID of this component (e.g. 200 for IMU)
  230. * @param chan The MAVLink channel this message will be sent over
  231. * @param msg The MAVLink message to compress the data into
  232. * @param hil_sensor C-struct to read the message contents from
  233. */
  234. 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)
  235. {
  236. 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);
  237. }
  238. /**
  239. * @brief Send a hil_sensor message
  240. * @param chan MAVLink channel to send the message
  241. *
  242. * @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.
  243. * @param xacc [m/s/s] X acceleration
  244. * @param yacc [m/s/s] Y acceleration
  245. * @param zacc [m/s/s] Z acceleration
  246. * @param xgyro [rad/s] Angular speed around X axis in body frame
  247. * @param ygyro [rad/s] Angular speed around Y axis in body frame
  248. * @param zgyro [rad/s] Angular speed around Z axis in body frame
  249. * @param xmag [gauss] X Magnetic field
  250. * @param ymag [gauss] Y Magnetic field
  251. * @param zmag [gauss] Z Magnetic field
  252. * @param abs_pressure [hPa] Absolute pressure
  253. * @param diff_pressure [hPa] Differential pressure (airspeed)
  254. * @param pressure_alt Altitude calculated from pressure
  255. * @param temperature [degC] Temperature
  256. * @param fields_updated Bitmap for fields that have updated since last message
  257. * @param id Sensor ID (zero indexed). Used for multiple sensor inputs
  258. */
  259. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  260. 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)
  261. {
  262. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  263. char buf[MAVLINK_MSG_ID_HIL_SENSOR_LEN];
  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. _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);
  281. #else
  282. mavlink_hil_sensor_t packet;
  283. packet.time_usec = time_usec;
  284. packet.xacc = xacc;
  285. packet.yacc = yacc;
  286. packet.zacc = zacc;
  287. packet.xgyro = xgyro;
  288. packet.ygyro = ygyro;
  289. packet.zgyro = zgyro;
  290. packet.xmag = xmag;
  291. packet.ymag = ymag;
  292. packet.zmag = zmag;
  293. packet.abs_pressure = abs_pressure;
  294. packet.diff_pressure = diff_pressure;
  295. packet.pressure_alt = pressure_alt;
  296. packet.temperature = temperature;
  297. packet.fields_updated = fields_updated;
  298. packet.id = id;
  299. _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);
  300. #endif
  301. }
  302. /**
  303. * @brief Send a hil_sensor message
  304. * @param chan MAVLink channel to send the message
  305. * @param struct The MAVLink struct to serialize
  306. */
  307. static inline void mavlink_msg_hil_sensor_send_struct(mavlink_channel_t chan, const mavlink_hil_sensor_t* hil_sensor)
  308. {
  309. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  310. 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);
  311. #else
  312. _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);
  313. #endif
  314. }
  315. #if MAVLINK_MSG_ID_HIL_SENSOR_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  316. /*
  317. This variant of _send() can be used to save stack space by re-using
  318. memory from the receive buffer. The caller provides a
  319. mavlink_message_t which is the size of a full mavlink message. This
  320. is usually the receive buffer for the channel, and allows a reply to an
  321. incoming message with minimum stack space usage.
  322. */
  323. 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)
  324. {
  325. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  326. char *buf = (char *)msgbuf;
  327. _mav_put_uint64_t(buf, 0, time_usec);
  328. _mav_put_float(buf, 8, xacc);
  329. _mav_put_float(buf, 12, yacc);
  330. _mav_put_float(buf, 16, zacc);
  331. _mav_put_float(buf, 20, xgyro);
  332. _mav_put_float(buf, 24, ygyro);
  333. _mav_put_float(buf, 28, zgyro);
  334. _mav_put_float(buf, 32, xmag);
  335. _mav_put_float(buf, 36, ymag);
  336. _mav_put_float(buf, 40, zmag);
  337. _mav_put_float(buf, 44, abs_pressure);
  338. _mav_put_float(buf, 48, diff_pressure);
  339. _mav_put_float(buf, 52, pressure_alt);
  340. _mav_put_float(buf, 56, temperature);
  341. _mav_put_uint32_t(buf, 60, fields_updated);
  342. _mav_put_uint8_t(buf, 64, id);
  343. _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);
  344. #else
  345. mavlink_hil_sensor_t *packet = (mavlink_hil_sensor_t *)msgbuf;
  346. packet->time_usec = time_usec;
  347. packet->xacc = xacc;
  348. packet->yacc = yacc;
  349. packet->zacc = zacc;
  350. packet->xgyro = xgyro;
  351. packet->ygyro = ygyro;
  352. packet->zgyro = zgyro;
  353. packet->xmag = xmag;
  354. packet->ymag = ymag;
  355. packet->zmag = zmag;
  356. packet->abs_pressure = abs_pressure;
  357. packet->diff_pressure = diff_pressure;
  358. packet->pressure_alt = pressure_alt;
  359. packet->temperature = temperature;
  360. packet->fields_updated = fields_updated;
  361. packet->id = id;
  362. _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);
  363. #endif
  364. }
  365. #endif
  366. #endif
  367. // MESSAGE HIL_SENSOR UNPACKING
  368. /**
  369. * @brief Get field time_usec from hil_sensor message
  370. *
  371. * @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.
  372. */
  373. static inline uint64_t mavlink_msg_hil_sensor_get_time_usec(const mavlink_message_t* msg)
  374. {
  375. return _MAV_RETURN_uint64_t(msg, 0);
  376. }
  377. /**
  378. * @brief Get field xacc from hil_sensor message
  379. *
  380. * @return [m/s/s] X acceleration
  381. */
  382. static inline float mavlink_msg_hil_sensor_get_xacc(const mavlink_message_t* msg)
  383. {
  384. return _MAV_RETURN_float(msg, 8);
  385. }
  386. /**
  387. * @brief Get field yacc from hil_sensor message
  388. *
  389. * @return [m/s/s] Y acceleration
  390. */
  391. static inline float mavlink_msg_hil_sensor_get_yacc(const mavlink_message_t* msg)
  392. {
  393. return _MAV_RETURN_float(msg, 12);
  394. }
  395. /**
  396. * @brief Get field zacc from hil_sensor message
  397. *
  398. * @return [m/s/s] Z acceleration
  399. */
  400. static inline float mavlink_msg_hil_sensor_get_zacc(const mavlink_message_t* msg)
  401. {
  402. return _MAV_RETURN_float(msg, 16);
  403. }
  404. /**
  405. * @brief Get field xgyro from hil_sensor message
  406. *
  407. * @return [rad/s] Angular speed around X axis in body frame
  408. */
  409. static inline float mavlink_msg_hil_sensor_get_xgyro(const mavlink_message_t* msg)
  410. {
  411. return _MAV_RETURN_float(msg, 20);
  412. }
  413. /**
  414. * @brief Get field ygyro from hil_sensor message
  415. *
  416. * @return [rad/s] Angular speed around Y axis in body frame
  417. */
  418. static inline float mavlink_msg_hil_sensor_get_ygyro(const mavlink_message_t* msg)
  419. {
  420. return _MAV_RETURN_float(msg, 24);
  421. }
  422. /**
  423. * @brief Get field zgyro from hil_sensor message
  424. *
  425. * @return [rad/s] Angular speed around Z axis in body frame
  426. */
  427. static inline float mavlink_msg_hil_sensor_get_zgyro(const mavlink_message_t* msg)
  428. {
  429. return _MAV_RETURN_float(msg, 28);
  430. }
  431. /**
  432. * @brief Get field xmag from hil_sensor message
  433. *
  434. * @return [gauss] X Magnetic field
  435. */
  436. static inline float mavlink_msg_hil_sensor_get_xmag(const mavlink_message_t* msg)
  437. {
  438. return _MAV_RETURN_float(msg, 32);
  439. }
  440. /**
  441. * @brief Get field ymag from hil_sensor message
  442. *
  443. * @return [gauss] Y Magnetic field
  444. */
  445. static inline float mavlink_msg_hil_sensor_get_ymag(const mavlink_message_t* msg)
  446. {
  447. return _MAV_RETURN_float(msg, 36);
  448. }
  449. /**
  450. * @brief Get field zmag from hil_sensor message
  451. *
  452. * @return [gauss] Z Magnetic field
  453. */
  454. static inline float mavlink_msg_hil_sensor_get_zmag(const mavlink_message_t* msg)
  455. {
  456. return _MAV_RETURN_float(msg, 40);
  457. }
  458. /**
  459. * @brief Get field abs_pressure from hil_sensor message
  460. *
  461. * @return [hPa] Absolute pressure
  462. */
  463. static inline float mavlink_msg_hil_sensor_get_abs_pressure(const mavlink_message_t* msg)
  464. {
  465. return _MAV_RETURN_float(msg, 44);
  466. }
  467. /**
  468. * @brief Get field diff_pressure from hil_sensor message
  469. *
  470. * @return [hPa] Differential pressure (airspeed)
  471. */
  472. static inline float mavlink_msg_hil_sensor_get_diff_pressure(const mavlink_message_t* msg)
  473. {
  474. return _MAV_RETURN_float(msg, 48);
  475. }
  476. /**
  477. * @brief Get field pressure_alt from hil_sensor message
  478. *
  479. * @return Altitude calculated from pressure
  480. */
  481. static inline float mavlink_msg_hil_sensor_get_pressure_alt(const mavlink_message_t* msg)
  482. {
  483. return _MAV_RETURN_float(msg, 52);
  484. }
  485. /**
  486. * @brief Get field temperature from hil_sensor message
  487. *
  488. * @return [degC] Temperature
  489. */
  490. static inline float mavlink_msg_hil_sensor_get_temperature(const mavlink_message_t* msg)
  491. {
  492. return _MAV_RETURN_float(msg, 56);
  493. }
  494. /**
  495. * @brief Get field fields_updated from hil_sensor message
  496. *
  497. * @return Bitmap for fields that have updated since last message
  498. */
  499. static inline uint32_t mavlink_msg_hil_sensor_get_fields_updated(const mavlink_message_t* msg)
  500. {
  501. return _MAV_RETURN_uint32_t(msg, 60);
  502. }
  503. /**
  504. * @brief Get field id from hil_sensor message
  505. *
  506. * @return Sensor ID (zero indexed). Used for multiple sensor inputs
  507. */
  508. static inline uint8_t mavlink_msg_hil_sensor_get_id(const mavlink_message_t* msg)
  509. {
  510. return _MAV_RETURN_uint8_t(msg, 64);
  511. }
  512. /**
  513. * @brief Decode a hil_sensor message into a struct
  514. *
  515. * @param msg The message to decode
  516. * @param hil_sensor C-struct to decode the message contents into
  517. */
  518. static inline void mavlink_msg_hil_sensor_decode(const mavlink_message_t* msg, mavlink_hil_sensor_t* hil_sensor)
  519. {
  520. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  521. hil_sensor->time_usec = mavlink_msg_hil_sensor_get_time_usec(msg);
  522. hil_sensor->xacc = mavlink_msg_hil_sensor_get_xacc(msg);
  523. hil_sensor->yacc = mavlink_msg_hil_sensor_get_yacc(msg);
  524. hil_sensor->zacc = mavlink_msg_hil_sensor_get_zacc(msg);
  525. hil_sensor->xgyro = mavlink_msg_hil_sensor_get_xgyro(msg);
  526. hil_sensor->ygyro = mavlink_msg_hil_sensor_get_ygyro(msg);
  527. hil_sensor->zgyro = mavlink_msg_hil_sensor_get_zgyro(msg);
  528. hil_sensor->xmag = mavlink_msg_hil_sensor_get_xmag(msg);
  529. hil_sensor->ymag = mavlink_msg_hil_sensor_get_ymag(msg);
  530. hil_sensor->zmag = mavlink_msg_hil_sensor_get_zmag(msg);
  531. hil_sensor->abs_pressure = mavlink_msg_hil_sensor_get_abs_pressure(msg);
  532. hil_sensor->diff_pressure = mavlink_msg_hil_sensor_get_diff_pressure(msg);
  533. hil_sensor->pressure_alt = mavlink_msg_hil_sensor_get_pressure_alt(msg);
  534. hil_sensor->temperature = mavlink_msg_hil_sensor_get_temperature(msg);
  535. hil_sensor->fields_updated = mavlink_msg_hil_sensor_get_fields_updated(msg);
  536. hil_sensor->id = mavlink_msg_hil_sensor_get_id(msg);
  537. #else
  538. uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_SENSOR_LEN? msg->len : MAVLINK_MSG_ID_HIL_SENSOR_LEN;
  539. memset(hil_sensor, 0, MAVLINK_MSG_ID_HIL_SENSOR_LEN);
  540. memcpy(hil_sensor, _MAV_PAYLOAD(msg), len);
  541. #endif
  542. }