mavlink_msg_mag_cal_report.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. #pragma once
  2. // MESSAGE MAG_CAL_REPORT PACKING
  3. #define MAVLINK_MSG_ID_MAG_CAL_REPORT 192
  4. MAVPACKED(
  5. typedef struct __mavlink_mag_cal_report_t {
  6. float fitness; /*< [mgauss] RMS milligauss residuals.*/
  7. float ofs_x; /*< X offset.*/
  8. float ofs_y; /*< Y offset.*/
  9. float ofs_z; /*< Z offset.*/
  10. float diag_x; /*< X diagonal (matrix 11).*/
  11. float diag_y; /*< Y diagonal (matrix 22).*/
  12. float diag_z; /*< Z diagonal (matrix 33).*/
  13. float offdiag_x; /*< X off-diagonal (matrix 12 and 21).*/
  14. float offdiag_y; /*< Y off-diagonal (matrix 13 and 31).*/
  15. float offdiag_z; /*< Z off-diagonal (matrix 32 and 23).*/
  16. uint8_t compass_id; /*< Compass being calibrated.*/
  17. uint8_t cal_mask; /*< Bitmask of compasses being calibrated.*/
  18. uint8_t cal_status; /*< Calibration Status.*/
  19. uint8_t autosaved; /*< 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.*/
  20. float orientation_confidence; /*< Confidence in orientation (higher is better).*/
  21. uint8_t old_orientation; /*< orientation before calibration.*/
  22. uint8_t new_orientation; /*< orientation after calibration.*/
  23. float scale_factor; /*< field radius correction factor*/
  24. }) mavlink_mag_cal_report_t;
  25. #define MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN 54
  26. #define MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN 44
  27. #define MAVLINK_MSG_ID_192_LEN 54
  28. #define MAVLINK_MSG_ID_192_MIN_LEN 44
  29. #define MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC 36
  30. #define MAVLINK_MSG_ID_192_CRC 36
  31. #if MAVLINK_COMMAND_24BIT
  32. #define MAVLINK_MESSAGE_INFO_MAG_CAL_REPORT { \
  33. 192, \
  34. "MAG_CAL_REPORT", \
  35. 18, \
  36. { { "compass_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_mag_cal_report_t, compass_id) }, \
  37. { "cal_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_mag_cal_report_t, cal_mask) }, \
  38. { "cal_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_mag_cal_report_t, cal_status) }, \
  39. { "autosaved", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_mag_cal_report_t, autosaved) }, \
  40. { "fitness", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mag_cal_report_t, fitness) }, \
  41. { "ofs_x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mag_cal_report_t, ofs_x) }, \
  42. { "ofs_y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mag_cal_report_t, ofs_y) }, \
  43. { "ofs_z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mag_cal_report_t, ofs_z) }, \
  44. { "diag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mag_cal_report_t, diag_x) }, \
  45. { "diag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mag_cal_report_t, diag_y) }, \
  46. { "diag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mag_cal_report_t, diag_z) }, \
  47. { "offdiag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_mag_cal_report_t, offdiag_x) }, \
  48. { "offdiag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_mag_cal_report_t, offdiag_y) }, \
  49. { "offdiag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_mag_cal_report_t, offdiag_z) }, \
  50. { "orientation_confidence", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_mag_cal_report_t, orientation_confidence) }, \
  51. { "old_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 48, offsetof(mavlink_mag_cal_report_t, old_orientation) }, \
  52. { "new_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_mag_cal_report_t, new_orientation) }, \
  53. { "scale_factor", NULL, MAVLINK_TYPE_FLOAT, 0, 50, offsetof(mavlink_mag_cal_report_t, scale_factor) }, \
  54. } \
  55. }
  56. #else
  57. #define MAVLINK_MESSAGE_INFO_MAG_CAL_REPORT { \
  58. "MAG_CAL_REPORT", \
  59. 18, \
  60. { { "compass_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 40, offsetof(mavlink_mag_cal_report_t, compass_id) }, \
  61. { "cal_mask", NULL, MAVLINK_TYPE_UINT8_T, 0, 41, offsetof(mavlink_mag_cal_report_t, cal_mask) }, \
  62. { "cal_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_mag_cal_report_t, cal_status) }, \
  63. { "autosaved", NULL, MAVLINK_TYPE_UINT8_T, 0, 43, offsetof(mavlink_mag_cal_report_t, autosaved) }, \
  64. { "fitness", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_mag_cal_report_t, fitness) }, \
  65. { "ofs_x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_mag_cal_report_t, ofs_x) }, \
  66. { "ofs_y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_mag_cal_report_t, ofs_y) }, \
  67. { "ofs_z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_mag_cal_report_t, ofs_z) }, \
  68. { "diag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_mag_cal_report_t, diag_x) }, \
  69. { "diag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_mag_cal_report_t, diag_y) }, \
  70. { "diag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_mag_cal_report_t, diag_z) }, \
  71. { "offdiag_x", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_mag_cal_report_t, offdiag_x) }, \
  72. { "offdiag_y", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_mag_cal_report_t, offdiag_y) }, \
  73. { "offdiag_z", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_mag_cal_report_t, offdiag_z) }, \
  74. { "orientation_confidence", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_mag_cal_report_t, orientation_confidence) }, \
  75. { "old_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 48, offsetof(mavlink_mag_cal_report_t, old_orientation) }, \
  76. { "new_orientation", NULL, MAVLINK_TYPE_UINT8_T, 0, 49, offsetof(mavlink_mag_cal_report_t, new_orientation) }, \
  77. { "scale_factor", NULL, MAVLINK_TYPE_FLOAT, 0, 50, offsetof(mavlink_mag_cal_report_t, scale_factor) }, \
  78. } \
  79. }
  80. #endif
  81. /**
  82. * @brief Pack a mag_cal_report message
  83. * @param system_id ID of this system
  84. * @param component_id ID of this component (e.g. 200 for IMU)
  85. * @param msg The MAVLink message to compress the data into
  86. *
  87. * @param compass_id Compass being calibrated.
  88. * @param cal_mask Bitmask of compasses being calibrated.
  89. * @param cal_status Calibration Status.
  90. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  91. * @param fitness [mgauss] RMS milligauss residuals.
  92. * @param ofs_x X offset.
  93. * @param ofs_y Y offset.
  94. * @param ofs_z Z offset.
  95. * @param diag_x X diagonal (matrix 11).
  96. * @param diag_y Y diagonal (matrix 22).
  97. * @param diag_z Z diagonal (matrix 33).
  98. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  99. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  100. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  101. * @param orientation_confidence Confidence in orientation (higher is better).
  102. * @param old_orientation orientation before calibration.
  103. * @param new_orientation orientation after calibration.
  104. * @param scale_factor field radius correction factor
  105. * @return length of the message in bytes (excluding serial stream start sign)
  106. */
  107. static inline uint16_t mavlink_msg_mag_cal_report_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  108. uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
  109. {
  110. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  111. char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
  112. _mav_put_float(buf, 0, fitness);
  113. _mav_put_float(buf, 4, ofs_x);
  114. _mav_put_float(buf, 8, ofs_y);
  115. _mav_put_float(buf, 12, ofs_z);
  116. _mav_put_float(buf, 16, diag_x);
  117. _mav_put_float(buf, 20, diag_y);
  118. _mav_put_float(buf, 24, diag_z);
  119. _mav_put_float(buf, 28, offdiag_x);
  120. _mav_put_float(buf, 32, offdiag_y);
  121. _mav_put_float(buf, 36, offdiag_z);
  122. _mav_put_uint8_t(buf, 40, compass_id);
  123. _mav_put_uint8_t(buf, 41, cal_mask);
  124. _mav_put_uint8_t(buf, 42, cal_status);
  125. _mav_put_uint8_t(buf, 43, autosaved);
  126. _mav_put_float(buf, 44, orientation_confidence);
  127. _mav_put_uint8_t(buf, 48, old_orientation);
  128. _mav_put_uint8_t(buf, 49, new_orientation);
  129. _mav_put_float(buf, 50, scale_factor);
  130. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  131. #else
  132. mavlink_mag_cal_report_t packet;
  133. packet.fitness = fitness;
  134. packet.ofs_x = ofs_x;
  135. packet.ofs_y = ofs_y;
  136. packet.ofs_z = ofs_z;
  137. packet.diag_x = diag_x;
  138. packet.diag_y = diag_y;
  139. packet.diag_z = diag_z;
  140. packet.offdiag_x = offdiag_x;
  141. packet.offdiag_y = offdiag_y;
  142. packet.offdiag_z = offdiag_z;
  143. packet.compass_id = compass_id;
  144. packet.cal_mask = cal_mask;
  145. packet.cal_status = cal_status;
  146. packet.autosaved = autosaved;
  147. packet.orientation_confidence = orientation_confidence;
  148. packet.old_orientation = old_orientation;
  149. packet.new_orientation = new_orientation;
  150. packet.scale_factor = scale_factor;
  151. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  152. #endif
  153. msg->msgid = MAVLINK_MSG_ID_MAG_CAL_REPORT;
  154. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  155. }
  156. /**
  157. * @brief Pack a mag_cal_report 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 compass_id Compass being calibrated.
  163. * @param cal_mask Bitmask of compasses being calibrated.
  164. * @param cal_status Calibration Status.
  165. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  166. * @param fitness [mgauss] RMS milligauss residuals.
  167. * @param ofs_x X offset.
  168. * @param ofs_y Y offset.
  169. * @param ofs_z Z offset.
  170. * @param diag_x X diagonal (matrix 11).
  171. * @param diag_y Y diagonal (matrix 22).
  172. * @param diag_z Z diagonal (matrix 33).
  173. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  174. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  175. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  176. * @param orientation_confidence Confidence in orientation (higher is better).
  177. * @param old_orientation orientation before calibration.
  178. * @param new_orientation orientation after calibration.
  179. * @param scale_factor field radius correction factor
  180. * @return length of the message in bytes (excluding serial stream start sign)
  181. */
  182. static inline uint16_t mavlink_msg_mag_cal_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  183. mavlink_message_t* msg,
  184. uint8_t compass_id,uint8_t cal_mask,uint8_t cal_status,uint8_t autosaved,float fitness,float ofs_x,float ofs_y,float ofs_z,float diag_x,float diag_y,float diag_z,float offdiag_x,float offdiag_y,float offdiag_z,float orientation_confidence,uint8_t old_orientation,uint8_t new_orientation,float scale_factor)
  185. {
  186. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  187. char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
  188. _mav_put_float(buf, 0, fitness);
  189. _mav_put_float(buf, 4, ofs_x);
  190. _mav_put_float(buf, 8, ofs_y);
  191. _mav_put_float(buf, 12, ofs_z);
  192. _mav_put_float(buf, 16, diag_x);
  193. _mav_put_float(buf, 20, diag_y);
  194. _mav_put_float(buf, 24, diag_z);
  195. _mav_put_float(buf, 28, offdiag_x);
  196. _mav_put_float(buf, 32, offdiag_y);
  197. _mav_put_float(buf, 36, offdiag_z);
  198. _mav_put_uint8_t(buf, 40, compass_id);
  199. _mav_put_uint8_t(buf, 41, cal_mask);
  200. _mav_put_uint8_t(buf, 42, cal_status);
  201. _mav_put_uint8_t(buf, 43, autosaved);
  202. _mav_put_float(buf, 44, orientation_confidence);
  203. _mav_put_uint8_t(buf, 48, old_orientation);
  204. _mav_put_uint8_t(buf, 49, new_orientation);
  205. _mav_put_float(buf, 50, scale_factor);
  206. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  207. #else
  208. mavlink_mag_cal_report_t packet;
  209. packet.fitness = fitness;
  210. packet.ofs_x = ofs_x;
  211. packet.ofs_y = ofs_y;
  212. packet.ofs_z = ofs_z;
  213. packet.diag_x = diag_x;
  214. packet.diag_y = diag_y;
  215. packet.diag_z = diag_z;
  216. packet.offdiag_x = offdiag_x;
  217. packet.offdiag_y = offdiag_y;
  218. packet.offdiag_z = offdiag_z;
  219. packet.compass_id = compass_id;
  220. packet.cal_mask = cal_mask;
  221. packet.cal_status = cal_status;
  222. packet.autosaved = autosaved;
  223. packet.orientation_confidence = orientation_confidence;
  224. packet.old_orientation = old_orientation;
  225. packet.new_orientation = new_orientation;
  226. packet.scale_factor = scale_factor;
  227. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  228. #endif
  229. msg->msgid = MAVLINK_MSG_ID_MAG_CAL_REPORT;
  230. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  231. }
  232. /**
  233. * @brief Encode a mag_cal_report struct
  234. *
  235. * @param system_id ID of this system
  236. * @param component_id ID of this component (e.g. 200 for IMU)
  237. * @param msg The MAVLink message to compress the data into
  238. * @param mag_cal_report C-struct to read the message contents from
  239. */
  240. static inline uint16_t mavlink_msg_mag_cal_report_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
  241. {
  242. return mavlink_msg_mag_cal_report_pack(system_id, component_id, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
  243. }
  244. /**
  245. * @brief Encode a mag_cal_report struct on a channel
  246. *
  247. * @param system_id ID of this system
  248. * @param component_id ID of this component (e.g. 200 for IMU)
  249. * @param chan The MAVLink channel this message will be sent over
  250. * @param msg The MAVLink message to compress the data into
  251. * @param mag_cal_report C-struct to read the message contents from
  252. */
  253. static inline uint16_t mavlink_msg_mag_cal_report_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
  254. {
  255. return mavlink_msg_mag_cal_report_pack_chan(system_id, component_id, chan, msg, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
  256. }
  257. /**
  258. * @brief Send a mag_cal_report message
  259. * @param chan MAVLink channel to send the message
  260. *
  261. * @param compass_id Compass being calibrated.
  262. * @param cal_mask Bitmask of compasses being calibrated.
  263. * @param cal_status Calibration Status.
  264. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  265. * @param fitness [mgauss] RMS milligauss residuals.
  266. * @param ofs_x X offset.
  267. * @param ofs_y Y offset.
  268. * @param ofs_z Z offset.
  269. * @param diag_x X diagonal (matrix 11).
  270. * @param diag_y Y diagonal (matrix 22).
  271. * @param diag_z Z diagonal (matrix 33).
  272. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  273. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  274. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  275. * @param orientation_confidence Confidence in orientation (higher is better).
  276. * @param old_orientation orientation before calibration.
  277. * @param new_orientation orientation after calibration.
  278. * @param scale_factor field radius correction factor
  279. */
  280. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  281. static inline void mavlink_msg_mag_cal_report_send(mavlink_channel_t chan, uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
  282. {
  283. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  284. char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
  285. _mav_put_float(buf, 0, fitness);
  286. _mav_put_float(buf, 4, ofs_x);
  287. _mav_put_float(buf, 8, ofs_y);
  288. _mav_put_float(buf, 12, ofs_z);
  289. _mav_put_float(buf, 16, diag_x);
  290. _mav_put_float(buf, 20, diag_y);
  291. _mav_put_float(buf, 24, diag_z);
  292. _mav_put_float(buf, 28, offdiag_x);
  293. _mav_put_float(buf, 32, offdiag_y);
  294. _mav_put_float(buf, 36, offdiag_z);
  295. _mav_put_uint8_t(buf, 40, compass_id);
  296. _mav_put_uint8_t(buf, 41, cal_mask);
  297. _mav_put_uint8_t(buf, 42, cal_status);
  298. _mav_put_uint8_t(buf, 43, autosaved);
  299. _mav_put_float(buf, 44, orientation_confidence);
  300. _mav_put_uint8_t(buf, 48, old_orientation);
  301. _mav_put_uint8_t(buf, 49, new_orientation);
  302. _mav_put_float(buf, 50, scale_factor);
  303. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  304. #else
  305. mavlink_mag_cal_report_t packet;
  306. packet.fitness = fitness;
  307. packet.ofs_x = ofs_x;
  308. packet.ofs_y = ofs_y;
  309. packet.ofs_z = ofs_z;
  310. packet.diag_x = diag_x;
  311. packet.diag_y = diag_y;
  312. packet.diag_z = diag_z;
  313. packet.offdiag_x = offdiag_x;
  314. packet.offdiag_y = offdiag_y;
  315. packet.offdiag_z = offdiag_z;
  316. packet.compass_id = compass_id;
  317. packet.cal_mask = cal_mask;
  318. packet.cal_status = cal_status;
  319. packet.autosaved = autosaved;
  320. packet.orientation_confidence = orientation_confidence;
  321. packet.old_orientation = old_orientation;
  322. packet.new_orientation = new_orientation;
  323. packet.scale_factor = scale_factor;
  324. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)&packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  325. #endif
  326. }
  327. /**
  328. * @brief Send a mag_cal_report message
  329. * @param chan MAVLink channel to send the message
  330. * @param struct The MAVLink struct to serialize
  331. */
  332. static inline void mavlink_msg_mag_cal_report_send_struct(mavlink_channel_t chan, const mavlink_mag_cal_report_t* mag_cal_report)
  333. {
  334. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  335. mavlink_msg_mag_cal_report_send(chan, mag_cal_report->compass_id, mag_cal_report->cal_mask, mag_cal_report->cal_status, mag_cal_report->autosaved, mag_cal_report->fitness, mag_cal_report->ofs_x, mag_cal_report->ofs_y, mag_cal_report->ofs_z, mag_cal_report->diag_x, mag_cal_report->diag_y, mag_cal_report->diag_z, mag_cal_report->offdiag_x, mag_cal_report->offdiag_y, mag_cal_report->offdiag_z, mag_cal_report->orientation_confidence, mag_cal_report->old_orientation, mag_cal_report->new_orientation, mag_cal_report->scale_factor);
  336. #else
  337. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)mag_cal_report, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  338. #endif
  339. }
  340. #if MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  341. /*
  342. This variant of _send() can be used to save stack space by re-using
  343. memory from the receive buffer. The caller provides a
  344. mavlink_message_t which is the size of a full mavlink message. This
  345. is usually the receive buffer for the channel, and allows a reply to an
  346. incoming message with minimum stack space usage.
  347. */
  348. static inline void mavlink_msg_mag_cal_report_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t compass_id, uint8_t cal_mask, uint8_t cal_status, uint8_t autosaved, float fitness, float ofs_x, float ofs_y, float ofs_z, float diag_x, float diag_y, float diag_z, float offdiag_x, float offdiag_y, float offdiag_z, float orientation_confidence, uint8_t old_orientation, uint8_t new_orientation, float scale_factor)
  349. {
  350. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  351. char *buf = (char *)msgbuf;
  352. _mav_put_float(buf, 0, fitness);
  353. _mav_put_float(buf, 4, ofs_x);
  354. _mav_put_float(buf, 8, ofs_y);
  355. _mav_put_float(buf, 12, ofs_z);
  356. _mav_put_float(buf, 16, diag_x);
  357. _mav_put_float(buf, 20, diag_y);
  358. _mav_put_float(buf, 24, diag_z);
  359. _mav_put_float(buf, 28, offdiag_x);
  360. _mav_put_float(buf, 32, offdiag_y);
  361. _mav_put_float(buf, 36, offdiag_z);
  362. _mav_put_uint8_t(buf, 40, compass_id);
  363. _mav_put_uint8_t(buf, 41, cal_mask);
  364. _mav_put_uint8_t(buf, 42, cal_status);
  365. _mav_put_uint8_t(buf, 43, autosaved);
  366. _mav_put_float(buf, 44, orientation_confidence);
  367. _mav_put_uint8_t(buf, 48, old_orientation);
  368. _mav_put_uint8_t(buf, 49, new_orientation);
  369. _mav_put_float(buf, 50, scale_factor);
  370. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  371. #else
  372. mavlink_mag_cal_report_t *packet = (mavlink_mag_cal_report_t *)msgbuf;
  373. packet->fitness = fitness;
  374. packet->ofs_x = ofs_x;
  375. packet->ofs_y = ofs_y;
  376. packet->ofs_z = ofs_z;
  377. packet->diag_x = diag_x;
  378. packet->diag_y = diag_y;
  379. packet->diag_z = diag_z;
  380. packet->offdiag_x = offdiag_x;
  381. packet->offdiag_y = offdiag_y;
  382. packet->offdiag_z = offdiag_z;
  383. packet->compass_id = compass_id;
  384. packet->cal_mask = cal_mask;
  385. packet->cal_status = cal_status;
  386. packet->autosaved = autosaved;
  387. packet->orientation_confidence = orientation_confidence;
  388. packet->old_orientation = old_orientation;
  389. packet->new_orientation = new_orientation;
  390. packet->scale_factor = scale_factor;
  391. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MAG_CAL_REPORT, (const char *)packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  392. #endif
  393. }
  394. #endif
  395. #endif
  396. // MESSAGE MAG_CAL_REPORT UNPACKING
  397. /**
  398. * @brief Get field compass_id from mag_cal_report message
  399. *
  400. * @return Compass being calibrated.
  401. */
  402. static inline uint8_t mavlink_msg_mag_cal_report_get_compass_id(const mavlink_message_t* msg)
  403. {
  404. return _MAV_RETURN_uint8_t(msg, 40);
  405. }
  406. /**
  407. * @brief Get field cal_mask from mag_cal_report message
  408. *
  409. * @return Bitmask of compasses being calibrated.
  410. */
  411. static inline uint8_t mavlink_msg_mag_cal_report_get_cal_mask(const mavlink_message_t* msg)
  412. {
  413. return _MAV_RETURN_uint8_t(msg, 41);
  414. }
  415. /**
  416. * @brief Get field cal_status from mag_cal_report message
  417. *
  418. * @return Calibration Status.
  419. */
  420. static inline uint8_t mavlink_msg_mag_cal_report_get_cal_status(const mavlink_message_t* msg)
  421. {
  422. return _MAV_RETURN_uint8_t(msg, 42);
  423. }
  424. /**
  425. * @brief Get field autosaved from mag_cal_report message
  426. *
  427. * @return 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  428. */
  429. static inline uint8_t mavlink_msg_mag_cal_report_get_autosaved(const mavlink_message_t* msg)
  430. {
  431. return _MAV_RETURN_uint8_t(msg, 43);
  432. }
  433. /**
  434. * @brief Get field fitness from mag_cal_report message
  435. *
  436. * @return [mgauss] RMS milligauss residuals.
  437. */
  438. static inline float mavlink_msg_mag_cal_report_get_fitness(const mavlink_message_t* msg)
  439. {
  440. return _MAV_RETURN_float(msg, 0);
  441. }
  442. /**
  443. * @brief Get field ofs_x from mag_cal_report message
  444. *
  445. * @return X offset.
  446. */
  447. static inline float mavlink_msg_mag_cal_report_get_ofs_x(const mavlink_message_t* msg)
  448. {
  449. return _MAV_RETURN_float(msg, 4);
  450. }
  451. /**
  452. * @brief Get field ofs_y from mag_cal_report message
  453. *
  454. * @return Y offset.
  455. */
  456. static inline float mavlink_msg_mag_cal_report_get_ofs_y(const mavlink_message_t* msg)
  457. {
  458. return _MAV_RETURN_float(msg, 8);
  459. }
  460. /**
  461. * @brief Get field ofs_z from mag_cal_report message
  462. *
  463. * @return Z offset.
  464. */
  465. static inline float mavlink_msg_mag_cal_report_get_ofs_z(const mavlink_message_t* msg)
  466. {
  467. return _MAV_RETURN_float(msg, 12);
  468. }
  469. /**
  470. * @brief Get field diag_x from mag_cal_report message
  471. *
  472. * @return X diagonal (matrix 11).
  473. */
  474. static inline float mavlink_msg_mag_cal_report_get_diag_x(const mavlink_message_t* msg)
  475. {
  476. return _MAV_RETURN_float(msg, 16);
  477. }
  478. /**
  479. * @brief Get field diag_y from mag_cal_report message
  480. *
  481. * @return Y diagonal (matrix 22).
  482. */
  483. static inline float mavlink_msg_mag_cal_report_get_diag_y(const mavlink_message_t* msg)
  484. {
  485. return _MAV_RETURN_float(msg, 20);
  486. }
  487. /**
  488. * @brief Get field diag_z from mag_cal_report message
  489. *
  490. * @return Z diagonal (matrix 33).
  491. */
  492. static inline float mavlink_msg_mag_cal_report_get_diag_z(const mavlink_message_t* msg)
  493. {
  494. return _MAV_RETURN_float(msg, 24);
  495. }
  496. /**
  497. * @brief Get field offdiag_x from mag_cal_report message
  498. *
  499. * @return X off-diagonal (matrix 12 and 21).
  500. */
  501. static inline float mavlink_msg_mag_cal_report_get_offdiag_x(const mavlink_message_t* msg)
  502. {
  503. return _MAV_RETURN_float(msg, 28);
  504. }
  505. /**
  506. * @brief Get field offdiag_y from mag_cal_report message
  507. *
  508. * @return Y off-diagonal (matrix 13 and 31).
  509. */
  510. static inline float mavlink_msg_mag_cal_report_get_offdiag_y(const mavlink_message_t* msg)
  511. {
  512. return _MAV_RETURN_float(msg, 32);
  513. }
  514. /**
  515. * @brief Get field offdiag_z from mag_cal_report message
  516. *
  517. * @return Z off-diagonal (matrix 32 and 23).
  518. */
  519. static inline float mavlink_msg_mag_cal_report_get_offdiag_z(const mavlink_message_t* msg)
  520. {
  521. return _MAV_RETURN_float(msg, 36);
  522. }
  523. /**
  524. * @brief Get field orientation_confidence from mag_cal_report message
  525. *
  526. * @return Confidence in orientation (higher is better).
  527. */
  528. static inline float mavlink_msg_mag_cal_report_get_orientation_confidence(const mavlink_message_t* msg)
  529. {
  530. return _MAV_RETURN_float(msg, 44);
  531. }
  532. /**
  533. * @brief Get field old_orientation from mag_cal_report message
  534. *
  535. * @return orientation before calibration.
  536. */
  537. static inline uint8_t mavlink_msg_mag_cal_report_get_old_orientation(const mavlink_message_t* msg)
  538. {
  539. return _MAV_RETURN_uint8_t(msg, 48);
  540. }
  541. /**
  542. * @brief Get field new_orientation from mag_cal_report message
  543. *
  544. * @return orientation after calibration.
  545. */
  546. static inline uint8_t mavlink_msg_mag_cal_report_get_new_orientation(const mavlink_message_t* msg)
  547. {
  548. return _MAV_RETURN_uint8_t(msg, 49);
  549. }
  550. /**
  551. * @brief Get field scale_factor from mag_cal_report message
  552. *
  553. * @return field radius correction factor
  554. */
  555. static inline float mavlink_msg_mag_cal_report_get_scale_factor(const mavlink_message_t* msg)
  556. {
  557. return _MAV_RETURN_float(msg, 50);
  558. }
  559. /**
  560. * @brief Decode a mag_cal_report message into a struct
  561. *
  562. * @param msg The message to decode
  563. * @param mag_cal_report C-struct to decode the message contents into
  564. */
  565. static inline void mavlink_msg_mag_cal_report_decode(const mavlink_message_t* msg, mavlink_mag_cal_report_t* mag_cal_report)
  566. {
  567. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  568. mag_cal_report->fitness = mavlink_msg_mag_cal_report_get_fitness(msg);
  569. mag_cal_report->ofs_x = mavlink_msg_mag_cal_report_get_ofs_x(msg);
  570. mag_cal_report->ofs_y = mavlink_msg_mag_cal_report_get_ofs_y(msg);
  571. mag_cal_report->ofs_z = mavlink_msg_mag_cal_report_get_ofs_z(msg);
  572. mag_cal_report->diag_x = mavlink_msg_mag_cal_report_get_diag_x(msg);
  573. mag_cal_report->diag_y = mavlink_msg_mag_cal_report_get_diag_y(msg);
  574. mag_cal_report->diag_z = mavlink_msg_mag_cal_report_get_diag_z(msg);
  575. mag_cal_report->offdiag_x = mavlink_msg_mag_cal_report_get_offdiag_x(msg);
  576. mag_cal_report->offdiag_y = mavlink_msg_mag_cal_report_get_offdiag_y(msg);
  577. mag_cal_report->offdiag_z = mavlink_msg_mag_cal_report_get_offdiag_z(msg);
  578. mag_cal_report->compass_id = mavlink_msg_mag_cal_report_get_compass_id(msg);
  579. mag_cal_report->cal_mask = mavlink_msg_mag_cal_report_get_cal_mask(msg);
  580. mag_cal_report->cal_status = mavlink_msg_mag_cal_report_get_cal_status(msg);
  581. mag_cal_report->autosaved = mavlink_msg_mag_cal_report_get_autosaved(msg);
  582. mag_cal_report->orientation_confidence = mavlink_msg_mag_cal_report_get_orientation_confidence(msg);
  583. mag_cal_report->old_orientation = mavlink_msg_mag_cal_report_get_old_orientation(msg);
  584. mag_cal_report->new_orientation = mavlink_msg_mag_cal_report_get_new_orientation(msg);
  585. mag_cal_report->scale_factor = mavlink_msg_mag_cal_report_get_scale_factor(msg);
  586. #else
  587. uint8_t len = msg->len < MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN? msg->len : MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN;
  588. memset(mag_cal_report, 0, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  589. memcpy(mag_cal_report, _MAV_PAYLOAD(msg), len);
  590. #endif
  591. }