/libraries/GCS_MAVLink/include/mavlink/v0.9/ardupilotmega/mavlink_msg_sensor_offsets.h

https://github.com/pchickey/purple-ardupilot-mega · C Header · 386 lines · 217 code · 36 blank · 133 comment · 3 complexity · 01f7396b0191443f8da428b28d4e047c MD5 · raw file

  1. // MESSAGE SENSOR_OFFSETS PACKING
  2. #define MAVLINK_MSG_ID_SENSOR_OFFSETS 150
  3. typedef struct __mavlink_sensor_offsets_t
  4. {
  5. int16_t mag_ofs_x; ///< magnetometer X offset
  6. int16_t mag_ofs_y; ///< magnetometer Y offset
  7. int16_t mag_ofs_z; ///< magnetometer Z offset
  8. float mag_declination; ///< magnetic declination (radians)
  9. int32_t raw_press; ///< raw pressure from barometer
  10. int32_t raw_temp; ///< raw temperature from barometer
  11. float gyro_cal_x; ///< gyro X calibration
  12. float gyro_cal_y; ///< gyro Y calibration
  13. float gyro_cal_z; ///< gyro Z calibration
  14. float accel_cal_x; ///< accel X calibration
  15. float accel_cal_y; ///< accel Y calibration
  16. float accel_cal_z; ///< accel Z calibration
  17. } mavlink_sensor_offsets_t;
  18. #define MAVLINK_MSG_ID_SENSOR_OFFSETS_LEN 42
  19. #define MAVLINK_MSG_ID_150_LEN 42
  20. #define MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS { \
  21. "SENSOR_OFFSETS", \
  22. 12, \
  23. { { "mag_ofs_x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_sensor_offsets_t, mag_ofs_x) }, \
  24. { "mag_ofs_y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_sensor_offsets_t, mag_ofs_y) }, \
  25. { "mag_ofs_z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_sensor_offsets_t, mag_ofs_z) }, \
  26. { "mag_declination", NULL, MAVLINK_TYPE_FLOAT, 0, 6, offsetof(mavlink_sensor_offsets_t, mag_declination) }, \
  27. { "raw_press", NULL, MAVLINK_TYPE_INT32_T, 0, 10, offsetof(mavlink_sensor_offsets_t, raw_press) }, \
  28. { "raw_temp", NULL, MAVLINK_TYPE_INT32_T, 0, 14, offsetof(mavlink_sensor_offsets_t, raw_temp) }, \
  29. { "gyro_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 18, offsetof(mavlink_sensor_offsets_t, gyro_cal_x) }, \
  30. { "gyro_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 22, offsetof(mavlink_sensor_offsets_t, gyro_cal_y) }, \
  31. { "gyro_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 26, offsetof(mavlink_sensor_offsets_t, gyro_cal_z) }, \
  32. { "accel_cal_x", NULL, MAVLINK_TYPE_FLOAT, 0, 30, offsetof(mavlink_sensor_offsets_t, accel_cal_x) }, \
  33. { "accel_cal_y", NULL, MAVLINK_TYPE_FLOAT, 0, 34, offsetof(mavlink_sensor_offsets_t, accel_cal_y) }, \
  34. { "accel_cal_z", NULL, MAVLINK_TYPE_FLOAT, 0, 38, offsetof(mavlink_sensor_offsets_t, accel_cal_z) }, \
  35. } \
  36. }
  37. /**
  38. * @brief Pack a sensor_offsets message
  39. * @param system_id ID of this system
  40. * @param component_id ID of this component (e.g. 200 for IMU)
  41. * @param msg The MAVLink message to compress the data into
  42. *
  43. * @param mag_ofs_x magnetometer X offset
  44. * @param mag_ofs_y magnetometer Y offset
  45. * @param mag_ofs_z magnetometer Z offset
  46. * @param mag_declination magnetic declination (radians)
  47. * @param raw_press raw pressure from barometer
  48. * @param raw_temp raw temperature from barometer
  49. * @param gyro_cal_x gyro X calibration
  50. * @param gyro_cal_y gyro Y calibration
  51. * @param gyro_cal_z gyro Z calibration
  52. * @param accel_cal_x accel X calibration
  53. * @param accel_cal_y accel Y calibration
  54. * @param accel_cal_z accel Z calibration
  55. * @return length of the message in bytes (excluding serial stream start sign)
  56. */
  57. static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  58. int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
  59. {
  60. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  61. char buf[42];
  62. _mav_put_int16_t(buf, 0, mag_ofs_x);
  63. _mav_put_int16_t(buf, 2, mag_ofs_y);
  64. _mav_put_int16_t(buf, 4, mag_ofs_z);
  65. _mav_put_float(buf, 6, mag_declination);
  66. _mav_put_int32_t(buf, 10, raw_press);
  67. _mav_put_int32_t(buf, 14, raw_temp);
  68. _mav_put_float(buf, 18, gyro_cal_x);
  69. _mav_put_float(buf, 22, gyro_cal_y);
  70. _mav_put_float(buf, 26, gyro_cal_z);
  71. _mav_put_float(buf, 30, accel_cal_x);
  72. _mav_put_float(buf, 34, accel_cal_y);
  73. _mav_put_float(buf, 38, accel_cal_z);
  74. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
  75. #else
  76. mavlink_sensor_offsets_t packet;
  77. packet.mag_ofs_x = mag_ofs_x;
  78. packet.mag_ofs_y = mag_ofs_y;
  79. packet.mag_ofs_z = mag_ofs_z;
  80. packet.mag_declination = mag_declination;
  81. packet.raw_press = raw_press;
  82. packet.raw_temp = raw_temp;
  83. packet.gyro_cal_x = gyro_cal_x;
  84. packet.gyro_cal_y = gyro_cal_y;
  85. packet.gyro_cal_z = gyro_cal_z;
  86. packet.accel_cal_x = accel_cal_x;
  87. packet.accel_cal_y = accel_cal_y;
  88. packet.accel_cal_z = accel_cal_z;
  89. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
  90. #endif
  91. msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
  92. return mavlink_finalize_message(msg, system_id, component_id, 42);
  93. }
  94. /**
  95. * @brief Pack a sensor_offsets message on a channel
  96. * @param system_id ID of this system
  97. * @param component_id ID of this component (e.g. 200 for IMU)
  98. * @param chan The MAVLink channel this message was sent over
  99. * @param msg The MAVLink message to compress the data into
  100. * @param mag_ofs_x magnetometer X offset
  101. * @param mag_ofs_y magnetometer Y offset
  102. * @param mag_ofs_z magnetometer Z offset
  103. * @param mag_declination magnetic declination (radians)
  104. * @param raw_press raw pressure from barometer
  105. * @param raw_temp raw temperature from barometer
  106. * @param gyro_cal_x gyro X calibration
  107. * @param gyro_cal_y gyro Y calibration
  108. * @param gyro_cal_z gyro Z calibration
  109. * @param accel_cal_x accel X calibration
  110. * @param accel_cal_y accel Y calibration
  111. * @param accel_cal_z accel Z calibration
  112. * @return length of the message in bytes (excluding serial stream start sign)
  113. */
  114. static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  115. mavlink_message_t* msg,
  116. int16_t mag_ofs_x,int16_t mag_ofs_y,int16_t mag_ofs_z,float mag_declination,int32_t raw_press,int32_t raw_temp,float gyro_cal_x,float gyro_cal_y,float gyro_cal_z,float accel_cal_x,float accel_cal_y,float accel_cal_z)
  117. {
  118. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  119. char buf[42];
  120. _mav_put_int16_t(buf, 0, mag_ofs_x);
  121. _mav_put_int16_t(buf, 2, mag_ofs_y);
  122. _mav_put_int16_t(buf, 4, mag_ofs_z);
  123. _mav_put_float(buf, 6, mag_declination);
  124. _mav_put_int32_t(buf, 10, raw_press);
  125. _mav_put_int32_t(buf, 14, raw_temp);
  126. _mav_put_float(buf, 18, gyro_cal_x);
  127. _mav_put_float(buf, 22, gyro_cal_y);
  128. _mav_put_float(buf, 26, gyro_cal_z);
  129. _mav_put_float(buf, 30, accel_cal_x);
  130. _mav_put_float(buf, 34, accel_cal_y);
  131. _mav_put_float(buf, 38, accel_cal_z);
  132. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42);
  133. #else
  134. mavlink_sensor_offsets_t packet;
  135. packet.mag_ofs_x = mag_ofs_x;
  136. packet.mag_ofs_y = mag_ofs_y;
  137. packet.mag_ofs_z = mag_ofs_z;
  138. packet.mag_declination = mag_declination;
  139. packet.raw_press = raw_press;
  140. packet.raw_temp = raw_temp;
  141. packet.gyro_cal_x = gyro_cal_x;
  142. packet.gyro_cal_y = gyro_cal_y;
  143. packet.gyro_cal_z = gyro_cal_z;
  144. packet.accel_cal_x = accel_cal_x;
  145. packet.accel_cal_y = accel_cal_y;
  146. packet.accel_cal_z = accel_cal_z;
  147. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42);
  148. #endif
  149. msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS;
  150. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42);
  151. }
  152. /**
  153. * @brief Encode a sensor_offsets struct into a message
  154. *
  155. * @param system_id ID of this system
  156. * @param component_id ID of this component (e.g. 200 for IMU)
  157. * @param msg The MAVLink message to compress the data into
  158. * @param sensor_offsets C-struct to read the message contents from
  159. */
  160. static inline uint16_t mavlink_msg_sensor_offsets_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sensor_offsets_t* sensor_offsets)
  161. {
  162. return mavlink_msg_sensor_offsets_pack(system_id, component_id, msg, sensor_offsets->mag_ofs_x, sensor_offsets->mag_ofs_y, sensor_offsets->mag_ofs_z, sensor_offsets->mag_declination, sensor_offsets->raw_press, sensor_offsets->raw_temp, sensor_offsets->gyro_cal_x, sensor_offsets->gyro_cal_y, sensor_offsets->gyro_cal_z, sensor_offsets->accel_cal_x, sensor_offsets->accel_cal_y, sensor_offsets->accel_cal_z);
  163. }
  164. /**
  165. * @brief Send a sensor_offsets message
  166. * @param chan MAVLink channel to send the message
  167. *
  168. * @param mag_ofs_x magnetometer X offset
  169. * @param mag_ofs_y magnetometer Y offset
  170. * @param mag_ofs_z magnetometer Z offset
  171. * @param mag_declination magnetic declination (radians)
  172. * @param raw_press raw pressure from barometer
  173. * @param raw_temp raw temperature from barometer
  174. * @param gyro_cal_x gyro X calibration
  175. * @param gyro_cal_y gyro Y calibration
  176. * @param gyro_cal_z gyro Z calibration
  177. * @param accel_cal_x accel X calibration
  178. * @param accel_cal_y accel Y calibration
  179. * @param accel_cal_z accel Z calibration
  180. */
  181. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  182. static inline void mavlink_msg_sensor_offsets_send(mavlink_channel_t chan, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z, float mag_declination, int32_t raw_press, int32_t raw_temp, float gyro_cal_x, float gyro_cal_y, float gyro_cal_z, float accel_cal_x, float accel_cal_y, float accel_cal_z)
  183. {
  184. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  185. char buf[42];
  186. _mav_put_int16_t(buf, 0, mag_ofs_x);
  187. _mav_put_int16_t(buf, 2, mag_ofs_y);
  188. _mav_put_int16_t(buf, 4, mag_ofs_z);
  189. _mav_put_float(buf, 6, mag_declination);
  190. _mav_put_int32_t(buf, 10, raw_press);
  191. _mav_put_int32_t(buf, 14, raw_temp);
  192. _mav_put_float(buf, 18, gyro_cal_x);
  193. _mav_put_float(buf, 22, gyro_cal_y);
  194. _mav_put_float(buf, 26, gyro_cal_z);
  195. _mav_put_float(buf, 30, accel_cal_x);
  196. _mav_put_float(buf, 34, accel_cal_y);
  197. _mav_put_float(buf, 38, accel_cal_z);
  198. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, buf, 42);
  199. #else
  200. mavlink_sensor_offsets_t packet;
  201. packet.mag_ofs_x = mag_ofs_x;
  202. packet.mag_ofs_y = mag_ofs_y;
  203. packet.mag_ofs_z = mag_ofs_z;
  204. packet.mag_declination = mag_declination;
  205. packet.raw_press = raw_press;
  206. packet.raw_temp = raw_temp;
  207. packet.gyro_cal_x = gyro_cal_x;
  208. packet.gyro_cal_y = gyro_cal_y;
  209. packet.gyro_cal_z = gyro_cal_z;
  210. packet.accel_cal_x = accel_cal_x;
  211. packet.accel_cal_y = accel_cal_y;
  212. packet.accel_cal_z = accel_cal_z;
  213. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSOR_OFFSETS, (const char *)&packet, 42);
  214. #endif
  215. }
  216. #endif
  217. // MESSAGE SENSOR_OFFSETS UNPACKING
  218. /**
  219. * @brief Get field mag_ofs_x from sensor_offsets message
  220. *
  221. * @return magnetometer X offset
  222. */
  223. static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_x(const mavlink_message_t* msg)
  224. {
  225. return _MAV_RETURN_int16_t(msg, 0);
  226. }
  227. /**
  228. * @brief Get field mag_ofs_y from sensor_offsets message
  229. *
  230. * @return magnetometer Y offset
  231. */
  232. static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_y(const mavlink_message_t* msg)
  233. {
  234. return _MAV_RETURN_int16_t(msg, 2);
  235. }
  236. /**
  237. * @brief Get field mag_ofs_z from sensor_offsets message
  238. *
  239. * @return magnetometer Z offset
  240. */
  241. static inline int16_t mavlink_msg_sensor_offsets_get_mag_ofs_z(const mavlink_message_t* msg)
  242. {
  243. return _MAV_RETURN_int16_t(msg, 4);
  244. }
  245. /**
  246. * @brief Get field mag_declination from sensor_offsets message
  247. *
  248. * @return magnetic declination (radians)
  249. */
  250. static inline float mavlink_msg_sensor_offsets_get_mag_declination(const mavlink_message_t* msg)
  251. {
  252. return _MAV_RETURN_float(msg, 6);
  253. }
  254. /**
  255. * @brief Get field raw_press from sensor_offsets message
  256. *
  257. * @return raw pressure from barometer
  258. */
  259. static inline int32_t mavlink_msg_sensor_offsets_get_raw_press(const mavlink_message_t* msg)
  260. {
  261. return _MAV_RETURN_int32_t(msg, 10);
  262. }
  263. /**
  264. * @brief Get field raw_temp from sensor_offsets message
  265. *
  266. * @return raw temperature from barometer
  267. */
  268. static inline int32_t mavlink_msg_sensor_offsets_get_raw_temp(const mavlink_message_t* msg)
  269. {
  270. return _MAV_RETURN_int32_t(msg, 14);
  271. }
  272. /**
  273. * @brief Get field gyro_cal_x from sensor_offsets message
  274. *
  275. * @return gyro X calibration
  276. */
  277. static inline float mavlink_msg_sensor_offsets_get_gyro_cal_x(const mavlink_message_t* msg)
  278. {
  279. return _MAV_RETURN_float(msg, 18);
  280. }
  281. /**
  282. * @brief Get field gyro_cal_y from sensor_offsets message
  283. *
  284. * @return gyro Y calibration
  285. */
  286. static inline float mavlink_msg_sensor_offsets_get_gyro_cal_y(const mavlink_message_t* msg)
  287. {
  288. return _MAV_RETURN_float(msg, 22);
  289. }
  290. /**
  291. * @brief Get field gyro_cal_z from sensor_offsets message
  292. *
  293. * @return gyro Z calibration
  294. */
  295. static inline float mavlink_msg_sensor_offsets_get_gyro_cal_z(const mavlink_message_t* msg)
  296. {
  297. return _MAV_RETURN_float(msg, 26);
  298. }
  299. /**
  300. * @brief Get field accel_cal_x from sensor_offsets message
  301. *
  302. * @return accel X calibration
  303. */
  304. static inline float mavlink_msg_sensor_offsets_get_accel_cal_x(const mavlink_message_t* msg)
  305. {
  306. return _MAV_RETURN_float(msg, 30);
  307. }
  308. /**
  309. * @brief Get field accel_cal_y from sensor_offsets message
  310. *
  311. * @return accel Y calibration
  312. */
  313. static inline float mavlink_msg_sensor_offsets_get_accel_cal_y(const mavlink_message_t* msg)
  314. {
  315. return _MAV_RETURN_float(msg, 34);
  316. }
  317. /**
  318. * @brief Get field accel_cal_z from sensor_offsets message
  319. *
  320. * @return accel Z calibration
  321. */
  322. static inline float mavlink_msg_sensor_offsets_get_accel_cal_z(const mavlink_message_t* msg)
  323. {
  324. return _MAV_RETURN_float(msg, 38);
  325. }
  326. /**
  327. * @brief Decode a sensor_offsets message into a struct
  328. *
  329. * @param msg The message to decode
  330. * @param sensor_offsets C-struct to decode the message contents into
  331. */
  332. static inline void mavlink_msg_sensor_offsets_decode(const mavlink_message_t* msg, mavlink_sensor_offsets_t* sensor_offsets)
  333. {
  334. #if MAVLINK_NEED_BYTE_SWAP
  335. sensor_offsets->mag_ofs_x = mavlink_msg_sensor_offsets_get_mag_ofs_x(msg);
  336. sensor_offsets->mag_ofs_y = mavlink_msg_sensor_offsets_get_mag_ofs_y(msg);
  337. sensor_offsets->mag_ofs_z = mavlink_msg_sensor_offsets_get_mag_ofs_z(msg);
  338. sensor_offsets->mag_declination = mavlink_msg_sensor_offsets_get_mag_declination(msg);
  339. sensor_offsets->raw_press = mavlink_msg_sensor_offsets_get_raw_press(msg);
  340. sensor_offsets->raw_temp = mavlink_msg_sensor_offsets_get_raw_temp(msg);
  341. sensor_offsets->gyro_cal_x = mavlink_msg_sensor_offsets_get_gyro_cal_x(msg);
  342. sensor_offsets->gyro_cal_y = mavlink_msg_sensor_offsets_get_gyro_cal_y(msg);
  343. sensor_offsets->gyro_cal_z = mavlink_msg_sensor_offsets_get_gyro_cal_z(msg);
  344. sensor_offsets->accel_cal_x = mavlink_msg_sensor_offsets_get_accel_cal_x(msg);
  345. sensor_offsets->accel_cal_y = mavlink_msg_sensor_offsets_get_accel_cal_y(msg);
  346. sensor_offsets->accel_cal_z = mavlink_msg_sensor_offsets_get_accel_cal_z(msg);
  347. #else
  348. memcpy(sensor_offsets, _MAV_PAYLOAD(msg), 42);
  349. #endif
  350. }