AP_Compass_SITL.h 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "AP_Compass.h"
  3. #include "AP_Compass_Backend.h"
  4. #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
  5. #include <SITL/SITL.h>
  6. #include <AP_Math/vectorN.h>
  7. #include <AP_Math/AP_Math.h>
  8. #include <AP_Declination/AP_Declination.h>
  9. #define SITL_NUM_COMPASSES 3
  10. class AP_Compass_SITL : public AP_Compass_Backend {
  11. public:
  12. AP_Compass_SITL();
  13. void read(void) override;
  14. private:
  15. uint8_t _compass_instance[SITL_NUM_COMPASSES];
  16. SITL::SITL *_sitl;
  17. // delay buffer variables
  18. struct readings_compass {
  19. uint32_t time;
  20. Vector3f data;
  21. };
  22. uint8_t store_index;
  23. uint32_t last_store_time;
  24. static const uint8_t buffer_length = 50;
  25. VectorN<readings_compass,buffer_length> buffer;
  26. void _timer();
  27. uint32_t _last_sample_time;
  28. void _setup_eliptical_correcion();
  29. Matrix3f _eliptical_corr;
  30. Vector3f _last_dia;
  31. Vector3f _last_odi;
  32. };
  33. #endif // CONFIG_HAL_BOARD