123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #pragma once
- #include <AP_Param/AP_Param.h>
- #include <AP_Common/AP_Common.h>
- #if CONFIG_HAL_BOARD == HAL_BOARD_SITL
- #define DEFAULT_PIN_WOW 8
- #define DEFAULT_PIN_WOW_POL 1
- #else
- #define DEFAULT_PIN_WOW -1
- #define DEFAULT_PIN_WOW_POL 0
- #endif
- class AP_LandingGear {
- public:
- AP_LandingGear() {
-
- AP_Param::setup_object_defaults(this, var_info);
-
- if (_singleton != nullptr) {
- AP_HAL::panic("AP_LandingGear must be singleton");
- }
- _singleton = this;
- }
-
- AP_LandingGear(const AP_LandingGear &other) = delete;
- AP_LandingGear &operator=(const AP_LandingGear&) = delete;
-
-
- static AP_LandingGear *get_singleton(void) {
- return _singleton;
- }
-
- enum LandingGearCommand {
- LandingGear_Retract,
- LandingGear_Deploy,
- };
-
- enum LandingGearStartupBehaviour {
- LandingGear_Startup_WaitForPilotInput = 0,
- LandingGear_Startup_Retract = 1,
- LandingGear_Startup_Deploy = 2,
- };
-
- void init();
-
- bool deployed();
-
- enum LG_LandingGear_State {
- LG_UNKNOWN = -1,
- LG_RETRACTED = 0,
- LG_DEPLOYED = 1,
- LG_RETRACTING = 2,
- LG_DEPLOYING = 3,
- };
-
- LG_LandingGear_State get_state();
-
- enum LG_WOW_State {
- LG_WOW_UNKNOWN = -1,
- LG_NO_WOW = 0,
- LG_WOW = 1,
- };
- LG_WOW_State get_wow_state();
-
- void set_position(LandingGearCommand cmd);
-
- uint32_t get_gear_state_duration_ms();
- uint32_t get_wow_state_duration_ms();
- static const struct AP_Param::GroupInfo var_info[];
-
- void update(float height_above_ground_m);
-
- bool check_before_land(void);
- private:
-
- AP_Int8 _startup_behaviour;
-
- AP_Int8 _pin_deployed;
- AP_Int8 _pin_deployed_polarity;
- AP_Int8 _pin_weight_on_wheels;
- AP_Int8 _pin_weight_on_wheels_polarity;
- AP_Int16 _deploy_alt;
- AP_Int16 _retract_alt;
-
- bool _deployed;
- bool _have_changed;
- int16_t _last_height_above_ground;
-
-
- LG_WOW_State wow_state_current = LG_WOW_UNKNOWN;
- uint32_t last_wow_event_ms;
-
- LG_LandingGear_State gear_state_current = LG_UNKNOWN;
- uint32_t last_gear_event_ms;
-
- void retract();
-
-
- void deploy();
-
- void log_wow_state(LG_WOW_State state);
- static AP_LandingGear *_singleton;
- };
|