diff --git a/ArduCopter/landing_gear.cpp b/ArduCopter/landing_gear.cpp index 4b0f6ece2b..4db9470469 100644 --- a/ArduCopter/landing_gear.cpp +++ b/ArduCopter/landing_gear.cpp @@ -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); } diff --git a/ArduCopter/mode.h b/ArduCopter/mode.h index 17a32c8dd9..cd357f2fd0 100644 --- a/ArduCopter/mode.h +++ b/ArduCopter/mode.h @@ -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(); diff --git a/ArduCopter/mode_auto.cpp b/ArduCopter/mode_auto.cpp index d0f243719f..8debad45ef 100644 --- a/ArduCopter/mode_auto.cpp +++ b/ArduCopter/mode_auto.cpp @@ -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: diff --git a/ArduCopter/mode_rtl.cpp b/ArduCopter/mode_rtl.cpp index 16326b997c..f906658c93 100644 --- a/ArduCopter/mode_rtl.cpp +++ b/ArduCopter/mode_rtl.cpp @@ -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: