AP_WindVane_Backend.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #pragma once
  14. #include "AP_WindVane.h"
  15. #include <GCS_MAVLink/GCS.h>
  16. #include <Filter/Filter.h>
  17. class AP_WindVane_Backend
  18. {
  19. public:
  20. // constructor. This incorporates initialization as well.
  21. AP_WindVane_Backend(AP_WindVane &frontend);
  22. // we declare a virtual destructor so that WindVane drivers can
  23. // override with a custom destructor if need be
  24. virtual ~AP_WindVane_Backend() {}
  25. // initialization
  26. virtual void init(const AP_SerialManager& serial_manager) {};
  27. // update the state structure
  28. virtual void update_speed() {};
  29. virtual void update_direction() {};
  30. virtual void calibrate();
  31. protected:
  32. // update frontend
  33. void speed_update_frontend(float apparent_speed_in);
  34. void direction_update_frontend(float apparent_angle_ef);
  35. AP_WindVane &_frontend;
  36. private:
  37. // low pass filters of direction and speed
  38. LowPassFilterFloat _dir_sin_filt = LowPassFilterFloat(2.0f);
  39. LowPassFilterFloat _dir_cos_filt = LowPassFilterFloat(2.0f);
  40. LowPassFilterFloat _speed_filt = LowPassFilterFloat(2.0f);
  41. };