From f6c69b94a95c2998e245f2b5325b41a7249fd735 Mon Sep 17 00:00:00 2001 From: duongtd Date: Tue, 10 Nov 2026 13:42:23 +0700 Subject: [PATCH] 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. --- README.md | 12 ++++++++++++ src/lane_route_planner.cpp | 12 +++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c9b5f4..c01a865 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,18 @@ Keys (defaults from `PlannerConfig`): - `lattice_field_standability_relax_m: 0.0` [m]: shrink each inflated footprint half size for the lattice field's standability test only. Higher values can reopen blocked gaps and improve the guide, but can also guide search into impossible gaps. The extra-clearance filter remains separate; search and final footprint checks keep the full gap. +- `lattice_field_zone_margin_deg: 0.0` [deg]: the heuristic field takes a diagonal grid step through a direction zone only + within (deviation - margin) of the zone direction. Grid steps are 45 deg apart, so at a deviation of exactly 45 deg the + field otherwise follows a diagonal at the limit of the rule that a turning robot cannot hold, and the search floods + until the budget ends. Axis steps keep the full deviation (closing them too slowed 90 deg queries). Search and + verification keep the full deviation. +- `lattice_alt_field_enabled: false`, `lattice_alt_field_relax_m: 0.035` [m], `lattice_alt_field_switch_fraction: 0.35`: + a second heuristic field. One 2D field cannot suit both kinds of narrow passage: a strict field closes passages the + robot only fits off the cell centre, an optimistic one leads the search into post gaps no heading fits. When the + search on the first field has not finished at the switch fraction of the fallback slice, it restarts once on a field + with no extra clearance and the alternate relax. An exhausted search does not switch (the field orders states, it + does not make them legal). Skipped when the first field already has no extra clearance and the same relax. The + `[debug] fallback` line reports `field_pass=primary|alternate`. - `debug/dump_dir: ""`, `debug/dump_max_files: 20`: when the directory is set, each failed query writes its static cost, master cost, direction codes and poses as `lane_route_eval` input (`.grid`, `.live`, `.scene`, `.txt`), at most that many per session. Off by default because diff --git a/src/lane_route_planner.cpp b/src/lane_route_planner.cpp index 287a0a1..cb8dc10 100644 --- a/src/lane_route_planner.cpp +++ b/src/lane_route_planner.cpp @@ -96,6 +96,10 @@ SessionConfig loadSessionConfig(const robot::NodeHandle& nh) load("lattice_analytic_goal_headings", p.lattice_analytic_goal_headings, d.lattice_analytic_goal_headings); load("lattice_field_extra_clearance_m", p.lattice_field_extra_clearance_m, d.lattice_field_extra_clearance_m); load("lattice_field_standability_relax_m", p.lattice_field_standability_relax_m, d.lattice_field_standability_relax_m); + load("lattice_field_zone_margin_deg", p.lattice_field_zone_margin_deg, d.lattice_field_zone_margin_deg); + load("lattice_alt_field_enabled", p.lattice_alt_field_enabled, d.lattice_alt_field_enabled); + load("lattice_alt_field_relax_m", p.lattice_alt_field_relax_m, d.lattice_alt_field_relax_m); + load("lattice_alt_field_switch_fraction", p.lattice_alt_field_switch_fraction, d.lattice_alt_field_switch_fraction); load("lattice_field_time_fraction", p.lattice_field_time_fraction, d.lattice_field_time_fraction); load("lattice_field_cell_factor", p.lattice_field_cell_factor, d.lattice_field_cell_factor); int field_max_cells = static_cast(d.lattice_field_max_cells); @@ -117,9 +121,10 @@ SessionConfig loadSessionConfig(const robot::NodeHandle& nh) void logPlanResult(const lane_route_core::PlanResult& result, bool debug_fallback) { if (debug_fallback && result.info.lattice_ms > 0.0) - robot::log_info("[lane_route_planner] [debug] fallback tier=%s graph_reason=%s lattice_reason=%s gap_pass=%s min_gap_m=%.3f gap_exact=%d expanded=%llu field=%.1fms search=%.1fms verify=%.1fms upgrade=%.1fms peak=%.1fMiB", + robot::log_info("[lane_route_planner] [debug] fallback tier=%s graph_reason=%s lattice_reason=%s field_pass=%s gap_pass=%s min_gap_m=%.3f gap_exact=%d expanded=%llu field=%.1fms search=%.1fms verify=%.1fms upgrade=%.1fms peak=%.1fMiB", result.info.tier_used.empty() ? "none" : result.info.tier_used.c_str(), result.info.graph_reason.c_str(), result.info.lattice_reason.c_str(), + result.info.lattice_field_pass.empty() ? "none" : result.info.lattice_field_pass.c_str(), result.info.lattice_gap_pass.empty() ? "none" : result.info.lattice_gap_pass.c_str(), result.info.min_gap_m, result.info.lattice_gap_exact ? 1 : 0, static_cast(result.info.lattice_states_expanded), result.info.lattice_field_ms, @@ -167,10 +172,11 @@ bool LaneRoutePlanner::initialize(std::string name, robot_costmap_2d::Costmap2DR robot::log_info("[lane_route_planner] %s: time_limit=%.2fs min_radius=%.3fm clearance_margin=%.3fm gap=%.3fm debug_plan=%d debug_state=%d", name.c_str(), p.time_limit_s, p.min_turn_radius_m, config_.clearance_min_margin_m, p.footprint_min_gap_m, config_.debug_plan, config_.debug_state); - robot::log_info("[lane_route_planner] fallback: lattice_enabled=%d fallback_time_limit_s=%.2f lattice_preferred_gap_m=%.3f lattice_preferred_time_fraction=%.2f lattice_smooth_enabled=%d lattice_smooth_max_checks=%lld lattice_heuristic_weight=%.2f lattice_heading_bins=%d lattice_max_memory_mb=%lld lattice_field_standability_relax_m=%.3f debug/fallback=%d", + robot::log_info("[lane_route_planner] fallback: lattice_enabled=%d fallback_time_limit_s=%.2f lattice_preferred_gap_m=%.3f lattice_preferred_time_fraction=%.2f lattice_smooth_enabled=%d lattice_smooth_max_checks=%lld lattice_heuristic_weight=%.2f lattice_heading_bins=%d lattice_max_memory_mb=%lld lattice_field_standability_relax_m=%.3f lattice_field_zone_margin_deg=%.1f lattice_alt_field_enabled=%d lattice_alt_field_relax_m=%.3f lattice_alt_field_switch_fraction=%.2f debug/fallback=%d", p.lattice_enabled, p.fallback_time_limit_s, p.lattice_preferred_gap_m, p.lattice_preferred_time_fraction, p.lattice_smooth_enabled, static_cast(p.lattice_smooth_max_checks), p.lattice_heuristic_weight, p.lattice_heading_bins, - static_cast(p.lattice_max_memory_mb), p.lattice_field_standability_relax_m, config_.debug_fallback); + static_cast(p.lattice_max_memory_mb), p.lattice_field_standability_relax_m, + p.lattice_field_zone_margin_deg, p.lattice_alt_field_enabled, p.lattice_alt_field_relax_m, p.lattice_alt_field_switch_fraction, config_.debug_fallback); robot::log_info("[lane_route_planner] radii: min_turn_radius_m=%.3f corner_radii_m=%zu values %.3f..%.3f regular_turn_radius_m=%.3f max_kink_deg=%.1f lattice_tight_arcs=%d lattice_tight_turn_cost_m=%.3f", p.min_turn_radius_m, p.corner_radii_m.size(), p.corner_radii_m.front(), p.corner_radii_m.back(), p.regular_turn_radius_m, p.max_kink_deg, p.lattice_tight_arcs, p.lattice_tight_turn_cost_m);