SIM_Precland.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 "stdint.h"
  15. #include <AP_Param/AP_Param.h>
  16. #include <AP_Math/AP_Math.h>
  17. #include <AP_Common/Location.h>
  18. namespace SITL {
  19. class SIM_Precland {
  20. public:
  21. SIM_Precland() {
  22. AP_Param::setup_object_defaults(this, var_info);
  23. };
  24. // update precland state
  25. void update(const Location &loc, const Vector3f &position);
  26. // true if precland sensor is online and healthy
  27. bool healthy() const { return _healthy; }
  28. // timestamp of most recent data read from the sensor
  29. uint32_t last_update_ms() const { return _last_update_ms; }
  30. const Vector3f &get_target_position() const { return _target_pos; }
  31. bool is_enabled() const {return static_cast<bool>(_enable);}
  32. void set_default_location(float lat, float lon, int16_t yaw);
  33. static const struct AP_Param::GroupInfo var_info[];
  34. AP_Int8 _enable;
  35. AP_Float _origin_lat;
  36. AP_Float _origin_lon;
  37. AP_Float _origin_height;
  38. AP_Int16 _orient_yaw;
  39. AP_Int8 _type;
  40. AP_Int32 _rate;
  41. AP_Float _alt_limit;
  42. AP_Float _dist_limit;
  43. enum PreclandType {
  44. PRECLAND_TYPE_CYLINDER = 0,
  45. PRECLAND_TYPE_CONE = 1,
  46. PRECLAND_TYPE_SPHERE = 2,
  47. };
  48. private:
  49. uint32_t _last_update_ms;
  50. bool _healthy;
  51. Vector3f _target_pos;
  52. };
  53. }