feat(lane_route_core): zone deviation cost and graph/lattice completeness fixes (R2.12)

- Graph tier: add zone_deviation_cost (weight * ds * dev_deg/45) to compiled,
  query and shortcut edges, so aligned travel is preferred and a diagonal is
  only used where a straight move is not possible.
- Drop the route_too_long rejection; its relaxed standability reference
  ignored heading continuity and discarded verified long routes.
- Graph retries: skip duplicate candidates and block the edge pair nearest
  the verifier failure location.
- Lattice: heading-sector guide field, zone-transition retry, finer-bin
  refinement before reporting lattice_approx_exhausted, analytic connector
  best-cost choice. The lattice plans with zone_deviation_weight 0.
- lane_route_eval: zone_deviation_weight and time_limit_s keys,
  zone_dev_len_m / zone_dev_integral output.

Sim config: random 300 scenes hook 224 vs 212, kit 199 vs 196; regress7
3416 = R2.11 baseline; independent recheck 0 violations; 128 tests pass.
This commit is contained in:
2026-11-11 14:31:32 +07:00
parent d36921f5b3
commit 4cb395f525
21 changed files with 686 additions and 127 deletions

View File

@@ -114,7 +114,7 @@ bool touchesZoneRegion(const PathPoint& pose, uint32_t region, const GridRef& gr
int footprintZoneViolations(const Path& samples, const GridRef& grid, double deviation_deg, const PlannerConfig& config,
std::vector<ZoneEndCell> start_cells, std::vector<ZoneEndCell> goal_cells,
detail::FootprintZoneIndex& index, const std::atomic<bool>* cancel,
const std::chrono::steady_clock::time_point* deadline)
const std::chrono::steady_clock::time_point* deadline, PathCheck* check)
{
if (grid.direction == nullptr || samples.empty()) return 0;
const auto stopped = [&]() {
@@ -161,7 +161,18 @@ int footprintZoneViolations(const Path& samples, const GridRef& grid, double dev
for (uint32_t region : rejected_regions) pending.push_back({i, region});
}
if (pending.empty()) return 0;
if (config.zone_transition_m <= 0.0) return static_cast<int>(pending.size());
const auto locate = [&](const Pending& entry) {
if (!check->has_failure_location)
{
check->has_failure_location = true;
check->failure_location = { samples[entry.sample].x, samples[entry.sample].y };
}
};
if (config.zone_transition_m <= 0.0)
{
locate(pending.front());
return static_cast<int>(pending.size());
}
// Components that appear here were already flood-filled above; no whole-map label array is needed. Arc distances
// are monotone, so each violation needs one binary search in the centre-entry distances of its own region.
@@ -184,7 +195,11 @@ int footprintZoneViolations(const Path& samples, const GridRef& grid, double dev
const auto& distances = centre_distances.find(entry.region)->second;
const double here = along[entry.sample];
const auto found = std::lower_bound(distances.begin(), distances.end(), here - config.zone_transition_m);
if (found == distances.end() || *found > here + config.zone_transition_m) ++violations;
if (found == distances.end() || *found > here + config.zone_transition_m)
{
locate(entry);
++violations;
}
}
return violations;
}
@@ -373,7 +388,13 @@ PathCheck verifyPath(const Path& path, const GridRef& grid, double deviation_deg
const double arc = std::abs(turn) < 1e-9 ? distance : distance * std::abs(turn) / (2.0 * std::abs(std::sin(turn / 2.0)));
check.max_curvature = std::max(check.max_curvature, std::abs(turn) / arc);
}
check.zone_violations += zoneViolations(a, b, grid, deviation_deg);
const int centre_violations = zoneViolations(a, b, grid, deviation_deg);
check.zone_violations += centre_violations;
if (centre_violations && !check.has_failure_location)
{
check.has_failure_location = true;
check.failure_location = { (a.x + b.x) * 0.5, (a.y + b.y) * 0.5 };
}
const int samples = std::max({ 1, static_cast<int>(std::ceil(distance / 0.01)), static_cast<int>(std::ceil(std::abs(turn) / 0.03)) });
if (corner && grid.direction != nullptr)
{
@@ -397,12 +418,19 @@ PathCheck verifyPath(const Path& path, const GridRef& grid, double deviation_deg
const double t = static_cast<double>(j) / samples;
const double x = a.x + t * dx, y = a.y + t * dy, yaw = a.yaw + t * turn;
if (footprintCollides(grid, x, y, yaw, config.half_x_m, config.half_y_m))
{
++check.footprint_collisions;
if (!check.has_failure_location)
{
check.has_failure_location = true;
check.failure_location = {x, y};
}
}
}
}
const int body_zone_violations = footprintZoneViolations(zone_samples, grid, config.max_deviation_deg, config,
std::move(start_zone_cells), std::move(goal_zone_cells),
zone_index, cancel, deadline);
zone_index, cancel, deadline, &check);
if (body_zone_violations < 0) return check;
check.zone_violations += body_zone_violations;
check.self_crossings = selfCrossings(path, cancel, deadline);