2015-01-06 00:24:05 -04:00
|
|
|
/// @file AP_LandingGear.h
|
|
|
|
/// @brief Landing gear control library
|
2016-02-17 21:25:32 -04:00
|
|
|
#pragma once
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_Common/AP_Common.h>
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2018-06-10 03:34:02 -03:00
|
|
|
#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
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
/// @class AP_LandingGear
|
|
|
|
/// @brief Class managing the control of landing gear
|
|
|
|
class AP_LandingGear {
|
|
|
|
public:
|
2017-12-12 21:06:12 -04:00
|
|
|
AP_LandingGear() {
|
|
|
|
// setup parameter defaults
|
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
if (_singleton != nullptr) {
|
|
|
|
AP_HAL::panic("AP_LandingGear must be singleton");
|
|
|
|
}
|
|
|
|
_singleton = this;
|
2017-12-12 21:06:12 -04:00
|
|
|
}
|
2017-08-29 20:57:36 -03:00
|
|
|
|
|
|
|
/* Do not allow copies */
|
|
|
|
AP_LandingGear(const AP_LandingGear &other) = delete;
|
|
|
|
AP_LandingGear &operator=(const AP_LandingGear&) = delete;
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
// get singleton instance
|
2019-02-10 14:05:37 -04:00
|
|
|
static AP_LandingGear *get_singleton(void) {
|
2018-11-08 20:03:11 -04:00
|
|
|
return _singleton;
|
2018-06-10 03:34:02 -03:00
|
|
|
}
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2017-06-10 01:07:38 -03:00
|
|
|
// Gear command modes
|
|
|
|
enum LandingGearCommand {
|
|
|
|
LandingGear_Retract,
|
|
|
|
LandingGear_Deploy,
|
|
|
|
};
|
|
|
|
|
2017-08-04 03:28:33 -03:00
|
|
|
// Gear command modes
|
|
|
|
enum LandingGearStartupBehaviour {
|
|
|
|
LandingGear_Startup_WaitForPilotInput = 0,
|
|
|
|
LandingGear_Startup_Retract = 1,
|
|
|
|
LandingGear_Startup_Deploy = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// initialise state of landing gear
|
|
|
|
void init();
|
|
|
|
|
2017-06-10 01:07:38 -03:00
|
|
|
/// returns true if the landing gear is deployed
|
2018-06-10 03:34:02 -03:00
|
|
|
bool deployed();
|
|
|
|
|
|
|
|
enum LG_LandingGear_State {
|
|
|
|
LG_UNKNOWN = -1,
|
|
|
|
LG_RETRACTED = 0,
|
|
|
|
LG_DEPLOYED = 1,
|
|
|
|
LG_RETRACTING = 2,
|
|
|
|
LG_DEPLOYING = 3,
|
|
|
|
};
|
|
|
|
/// returns detailed state of gear
|
|
|
|
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();
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2017-06-10 01:07:38 -03:00
|
|
|
/// set landing gear position to retract, deploy or deploy-and-keep-deployed
|
|
|
|
void set_position(LandingGearCommand cmd);
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
uint32_t get_gear_state_duration_ms();
|
|
|
|
uint32_t get_wow_state_duration_ms();
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2018-06-10 03:34:02 -03:00
|
|
|
|
2018-11-09 00:39:59 -04:00
|
|
|
void update(float height_above_ground_m);
|
2018-11-11 07:57:02 -04:00
|
|
|
|
|
|
|
bool check_before_land(void);
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2020-02-20 23:08:11 -04:00
|
|
|
// retract after takeoff or deploy for landing depending on the OPTIONS parameter
|
|
|
|
void retract_after_takeoff();
|
|
|
|
void deploy_for_landing();
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
private:
|
|
|
|
// Parameters
|
2017-08-04 03:28:33 -03:00
|
|
|
AP_Int8 _startup_behaviour; // start-up behaviour (see LandingGearStartupBehaviour)
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
AP_Int8 _pin_deployed;
|
|
|
|
AP_Int8 _pin_deployed_polarity;
|
|
|
|
AP_Int8 _pin_weight_on_wheels;
|
|
|
|
AP_Int8 _pin_weight_on_wheels_polarity;
|
2018-11-09 00:39:59 -04:00
|
|
|
AP_Int16 _deploy_alt;
|
|
|
|
AP_Int16 _retract_alt;
|
2020-02-20 23:08:11 -04:00
|
|
|
AP_Int16 _options;
|
|
|
|
|
|
|
|
// bitmask of options
|
|
|
|
enum class Option : uint16_t {
|
|
|
|
RETRACT_AFTER_TAKEOFF = (1U<<0),
|
|
|
|
DEPLOY_DURING_LANDING = (1U<<1)
|
|
|
|
};
|
2015-01-06 00:24:05 -04:00
|
|
|
|
|
|
|
// internal variables
|
|
|
|
bool _deployed; // true if the landing gear has been deployed, initialized false
|
2018-11-09 00:39:59 -04:00
|
|
|
bool _have_changed; // have we changed the servo state?
|
2018-06-10 03:34:02 -03:00
|
|
|
|
2018-11-09 00:39:59 -04:00
|
|
|
int16_t _last_height_above_ground;
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
// debounce
|
|
|
|
LG_WOW_State wow_state_current = LG_WOW_UNKNOWN;
|
|
|
|
uint32_t last_wow_event_ms;
|
2015-01-06 00:24:05 -04:00
|
|
|
|
2018-06-10 03:34:02 -03:00
|
|
|
LG_LandingGear_State gear_state_current = LG_UNKNOWN;
|
|
|
|
uint32_t last_gear_event_ms;
|
|
|
|
|
2015-01-06 00:24:05 -04:00
|
|
|
/// retract - retract landing gear
|
|
|
|
void retract();
|
|
|
|
|
|
|
|
/// deploy - deploy the landing gear
|
|
|
|
void deploy();
|
2018-06-10 03:34:02 -03:00
|
|
|
|
|
|
|
// log weight on wheels state
|
|
|
|
void log_wow_state(LG_WOW_State state);
|
|
|
|
|
|
|
|
static AP_LandingGear *_singleton;
|
2015-01-06 00:24:05 -04:00
|
|
|
};
|