diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 7f2a211b9a..c20c0b4594 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -929,6 +929,7 @@ private: // fence.cpp void fence_check(); bool fence_stickmixing() const; + void disable_fence_for_landing(void); #endif // ArduPlane.cpp diff --git a/ArduPlane/commands_logic.cpp b/ArduPlane/commands_logic.cpp index f36e76ed0c..231f95d8d1 100644 --- a/ArduPlane/commands_logic.cpp +++ b/ArduPlane/commands_logic.cpp @@ -383,21 +383,8 @@ void Plane::do_land(const AP_Mission::Mission_Command& cmd) } #if AC_FENCE == ENABLED - switch(fence.auto_enabled()) { - case AC_Fence::AutoEnable::ALWAYS_ENABLED: - fence.enable(false); - gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (auto disable)"); - break; - case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY: - fence.disable_floor(); - gcs().send_text(MAV_SEVERITY_NOTICE, "Fence floor disabled (auto disable)"); - break; - default: - // fence does not auto-disable in other landing conditions - break; - } + disable_fence_for_landing(); #endif - } void Plane::do_landing_vtol_approach(const AP_Mission::Mission_Command& cmd) diff --git a/ArduPlane/fence.cpp b/ArduPlane/fence.cpp index 54db609754..0643436b3d 100644 --- a/ArduPlane/fence.cpp +++ b/ArduPlane/fence.cpp @@ -126,4 +126,22 @@ bool Plane::fence_stickmixing(void) const // normal mixing rules return true; } + +void Plane::disable_fence_for_landing(void) +{ + switch (fence.auto_enabled()) { + case AC_Fence::AutoEnable::ALWAYS_ENABLED: + fence.enable(false); + gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (auto disable)"); + break; + case AC_Fence::AutoEnable::ENABLE_DISABLE_FLOOR_ONLY: + fence.disable_floor(); + gcs().send_text(MAV_SEVERITY_NOTICE, "Fence floor disabled (auto disable)"); + break; + default: + // fence does not auto-disable in other landing conditions + break; + } +} + #endif \ No newline at end of file diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index e01c55d0b1..4c8818212f 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -1306,7 +1306,9 @@ void QuadPlane::init_qland(void) #if LANDING_GEAR_ENABLED == ENABLED plane.g2.landing_gear.deploy_for_landing(); #endif +#if AC_FENCE == ENABLED plane.disable_fence_for_landing(); +#endif }