feat(lane_route): heuristic-only standability relax for the lattice field (R2.9)

- lattice_field_standability_relax_m (default 0): shrinks the inflated
  footprint half sizes for the lattice heuristic field only; graph
  reference, C-space and verification stay strict.
- Plugin loads it, prints it on the fallback boot line; README and eval
  override key.
- Measured 10/11: with extra field clearance 0 any relax reopens the sim
  post gaps (dumps 1, 2, 4 time out); with extra clearance 0.1 a relax of
  0.035 keeps them and gains one kit query.
This commit is contained in:
2026-11-10 10:36:02 +07:00
parent 4453f454a9
commit 1d26e29899
7 changed files with 104 additions and 12 deletions

View File

@@ -114,8 +114,9 @@ std::string PlannerConfig::validate() const
error << "regular_turn_radius_m must be finite and > 0";
else if (!not_negative(max_kink_deg) || max_kink_deg > 90.0)
error << "max_kink_deg must be in [0, 90]";
else if (lattice_enabled && (!not_negative(lattice_tight_turn_cost_m) || !not_negative(lattice_field_extra_clearance_m)))
error << "lattice_tight_turn_cost_m and lattice_field_extra_clearance_m must be finite and >= 0";
else if (lattice_enabled && (!not_negative(lattice_tight_turn_cost_m) || !not_negative(lattice_field_extra_clearance_m) ||
!not_negative(lattice_field_standability_relax_m)))
error << "lattice_tight_turn_cost_m, lattice_field_extra_clearance_m and lattice_field_standability_relax_m must be finite and >= 0";
else if (lattice_enabled && (!not_negative(lattice_preferred_gap_m) ||
!positive(lattice_preferred_time_fraction) || lattice_preferred_time_fraction > 1.0))
error << "lattice_preferred_gap_m must be >= 0; lattice_preferred_time_fraction must be in (0, 1]";

View File

@@ -83,13 +83,18 @@ bool buildLatticeField(LatticeContext& context, LatticeField* field, TimePoint f
if (cells64 > std::numeric_limits<int32_t>::max()) return true;
const std::size_t cells = static_cast<std::size_t>(cells64);
// The extra field margin remains a separate heuristic filter; standability always uses the hard minimum gap.
// The extra field clearance remains a separate heuristic filter, independent of standability relaxation.
const PlannerConfig& config = context.config;
const double fit_m = std::min(config.half_x_m, config.half_y_m) + config.footprint_min_gap_m - g.resolution +
std::max(0.0, extra_clearance_m);
const uint16_t fit_mm = static_cast<uint16_t>(std::max(0.0, std::min(65535.0, std::floor(fit_m * 1000.0))));
// res/sqrt(2) covers translation from any position in a cell to its centre; an additional
// 2*R*sin(pi/64), where R is the inflated footprint circumradius, covers headings between
// the 16 samples. Larger relaxations can reopen gaps where no heading fits (closed in R2.8).
// This changes only the heuristic; search and verification use the full footprint and gap.
Standability standability(g, config, &context.memory, &context.info.lattice_standability_tests,
&context.info.lattice_standability_rejected, context.request.cancel, &field_deadline);
&context.info.lattice_standability_rejected, context.request.cancel, &field_deadline,
config.lattice_field_standability_relax_m);
const auto fits = [&](std::size_t cell) {
return (extra_clearance_m <= 0.0 || g.clearance_mm[cell] >= fit_mm) &&
standability.fits(cell);

View File

@@ -11,8 +11,10 @@ namespace detail
{
Standability::Standability(const GridRef& grid, const PlannerConfig& config, std::pmr::memory_resource* memory,
uint64_t* tests, uint64_t* rejected, const std::atomic<bool>* cancel,
const std::chrono::steady_clock::time_point* deadline)
: grid_(grid), config_(config), tiles_(memory), tests_(tests), rejected_(rejected), cancel_(cancel), deadline_(deadline)
const std::chrono::steady_clock::time_point* deadline, double relax_m)
: grid_(grid), half_x_m_(std::max(0.0, config.half_x_m + config.footprint_min_gap_m - relax_m)),
half_y_m_(std::max(0.0, config.half_y_m + config.footprint_min_gap_m - relax_m)),
tiles_(memory), tests_(tests), rejected_(rejected), cancel_(cancel), deadline_(deadline)
{
}
@@ -24,8 +26,7 @@ bool Standability::stopped() const
bool Standability::tileHasBlocked(int32_t tx, int32_t ty) const
{
const double radius = std::hypot(config_.half_x_m + config_.footprint_min_gap_m,
config_.half_y_m + config_.footprint_min_gap_m);
const double radius = std::hypot(half_x_m_, half_y_m_);
const double max_pad = static_cast<double>(std::max(grid_.width, grid_.height)) + 2.0;
const int64_t pad = static_cast<int64_t>(std::min(max_pad, std::ceil(radius / grid_.resolution) + 2.0));
const int32_t x0 = static_cast<int32_t>(std::max<int64_t>(0, static_cast<int64_t>(tx) * 32 - pad));
@@ -57,8 +58,8 @@ bool Standability::fits(std::size_t cell)
if (rejected_) ++*rejected_;
return false;
}
const double hx = config_.half_x_m + config_.footprint_min_gap_m;
const double hy = config_.half_y_m + config_.footprint_min_gap_m;
const double hx = half_x_m_;
const double hy = half_y_m_;
const double radius = std::hypot(hx, hy);
const double wx = grid_.origin_x + (x + 0.5) * grid_.resolution;
const double wy = grid_.origin_y + (y + 0.5) * grid_.resolution;

View File

@@ -22,7 +22,7 @@ class Standability
public:
Standability(const GridRef& grid, const PlannerConfig& config, std::pmr::memory_resource* memory,
uint64_t* tests, uint64_t* rejected, const std::atomic<bool>* cancel,
const std::chrono::steady_clock::time_point* deadline);
const std::chrono::steady_clock::time_point* deadline, double relax_m = 0.0);
bool fits(std::size_t cell);
private:
@@ -35,7 +35,8 @@ private:
bool stopped() const;
bool tileHasBlocked(int32_t tx, int32_t ty) const;
const GridRef& grid_;
const PlannerConfig& config_;
const double half_x_m_;
const double half_y_m_;
std::pmr::unordered_map<int64_t, Tile> tiles_;
uint64_t* tests_;
uint64_t* rejected_;