From f3b4f8fdc4cf19d8761e52a80404a5ce71763fa5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 11 Sep 2024 10:19:23 +1000 Subject: [PATCH] Plane: added Q_APPROACH_DIST this sets a minimum distance to use the fixed wing approach logic. It is an alternative to just disabling the approach with Q_OPTIONS which some users do to avoid some short distance problems. This allows the approach to still be used for longer distances in QRTL but have it disabled for shorter distances --- ArduPlane/quadplane.cpp | 12 +++++++++++- ArduPlane/quadplane.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index 3c0d2e18fd..05748796e4 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -538,6 +538,15 @@ const AP_Param::GroupInfo QuadPlane::var_info2[] = { // @User: Standard AP_GROUPINFO("BCK_PIT_LIM", 38, QuadPlane, q_bck_pitch_lim, 10.0f), + // @Param: APPROACH_DIST + // @DisplayName: Q mode approach distance + // @Description: The minimum distance from the destination to use the fixed wing airbrake and approach code for landing approach. This is useful if you don't want the fixed wing approach logic to be used when you are close to the destination. Set to zero to always use fixed wing approach. + // @Units: m + // @Range: 0.0 1000 + // @Increment: 1 + // @User: Standard + AP_GROUPINFO("APPROACH_DIST", 39, QuadPlane, approach_distance, 0), + AP_GROUPEND }; @@ -2160,7 +2169,8 @@ void QuadPlane::run_xy_controller(float accel_limit) void QuadPlane::poscontrol_init_approach(void) { const float dist = plane.current_loc.get_distance(plane.next_WP_loc); - if (option_is_set(QuadPlane::OPTION::DISABLE_APPROACH)) { + if (option_is_set(QuadPlane::OPTION::DISABLE_APPROACH) || + (is_positive(approach_distance) && dist < approach_distance)) { // go straight to QPOS_POSITION1 poscontrol.set_state(QPOS_POSITION1); gcs().send_text(MAV_SEVERITY_INFO,"VTOL Position1 d=%.1f", dist); diff --git a/ArduPlane/quadplane.h b/ArduPlane/quadplane.h index ea3bba8779..6a810f2325 100644 --- a/ArduPlane/quadplane.h +++ b/ArduPlane/quadplane.h @@ -609,6 +609,9 @@ private: return (options.get() & int32_t(option)) != 0; } + // minimum distance to be from destination to use approach logic + AP_Float approach_distance; + AP_Float takeoff_failure_scalar; AP_Float maximum_takeoff_airspeed; uint32_t takeoff_start_time_ms;