AP_Baro_SITL.h 949 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "AP_Baro_Backend.h"
  3. #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
  4. #include <SITL/SITL.h>
  5. #include <AP_Math/vectorN.h>
  6. class AP_Baro_SITL : public AP_Baro_Backend {
  7. public:
  8. AP_Baro_SITL(AP_Baro &);
  9. void update() override;
  10. protected:
  11. void update_healthy_flag(uint8_t instance) override { _frontend.sensors[instance].healthy = true; }
  12. private:
  13. uint8_t _instance;
  14. SITL::SITL *_sitl;
  15. // barometer delay buffer variables
  16. struct readings_baro {
  17. uint32_t time;
  18. float data;
  19. };
  20. uint8_t _store_index;
  21. uint32_t _last_store_time;
  22. static const uint8_t _buffer_length = 50;
  23. VectorN<readings_baro, _buffer_length> _buffer;
  24. // adjust for simulated board temperature
  25. void temperature_adjustment(float &p, float &T);
  26. void _timer();
  27. bool _has_sample;
  28. uint32_t _last_sample_time;
  29. float _recent_temp;
  30. float _recent_press;
  31. };
  32. #endif // CONFIG_HAL_BOARD