feat(lane_route): radius ladder and failure dumps (R2.6)

Radius ladder: the first graph pass, the lattice and the smoother use
only radii at or above regular_turn_radius_m (1.06 m), as before. When
min_turn_radius_m is lower, the graph runs a second pass with all
corner_radii_m if the first fails or returns a long detour, and keeps
it only when at least 20% shorter. Optional lattice tight arcs exist
behind lattice_tight_arcs (off: they cost many queries to timeouts).
C++ defaults keep the old 1.06 m floor; regress7 output is identical.
With a 0.4 m floor: graph-only coverage +5 (hook_150) and +8 (kit),
none lost; with fallback, coverage unchanged and 27/29 queries move
from lattice to graph; tight corners used 0.9 m.

Failure dumps: with debug/dump_dir set, the plugin writes each failed
query as lane_route_eval input (static cost, master cost, direction
codes, poses, settings), at most debug/dump_max_files per session.
This commit is contained in:
2026-11-09 20:09:43 +07:00
parent d27cff23bd
commit 907fa0c4dc
8 changed files with 149 additions and 14 deletions

View File

@@ -27,6 +27,21 @@ using detail::Clock;
using detail::TimePoint;
using detail::msSince;
namespace
{
// A tight-corner graph path replaces a large-radius one only when it is at least this much shorter, so a large radius stays the
// default shape and a tight corner appears where it removes a real detour.
constexpr double kTightMinSaving = 0.2;
double polylineLength(const Path& path)
{
double length = 0.0;
for (std::size_t i = 1; i < path.size(); ++i)
length += std::hypot(path[i].x - path[i - 1].x, path[i].y - path[i - 1].y);
return length;
}
} // namespace
PlanResult planRoute(const GraphProvider& graphs, const RouteRequest& request, const GridRef& live, const PlannerConfig& config,
const RidgeBackend& backend)
{
@@ -100,6 +115,22 @@ PlanResult planRoute(const GraphProvider& graphs, const RouteRequest& request, c
}
rungs.push_back(config.max_deviation_deg);
// Radius ladder. The first graph pass and the lattice use only radii at or above regular_turn_radius_m, which is how every
// tier planned before the floor could be lowered. A lower min_turn_radius_m only adds a second graph pass with all corner
// radii, for a failed first pass or a long detour (measured 9/11: letting the route search and the lattice use the low floor
// from the start lost 25 to 84 regress7 queries).
PlannerConfig regular = config;
regular.min_turn_radius_m = std::max(config.regular_turn_radius_m, config.min_turn_radius_m);
regular.corner_radii_m.clear();
for (double radius : config.corner_radii_m)
if (radius >= regular.min_turn_radius_m - 1e-9)
regular.corner_radii_m.push_back(radius);
if (regular.corner_radii_m.empty())
regular.corner_radii_m.push_back(regular.min_turn_radius_m);
const bool tight_corners = config.min_turn_radius_m < regular.min_turn_radius_m - 1e-9;
const PlannerConfig& lattice_config = config.lattice_tight_arcs ? config : regular;
const double chord = std::hypot(request.goal.x - request.start.x, request.goal.y - request.start.y);
// R2 smoothing must share this fallback deadline instead of starting a new budget.
TimePoint fallback_deadline = deadline;
bool fallback_started = false;
@@ -123,8 +154,35 @@ PlanResult planRoute(const GraphProvider& graphs, const RouteRequest& request, c
else
{
result.info.live_ridge.clear();
graph_ok = detail::planGraphTier({ *graph, request, live, deadline, config, backend },
graph_ok = detail::planGraphTier({ *graph, request, live, deadline, tight_corners ? regular : config, backend },
{ result.path, result.check, result.info });
const bool detour = graph_ok && polylineLength(result.path) > config.suspicious_ratio * chord + config.suspicious_margin_m;
const bool stopped = (request.cancel && request.cancel->load(std::memory_order_relaxed)) || Clock::now() >= deadline ||
result.info.reason == "timeout" || result.info.reason == "no_route_enclosed";
if (tight_corners && (!graph_ok || detour) && !stopped)
{
Path tight_path;
PathCheck tight_check;
PlanInfo tight_info = result.info;
tight_info.live_ridge.clear();
const bool tight_ok = detail::planGraphTier({ *graph, request, live, deadline, config, backend },
{ tight_path, tight_check, tight_info });
// A tight corner must buy a clearly shorter path; otherwise the large-radius shape stays.
if (tight_ok && (!graph_ok || polylineLength(tight_path) < (1.0 - kTightMinSaving) * polylineLength(result.path)))
{
result.path = std::move(tight_path);
result.check = tight_check;
result.info = tight_info;
result.info.graph_radius_pass = "tight";
graph_ok = true;
}
else if (!graph_ok)
{
result.info = tight_info;
}
}
if (graph_ok && result.info.graph_radius_pass.empty())
result.info.graph_radius_pass = "regular";
}
result.info.graph_reason = result.info.reason;
result.info.graph_rung_reasons.push_back(result.info.graph_reason);
@@ -168,7 +226,7 @@ PlanResult planRoute(const GraphProvider& graphs, const RouteRequest& request, c
break;
}
const TimePoint rung_deadline = now + (fallback_deadline - now) / static_cast<Clock::duration::rep>(rungs.size() - rung);
if (detail::planLatticeTier({ request, live, config, deviation, rung_deadline, fallback_deadline },
if (detail::planLatticeTier({ request, live, lattice_config, deviation, rung_deadline, fallback_deadline },
{ result.path, result.check, result.info }))
{
result.ok = true;