feat(lane_route): second heuristic field and diagonal zone margin (R2.10)

- lattice_alt_field_enabled (default false), lattice_alt_field_relax_m,
  lattice_alt_field_switch_fraction: when the search on the first field
  has not finished at the switch point, it restarts once on a field with
  no extra clearance and the alternate relax. Exhausted searches do not
  switch. PlanInfo/eval/debug line report field_pass.
- lattice_field_zone_margin_deg (default 0): diagonal field steps through
  a direction zone must stay that far inside the deviation limit; at
  exactly 45 deg the field otherwise follows a diagonal a turning robot
  cannot hold (sim M4, M7, 4a timed out even with 10 s).
- lane_route_eval compiles the graph with the live master when it holds
  preferred cells, as the plugin does.
- Measured 10/11 (sim settings, 10 s, margin 15, alternate on): regress7
  hook_150 1719, kit 1718, no query lost, independent recheck 0 bad.
This commit is contained in:
2026-11-10 13:42:23 +07:00
parent 1d26e29899
commit a4b655b74b
8 changed files with 160 additions and 10 deletions

View File

@@ -146,6 +146,9 @@ void applyOverrides(PlannerConfig* config)
{ "lattice_tight_turn_cost_m", &config->lattice_tight_turn_cost_m },
{ "lattice_field_extra_clearance_m", &config->lattice_field_extra_clearance_m },
{ "lattice_field_standability_relax_m", &config->lattice_field_standability_relax_m },
{ "lattice_alt_field_relax_m", &config->lattice_alt_field_relax_m },
{ "lattice_field_zone_margin_deg", &config->lattice_field_zone_margin_deg },
{ "lattice_alt_field_switch_fraction", &config->lattice_alt_field_switch_fraction },
};
const std::map<std::string, int*> ints{
{ "lattice_heading_bins", &config->lattice_heading_bins },
@@ -163,6 +166,7 @@ void applyOverrides(PlannerConfig* config)
const std::map<std::string, bool*> bools{
{ "lattice_smooth_enabled", &config->lattice_smooth_enabled },
{ "lattice_tight_arcs", &config->lattice_tight_arcs },
{ "lattice_alt_field_enabled", &config->lattice_alt_field_enabled },
};
std::stringstream stream(text);
std::string item;
@@ -332,14 +336,19 @@ int main(int argc, char** argv)
coarse = &found->second;
}
// The plugin compiles with the live master, whose preferred cells add their region centre lines to the graph. A live
// grid with preferred cells is compiled the same way here and not cached, since another row may carry other zones.
const bool live_preferred = std::find(live_cost.begin(), live_cost.end(), kPreferredSpace) != live_cost.end();
std::map<double, std::shared_ptr<const CompiledGraph>> row_graphs;
for (double deviation : deviations)
{
config.max_deviation_deg = deviation;
const GraphProvider provider = [&](double limit) -> std::shared_ptr<const CompiledGraph> {
if (coarse == nullptr) return {};
auto& slot = map->graphs[std::make_pair(variant, limit)];
auto& slot = live_preferred ? row_graphs[limit] : map->graphs[std::make_pair(variant, limit)];
if (slot == nullptr)
slot = std::make_shared<const CompiledGraph>(compileGraph(*coarse, compile_grid, compile_grid.cost, limit, config, backend));
slot = std::make_shared<const CompiledGraph>(
compileGraph(*coarse, compile_grid, live_preferred ? live_cost.data() : compile_grid.cost, limit, config, backend));
return slot;
};
const PlanResult result = planRoute(provider, request, live_grid, config, backend);
@@ -381,6 +390,7 @@ int main(int argc, char** argv)
<< ",\"lattice_smooth_rejects_verify\":" << info.lattice_smooth_rejects_verify
<< ",\"lattice_smooth_stop\":\"" << info.lattice_smooth_stop << "\""
<< ",\"lattice_gap_pass\":\"" << info.lattice_gap_pass << "\""
<< ",\"lattice_field_pass\":\"" << info.lattice_field_pass << "\""
<< ",\"lattice_gap_exact\":" << (info.lattice_gap_exact ? 1 : 0)
<< ",\"lattice_min_gap_m\":";
if (result.ok && info.tier_used == "lattice" && std::isfinite(info.min_gap_m)) out << info.min_gap_m;