Copter: make landing_gear_should_be_deployed a base-class method

This commit is contained in:
Peter Barker 2017-12-06 22:18:34 +11:00 committed by Francisco Ferreira
parent e76865eb9c
commit d9235d3d41
4 changed files with 9 additions and 7 deletions

View File

@ -14,9 +14,7 @@ void Copter::landinggear_update()
// if we are doing an automatic landing procedure, force the landing gear to deploy.
// To-Do: should we pause the auto-land procedure to give time for gear to come down?
if (control_mode == LAND ||
(control_mode == RTL && mode_rtl.landing_gear_should_be_deployed()) ||
(control_mode == AUTO && mode_auto.landing_gear_should_be_deployed())) {
if (flightmode->landing_gear_should_be_deployed()) {
landinggear.set_position(AP_LandingGear::LandingGear_Deploy_And_Keep_Deployed);
}

View File

@ -42,6 +42,9 @@ protected:
virtual bool requires_GPS() const = 0;
virtual bool has_manual_throttle() const = 0;
virtual bool allows_arming(bool from_gcs) const = 0;
virtual bool landing_gear_should_be_deployed() const { return false; }
virtual const char *name() const = 0;
// returns a string for this flightmode, exactly 4 bytes
@ -270,7 +273,7 @@ public:
void spline_start(const Location_Class& destination, bool stopped_at_start, AC_WPNav::spline_segment_end_type seg_end_type, const Location_Class& next_destination);
void nav_guided_start();
bool landing_gear_should_be_deployed();
bool landing_gear_should_be_deployed() const override;
void payload_place_start();
@ -780,6 +783,7 @@ public:
bool has_manual_throttle() const override { return false; }
bool allows_arming(bool from_gcs) const override { return false; };
bool is_autopilot() const override { return true; }
bool landing_gear_should_be_deployed() const override { return true; };
float get_land_descent_speed();
bool landing_with_GPS();
@ -903,7 +907,7 @@ public:
// this should probably not be exposed
bool state_complete() { return _state_complete; }
bool landing_gear_should_be_deployed();
bool landing_gear_should_be_deployed() const override;
void restart_without_terrain();

View File

@ -411,7 +411,7 @@ void Copter::ModeAuto::land_run()
_copter.land_run_vertical_control();
}
bool Copter::ModeAuto::landing_gear_should_be_deployed()
bool Copter::ModeAuto::landing_gear_should_be_deployed() const
{
switch(_mode) {
case Auto_Land:

View File

@ -356,7 +356,7 @@ void Copter::ModeRTL::land_start()
set_auto_yaw_mode(AUTO_YAW_HOLD);
}
bool Copter::ModeRTL::landing_gear_should_be_deployed()
bool Copter::ModeRTL::landing_gear_should_be_deployed() const
{
switch(_state) {
case RTL_LoiterAtHome: