feat(lane_route): footprint standability, unknown cells in graph gap (R2.8)

- Standability: a cell is passable for the graph length reference and the
  lattice heuristic field only when the footprint plus the minimum gap fits
  at one of 16 headings; memoised per 32x32 tile, open space skips the test.
- Graph reference no longer cuts diagonal corners; route_too_long reports
  the reference length.
- Lattice field: coarse block passability decided lazily on first touch.
- ReferenceMemo: one route_too_long reference search per core pass instead
  of one per candidate.
- Graph tier counts unknown cells as obstacles for the footprint gap, like
  the lattice (user ruling 10/11).
- PlanInfo and eval JSON: standability counters, graph reference length.
This commit is contained in:
2026-11-10 10:01:39 +07:00
parent 527071827f
commit 4453f454a9
13 changed files with 516 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
#include "route_planner_internal.h"
#include "standability.h"
#include <algorithm>
#include <array>
@@ -43,6 +44,11 @@ bool planCore(const CompiledGraph& graph, const Pose2& start, const Pose2& goal,
clearanceThresholdMm(config.collision_check_distance_m), {} };
context.info = info;
context.cancel = cancel;
Standability standability(verify_grid, config, std::pmr::get_default_resource(), &info->graph_standability_tests,
&info->graph_standability_rejected, cancel, &deadline);
context.standability = &standability;
ReferenceMemo reference_memo;
context.reference = &reference_memo;
const Point2 start_point{ start.x, start.y };
const Point2 goal_point{ goal.x, goal.y };
const double dev = graph.deviation_deg;
@@ -186,7 +192,8 @@ bool planCore(const CompiledGraph& graph, const Pose2& start, const Pose2& goal,
if (path_check.valid && ends_ok && clear_ok)
{
timer = Clock::now();
gap = checkFootprintGap(candidate.path, verify_grid, config.footprint_min_gap_m, config.half_x_m, config.half_y_m, context.cancel);
gap = checkFootprintGap(candidate.path, verify_grid, config.footprint_min_gap_m, config.half_x_m, config.half_y_m, context.cancel,
nullptr, true);
info->verify_ms += msSince(timer);
gap_checked = true;
if (!gap.valid)
@@ -209,7 +216,8 @@ bool planCore(const CompiledGraph& graph, const Pose2& start, const Pose2& goal,
blockedEndpointTurn(alternative.path, verify_grid, config.half_x_m, config.half_y_m) == nullptr;
GapCheck alternative_gap;
if (usable)
alternative_gap = checkFootprintGap(alternative.path, verify_grid, config.footprint_min_gap_m, config.half_x_m, config.half_y_m, context.cancel);
alternative_gap = checkFootprintGap(alternative.path, verify_grid, config.footprint_min_gap_m, config.half_x_m, config.half_y_m,
context.cancel, nullptr, true);
info->verify_ms += msSince(timer);
if (!usable)
continue;
@@ -223,7 +231,8 @@ bool planCore(const CompiledGraph& graph, const Pose2& start, const Pose2& goal,
{
const double bound = (length - config.route_too_long_margin_m) / config.route_too_long_ratio;
double reference = 0.0;
if (shortestDirectedReference(verify_grid, start_point, goal_point, dev, bound, &reference, context.cancel) &&
if (cachedStandableReference(verify_grid, start_point, goal_point, dev, bound, &reference, standability, reference_memo,
context.cancel, &deadline) &&
length > config.route_too_long_ratio * reference + config.route_too_long_margin_m)
continue;
reference_checked = true;
@@ -252,10 +261,12 @@ bool planCore(const CompiledGraph& graph, const Pose2& start, const Pose2& goal,
timer = Clock::now();
const double bound = (length - config.route_too_long_margin_m) / config.route_too_long_ratio;
double reference = 0.0;
const bool known = shortestDirectedReference(verify_grid, start_point, goal_point, dev, bound, &reference, context.cancel);
const bool known = cachedStandableReference(verify_grid, start_point, goal_point, dev, bound, &reference, standability,
reference_memo, context.cancel, &deadline);
info->verify_ms += msSince(timer);
if (known && length > config.route_too_long_ratio * reference + config.route_too_long_margin_m)
{
info->graph_reference_length_m = reference;
reason = "route_too_long";
break;
}
@@ -391,6 +402,10 @@ bool planRung(const CompiledGraph& graph, const RouteRequest& request, const Gri
}
info->retries += live_info.retries;
info->gap_failures += live_info.gap_failures;
info->graph_standability_tests += live_info.graph_standability_tests;
info->graph_standability_rejected += live_info.graph_standability_rejected;
if (live_info.graph_reference_length_m > 0.0)
info->graph_reference_length_m = live_info.graph_reference_length_m;
info->search_ms += live_info.search_ms;
info->build_ms += live_info.build_ms;
info->verify_ms += live_info.verify_ms;