mavlink_msg_mag_cal_report.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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
  158. * @param system_id ID of this system
  159. * @param component_id ID of this component (e.g. 200 for IMU)
  160. * @param status MAVLink status structure
  161. * @param msg The MAVLink message to compress the data into
  162. *
  163. * @param compass_id Compass being calibrated.
  164. * @param cal_mask Bitmask of compasses being calibrated.
  165. * @param cal_status Calibration Status.
  166. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  167. * @param fitness [mgauss] RMS milligauss residuals.
  168. * @param ofs_x X offset.
  169. * @param ofs_y Y offset.
  170. * @param ofs_z Z offset.
  171. * @param diag_x X diagonal (matrix 11).
  172. * @param diag_y Y diagonal (matrix 22).
  173. * @param diag_z Z diagonal (matrix 33).
  174. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  175. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  176. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  177. * @param orientation_confidence Confidence in orientation (higher is better).
  178. * @param old_orientation orientation before calibration.
  179. * @param new_orientation orientation after calibration.
  180. * @param scale_factor field radius correction factor
  181. * @return length of the message in bytes (excluding serial stream start sign)
  182. */
  183. static inline uint16_t mavlink_msg_mag_cal_report_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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. #if MAVLINK_CRC_EXTRA
  231. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_CRC);
  232. #else
  233. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_MAG_CAL_REPORT_MIN_LEN, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  234. #endif
  235. }
  236. /**
  237. * @brief Pack a mag_cal_report message on a channel
  238. * @param system_id ID of this system
  239. * @param component_id ID of this component (e.g. 200 for IMU)
  240. * @param chan The MAVLink channel this message will be sent over
  241. * @param msg The MAVLink message to compress the data into
  242. * @param compass_id Compass being calibrated.
  243. * @param cal_mask Bitmask of compasses being calibrated.
  244. * @param cal_status Calibration Status.
  245. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  246. * @param fitness [mgauss] RMS milligauss residuals.
  247. * @param ofs_x X offset.
  248. * @param ofs_y Y offset.
  249. * @param ofs_z Z offset.
  250. * @param diag_x X diagonal (matrix 11).
  251. * @param diag_y Y diagonal (matrix 22).
  252. * @param diag_z Z diagonal (matrix 33).
  253. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  254. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  255. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  256. * @param orientation_confidence Confidence in orientation (higher is better).
  257. * @param old_orientation orientation before calibration.
  258. * @param new_orientation orientation after calibration.
  259. * @param scale_factor field radius correction factor
  260. * @return length of the message in bytes (excluding serial stream start sign)
  261. */
  262. static inline uint16_t mavlink_msg_mag_cal_report_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  263. mavlink_message_t* msg,
  264. 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)
  265. {
  266. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  267. char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
  268. _mav_put_float(buf, 0, fitness);
  269. _mav_put_float(buf, 4, ofs_x);
  270. _mav_put_float(buf, 8, ofs_y);
  271. _mav_put_float(buf, 12, ofs_z);
  272. _mav_put_float(buf, 16, diag_x);
  273. _mav_put_float(buf, 20, diag_y);
  274. _mav_put_float(buf, 24, diag_z);
  275. _mav_put_float(buf, 28, offdiag_x);
  276. _mav_put_float(buf, 32, offdiag_y);
  277. _mav_put_float(buf, 36, offdiag_z);
  278. _mav_put_uint8_t(buf, 40, compass_id);
  279. _mav_put_uint8_t(buf, 41, cal_mask);
  280. _mav_put_uint8_t(buf, 42, cal_status);
  281. _mav_put_uint8_t(buf, 43, autosaved);
  282. _mav_put_float(buf, 44, orientation_confidence);
  283. _mav_put_uint8_t(buf, 48, old_orientation);
  284. _mav_put_uint8_t(buf, 49, new_orientation);
  285. _mav_put_float(buf, 50, scale_factor);
  286. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  287. #else
  288. mavlink_mag_cal_report_t packet;
  289. packet.fitness = fitness;
  290. packet.ofs_x = ofs_x;
  291. packet.ofs_y = ofs_y;
  292. packet.ofs_z = ofs_z;
  293. packet.diag_x = diag_x;
  294. packet.diag_y = diag_y;
  295. packet.diag_z = diag_z;
  296. packet.offdiag_x = offdiag_x;
  297. packet.offdiag_y = offdiag_y;
  298. packet.offdiag_z = offdiag_z;
  299. packet.compass_id = compass_id;
  300. packet.cal_mask = cal_mask;
  301. packet.cal_status = cal_status;
  302. packet.autosaved = autosaved;
  303. packet.orientation_confidence = orientation_confidence;
  304. packet.old_orientation = old_orientation;
  305. packet.new_orientation = new_orientation;
  306. packet.scale_factor = scale_factor;
  307. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  308. #endif
  309. msg->msgid = MAVLINK_MSG_ID_MAG_CAL_REPORT;
  310. 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);
  311. }
  312. /**
  313. * @brief Encode a mag_cal_report struct
  314. *
  315. * @param system_id ID of this system
  316. * @param component_id ID of this component (e.g. 200 for IMU)
  317. * @param msg The MAVLink message to compress the data into
  318. * @param mag_cal_report C-struct to read the message contents from
  319. */
  320. 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)
  321. {
  322. 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);
  323. }
  324. /**
  325. * @brief Encode a mag_cal_report struct on a channel
  326. *
  327. * @param system_id ID of this system
  328. * @param component_id ID of this component (e.g. 200 for IMU)
  329. * @param chan The MAVLink channel this message will be sent over
  330. * @param msg The MAVLink message to compress the data into
  331. * @param mag_cal_report C-struct to read the message contents from
  332. */
  333. 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)
  334. {
  335. 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);
  336. }
  337. /**
  338. * @brief Encode a mag_cal_report struct with provided status structure
  339. *
  340. * @param system_id ID of this system
  341. * @param component_id ID of this component (e.g. 200 for IMU)
  342. * @param status MAVLink status structure
  343. * @param msg The MAVLink message to compress the data into
  344. * @param mag_cal_report C-struct to read the message contents from
  345. */
  346. static inline uint16_t mavlink_msg_mag_cal_report_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_mag_cal_report_t* mag_cal_report)
  347. {
  348. return mavlink_msg_mag_cal_report_pack_status(system_id, component_id, _status, 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);
  349. }
  350. /**
  351. * @brief Send a mag_cal_report message
  352. * @param chan MAVLink channel to send the message
  353. *
  354. * @param compass_id Compass being calibrated.
  355. * @param cal_mask Bitmask of compasses being calibrated.
  356. * @param cal_status Calibration Status.
  357. * @param autosaved 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  358. * @param fitness [mgauss] RMS milligauss residuals.
  359. * @param ofs_x X offset.
  360. * @param ofs_y Y offset.
  361. * @param ofs_z Z offset.
  362. * @param diag_x X diagonal (matrix 11).
  363. * @param diag_y Y diagonal (matrix 22).
  364. * @param diag_z Z diagonal (matrix 33).
  365. * @param offdiag_x X off-diagonal (matrix 12 and 21).
  366. * @param offdiag_y Y off-diagonal (matrix 13 and 31).
  367. * @param offdiag_z Z off-diagonal (matrix 32 and 23).
  368. * @param orientation_confidence Confidence in orientation (higher is better).
  369. * @param old_orientation orientation before calibration.
  370. * @param new_orientation orientation after calibration.
  371. * @param scale_factor field radius correction factor
  372. */
  373. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  374. 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)
  375. {
  376. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  377. char buf[MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN];
  378. _mav_put_float(buf, 0, fitness);
  379. _mav_put_float(buf, 4, ofs_x);
  380. _mav_put_float(buf, 8, ofs_y);
  381. _mav_put_float(buf, 12, ofs_z);
  382. _mav_put_float(buf, 16, diag_x);
  383. _mav_put_float(buf, 20, diag_y);
  384. _mav_put_float(buf, 24, diag_z);
  385. _mav_put_float(buf, 28, offdiag_x);
  386. _mav_put_float(buf, 32, offdiag_y);
  387. _mav_put_float(buf, 36, offdiag_z);
  388. _mav_put_uint8_t(buf, 40, compass_id);
  389. _mav_put_uint8_t(buf, 41, cal_mask);
  390. _mav_put_uint8_t(buf, 42, cal_status);
  391. _mav_put_uint8_t(buf, 43, autosaved);
  392. _mav_put_float(buf, 44, orientation_confidence);
  393. _mav_put_uint8_t(buf, 48, old_orientation);
  394. _mav_put_uint8_t(buf, 49, new_orientation);
  395. _mav_put_float(buf, 50, scale_factor);
  396. _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);
  397. #else
  398. mavlink_mag_cal_report_t packet;
  399. packet.fitness = fitness;
  400. packet.ofs_x = ofs_x;
  401. packet.ofs_y = ofs_y;
  402. packet.ofs_z = ofs_z;
  403. packet.diag_x = diag_x;
  404. packet.diag_y = diag_y;
  405. packet.diag_z = diag_z;
  406. packet.offdiag_x = offdiag_x;
  407. packet.offdiag_y = offdiag_y;
  408. packet.offdiag_z = offdiag_z;
  409. packet.compass_id = compass_id;
  410. packet.cal_mask = cal_mask;
  411. packet.cal_status = cal_status;
  412. packet.autosaved = autosaved;
  413. packet.orientation_confidence = orientation_confidence;
  414. packet.old_orientation = old_orientation;
  415. packet.new_orientation = new_orientation;
  416. packet.scale_factor = scale_factor;
  417. _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);
  418. #endif
  419. }
  420. /**
  421. * @brief Send a mag_cal_report message
  422. * @param chan MAVLink channel to send the message
  423. * @param struct The MAVLink struct to serialize
  424. */
  425. static inline void mavlink_msg_mag_cal_report_send_struct(mavlink_channel_t chan, const mavlink_mag_cal_report_t* mag_cal_report)
  426. {
  427. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  428. 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);
  429. #else
  430. _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);
  431. #endif
  432. }
  433. #if MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  434. /*
  435. This variant of _send() can be used to save stack space by re-using
  436. memory from the receive buffer. The caller provides a
  437. mavlink_message_t which is the size of a full mavlink message. This
  438. is usually the receive buffer for the channel, and allows a reply to an
  439. incoming message with minimum stack space usage.
  440. */
  441. 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)
  442. {
  443. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  444. char *buf = (char *)msgbuf;
  445. _mav_put_float(buf, 0, fitness);
  446. _mav_put_float(buf, 4, ofs_x);
  447. _mav_put_float(buf, 8, ofs_y);
  448. _mav_put_float(buf, 12, ofs_z);
  449. _mav_put_float(buf, 16, diag_x);
  450. _mav_put_float(buf, 20, diag_y);
  451. _mav_put_float(buf, 24, diag_z);
  452. _mav_put_float(buf, 28, offdiag_x);
  453. _mav_put_float(buf, 32, offdiag_y);
  454. _mav_put_float(buf, 36, offdiag_z);
  455. _mav_put_uint8_t(buf, 40, compass_id);
  456. _mav_put_uint8_t(buf, 41, cal_mask);
  457. _mav_put_uint8_t(buf, 42, cal_status);
  458. _mav_put_uint8_t(buf, 43, autosaved);
  459. _mav_put_float(buf, 44, orientation_confidence);
  460. _mav_put_uint8_t(buf, 48, old_orientation);
  461. _mav_put_uint8_t(buf, 49, new_orientation);
  462. _mav_put_float(buf, 50, scale_factor);
  463. _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);
  464. #else
  465. mavlink_mag_cal_report_t *packet = (mavlink_mag_cal_report_t *)msgbuf;
  466. packet->fitness = fitness;
  467. packet->ofs_x = ofs_x;
  468. packet->ofs_y = ofs_y;
  469. packet->ofs_z = ofs_z;
  470. packet->diag_x = diag_x;
  471. packet->diag_y = diag_y;
  472. packet->diag_z = diag_z;
  473. packet->offdiag_x = offdiag_x;
  474. packet->offdiag_y = offdiag_y;
  475. packet->offdiag_z = offdiag_z;
  476. packet->compass_id = compass_id;
  477. packet->cal_mask = cal_mask;
  478. packet->cal_status = cal_status;
  479. packet->autosaved = autosaved;
  480. packet->orientation_confidence = orientation_confidence;
  481. packet->old_orientation = old_orientation;
  482. packet->new_orientation = new_orientation;
  483. packet->scale_factor = scale_factor;
  484. _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);
  485. #endif
  486. }
  487. #endif
  488. #endif
  489. // MESSAGE MAG_CAL_REPORT UNPACKING
  490. /**
  491. * @brief Get field compass_id from mag_cal_report message
  492. *
  493. * @return Compass being calibrated.
  494. */
  495. static inline uint8_t mavlink_msg_mag_cal_report_get_compass_id(const mavlink_message_t* msg)
  496. {
  497. return _MAV_RETURN_uint8_t(msg, 40);
  498. }
  499. /**
  500. * @brief Get field cal_mask from mag_cal_report message
  501. *
  502. * @return Bitmask of compasses being calibrated.
  503. */
  504. static inline uint8_t mavlink_msg_mag_cal_report_get_cal_mask(const mavlink_message_t* msg)
  505. {
  506. return _MAV_RETURN_uint8_t(msg, 41);
  507. }
  508. /**
  509. * @brief Get field cal_status from mag_cal_report message
  510. *
  511. * @return Calibration Status.
  512. */
  513. static inline uint8_t mavlink_msg_mag_cal_report_get_cal_status(const mavlink_message_t* msg)
  514. {
  515. return _MAV_RETURN_uint8_t(msg, 42);
  516. }
  517. /**
  518. * @brief Get field autosaved from mag_cal_report message
  519. *
  520. * @return 0=requires a MAV_CMD_DO_ACCEPT_MAG_CAL, 1=saved to parameters.
  521. */
  522. static inline uint8_t mavlink_msg_mag_cal_report_get_autosaved(const mavlink_message_t* msg)
  523. {
  524. return _MAV_RETURN_uint8_t(msg, 43);
  525. }
  526. /**
  527. * @brief Get field fitness from mag_cal_report message
  528. *
  529. * @return [mgauss] RMS milligauss residuals.
  530. */
  531. static inline float mavlink_msg_mag_cal_report_get_fitness(const mavlink_message_t* msg)
  532. {
  533. return _MAV_RETURN_float(msg, 0);
  534. }
  535. /**
  536. * @brief Get field ofs_x from mag_cal_report message
  537. *
  538. * @return X offset.
  539. */
  540. static inline float mavlink_msg_mag_cal_report_get_ofs_x(const mavlink_message_t* msg)
  541. {
  542. return _MAV_RETURN_float(msg, 4);
  543. }
  544. /**
  545. * @brief Get field ofs_y from mag_cal_report message
  546. *
  547. * @return Y offset.
  548. */
  549. static inline float mavlink_msg_mag_cal_report_get_ofs_y(const mavlink_message_t* msg)
  550. {
  551. return _MAV_RETURN_float(msg, 8);
  552. }
  553. /**
  554. * @brief Get field ofs_z from mag_cal_report message
  555. *
  556. * @return Z offset.
  557. */
  558. static inline float mavlink_msg_mag_cal_report_get_ofs_z(const mavlink_message_t* msg)
  559. {
  560. return _MAV_RETURN_float(msg, 12);
  561. }
  562. /**
  563. * @brief Get field diag_x from mag_cal_report message
  564. *
  565. * @return X diagonal (matrix 11).
  566. */
  567. static inline float mavlink_msg_mag_cal_report_get_diag_x(const mavlink_message_t* msg)
  568. {
  569. return _MAV_RETURN_float(msg, 16);
  570. }
  571. /**
  572. * @brief Get field diag_y from mag_cal_report message
  573. *
  574. * @return Y diagonal (matrix 22).
  575. */
  576. static inline float mavlink_msg_mag_cal_report_get_diag_y(const mavlink_message_t* msg)
  577. {
  578. return _MAV_RETURN_float(msg, 20);
  579. }
  580. /**
  581. * @brief Get field diag_z from mag_cal_report message
  582. *
  583. * @return Z diagonal (matrix 33).
  584. */
  585. static inline float mavlink_msg_mag_cal_report_get_diag_z(const mavlink_message_t* msg)
  586. {
  587. return _MAV_RETURN_float(msg, 24);
  588. }
  589. /**
  590. * @brief Get field offdiag_x from mag_cal_report message
  591. *
  592. * @return X off-diagonal (matrix 12 and 21).
  593. */
  594. static inline float mavlink_msg_mag_cal_report_get_offdiag_x(const mavlink_message_t* msg)
  595. {
  596. return _MAV_RETURN_float(msg, 28);
  597. }
  598. /**
  599. * @brief Get field offdiag_y from mag_cal_report message
  600. *
  601. * @return Y off-diagonal (matrix 13 and 31).
  602. */
  603. static inline float mavlink_msg_mag_cal_report_get_offdiag_y(const mavlink_message_t* msg)
  604. {
  605. return _MAV_RETURN_float(msg, 32);
  606. }
  607. /**
  608. * @brief Get field offdiag_z from mag_cal_report message
  609. *
  610. * @return Z off-diagonal (matrix 32 and 23).
  611. */
  612. static inline float mavlink_msg_mag_cal_report_get_offdiag_z(const mavlink_message_t* msg)
  613. {
  614. return _MAV_RETURN_float(msg, 36);
  615. }
  616. /**
  617. * @brief Get field orientation_confidence from mag_cal_report message
  618. *
  619. * @return Confidence in orientation (higher is better).
  620. */
  621. static inline float mavlink_msg_mag_cal_report_get_orientation_confidence(const mavlink_message_t* msg)
  622. {
  623. return _MAV_RETURN_float(msg, 44);
  624. }
  625. /**
  626. * @brief Get field old_orientation from mag_cal_report message
  627. *
  628. * @return orientation before calibration.
  629. */
  630. static inline uint8_t mavlink_msg_mag_cal_report_get_old_orientation(const mavlink_message_t* msg)
  631. {
  632. return _MAV_RETURN_uint8_t(msg, 48);
  633. }
  634. /**
  635. * @brief Get field new_orientation from mag_cal_report message
  636. *
  637. * @return orientation after calibration.
  638. */
  639. static inline uint8_t mavlink_msg_mag_cal_report_get_new_orientation(const mavlink_message_t* msg)
  640. {
  641. return _MAV_RETURN_uint8_t(msg, 49);
  642. }
  643. /**
  644. * @brief Get field scale_factor from mag_cal_report message
  645. *
  646. * @return field radius correction factor
  647. */
  648. static inline float mavlink_msg_mag_cal_report_get_scale_factor(const mavlink_message_t* msg)
  649. {
  650. return _MAV_RETURN_float(msg, 50);
  651. }
  652. /**
  653. * @brief Decode a mag_cal_report message into a struct
  654. *
  655. * @param msg The message to decode
  656. * @param mag_cal_report C-struct to decode the message contents into
  657. */
  658. static inline void mavlink_msg_mag_cal_report_decode(const mavlink_message_t* msg, mavlink_mag_cal_report_t* mag_cal_report)
  659. {
  660. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  661. mag_cal_report->fitness = mavlink_msg_mag_cal_report_get_fitness(msg);
  662. mag_cal_report->ofs_x = mavlink_msg_mag_cal_report_get_ofs_x(msg);
  663. mag_cal_report->ofs_y = mavlink_msg_mag_cal_report_get_ofs_y(msg);
  664. mag_cal_report->ofs_z = mavlink_msg_mag_cal_report_get_ofs_z(msg);
  665. mag_cal_report->diag_x = mavlink_msg_mag_cal_report_get_diag_x(msg);
  666. mag_cal_report->diag_y = mavlink_msg_mag_cal_report_get_diag_y(msg);
  667. mag_cal_report->diag_z = mavlink_msg_mag_cal_report_get_diag_z(msg);
  668. mag_cal_report->offdiag_x = mavlink_msg_mag_cal_report_get_offdiag_x(msg);
  669. mag_cal_report->offdiag_y = mavlink_msg_mag_cal_report_get_offdiag_y(msg);
  670. mag_cal_report->offdiag_z = mavlink_msg_mag_cal_report_get_offdiag_z(msg);
  671. mag_cal_report->compass_id = mavlink_msg_mag_cal_report_get_compass_id(msg);
  672. mag_cal_report->cal_mask = mavlink_msg_mag_cal_report_get_cal_mask(msg);
  673. mag_cal_report->cal_status = mavlink_msg_mag_cal_report_get_cal_status(msg);
  674. mag_cal_report->autosaved = mavlink_msg_mag_cal_report_get_autosaved(msg);
  675. mag_cal_report->orientation_confidence = mavlink_msg_mag_cal_report_get_orientation_confidence(msg);
  676. mag_cal_report->old_orientation = mavlink_msg_mag_cal_report_get_old_orientation(msg);
  677. mag_cal_report->new_orientation = mavlink_msg_mag_cal_report_get_new_orientation(msg);
  678. mag_cal_report->scale_factor = mavlink_msg_mag_cal_report_get_scale_factor(msg);
  679. #else
  680. uint8_t len = msg->len < MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN? msg->len : MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN;
  681. memset(mag_cal_report, 0, MAVLINK_MSG_ID_MAG_CAL_REPORT_LEN);
  682. memcpy(mag_cal_report, _MAV_PAYLOAD(msg), len);
  683. #endif
  684. }