feat(lane_route): keep a preferred footprint gap on lattice paths (R2.5)

The lattice tier first finds a path with the minimum gap, as before, so
coverage cannot drop. If that path is not legal under
lattice_preferred_gap_m (0.15 m) away from the ends, a bounded upgrade
search (lattice_preferred_time_fraction of the rung slice) tries a wider
path and replaces it on success. Smoothing keeps the margin of the
returned path. PlanInfo, eval JSON and the plugin debug/fallback line
report the gap pass, the minimum gap and the upgrade time. The plugin
loads the preferred-gap and smoother keys.

regress7 (3 s): coverage equal to R2c (hook_150 1718, kit 1709),
graph-only output identical, middle gap >= 0.15 m on 133/153 and
128/190 lattice paths (R2c 88 and 89), Python recheck 0 bad.
This commit is contained in:
2026-11-09 17:42:48 +07:00
parent ad326f535c
commit 17ec2466b1
3 changed files with 54 additions and 5 deletions

View File

@@ -233,6 +233,10 @@ TEST(AdapterConfig, LatticeYamlReachesPlannerConfig)
robot::NodeHandle root;
root.setParam("LaneRouteLatticeConfigTest", YAML::Load(R"(
lattice_enabled: true
lattice_preferred_gap_m: 0.18
lattice_preferred_time_fraction: 0.35
lattice_smooth_enabled: false
lattice_smooth_max_checks: 123456
lattice_heading_bins: 64
lattice_closed_resolution_m: 0.2
lattice_heuristic_weight: 2.0
@@ -261,6 +265,10 @@ TEST(AdapterConfig, LatticeYamlReachesPlannerConfig)
const auto& p = config.planner;
EXPECT_TRUE(config.validate().empty());
EXPECT_TRUE(p.lattice_enabled);
EXPECT_DOUBLE_EQ(p.lattice_preferred_gap_m, 0.18);
EXPECT_DOUBLE_EQ(p.lattice_preferred_time_fraction, 0.35);
EXPECT_FALSE(p.lattice_smooth_enabled);
EXPECT_EQ(p.lattice_smooth_max_checks, 123456);
EXPECT_EQ(p.lattice_heading_bins, 64);
EXPECT_DOUBLE_EQ(p.lattice_closed_resolution_m, 0.2);
EXPECT_DOUBLE_EQ(p.lattice_heuristic_weight, 2.0);
@@ -289,6 +297,10 @@ TEST(AdapterConfig, LatticeYamlReachesPlannerConfig)
const PlannerConfig expected;
EXPECT_FALSE(defaults.planner.lattice_enabled);
EXPECT_EQ(defaults.planner.lattice_heading_bins, expected.lattice_heading_bins);
EXPECT_DOUBLE_EQ(defaults.planner.lattice_preferred_gap_m, expected.lattice_preferred_gap_m);
EXPECT_DOUBLE_EQ(defaults.planner.lattice_preferred_time_fraction, expected.lattice_preferred_time_fraction);
EXPECT_EQ(defaults.planner.lattice_smooth_enabled, expected.lattice_smooth_enabled);
EXPECT_EQ(defaults.planner.lattice_smooth_max_checks, expected.lattice_smooth_max_checks);
EXPECT_DOUBLE_EQ(defaults.planner.fallback_time_limit_s, expected.fallback_time_limit_s);
EXPECT_EQ(defaults.planner.lattice_field_max_cells, expected.lattice_field_max_cells);
EXPECT_EQ(defaults.planner.lattice_max_memory_mb, expected.lattice_max_memory_mb);
@@ -320,6 +332,23 @@ TEST(AdapterConfig, InvalidLatticeRejectsPluginInitialization)
EXPECT_FALSE(disabled_initialized);
EXPECT_NE(disabled_log.find("invalid configuration: lattice_heading_bins must be even and in [8, 1024]"),
std::string::npos);
// A minimum gap above the preferred gap only switches the preferred pass off; it must not stop initialisation.
root.setParam("LaneRouteWideMinimumGapTest", YAML::Load("{lattice_enabled: true, footprint_min_gap_m: 0.20}"));
LaneRoutePlanner wide_gap;
testing::internal::CaptureStdout();
EXPECT_FALSE(wide_gap.initialize("LaneRouteWideMinimumGapTest", nullptr));
const std::string wide_gap_log = testing::internal::GetCapturedStdout();
EXPECT_EQ(wide_gap_log.find("invalid configuration"), std::string::npos);
EXPECT_NE(wide_gap_log.find("missing costmap"), std::string::npos);
// A broken smoother budget is rejected even while the lattice is off.
root.setParam("LaneRouteDisabledSmoothTest", YAML::Load("{lattice_enabled: false, lattice_smooth_max_checks: -1}"));
LaneRoutePlanner disabled_smooth;
testing::internal::CaptureStdout();
EXPECT_FALSE(disabled_smooth.initialize("LaneRouteDisabledSmoothTest", nullptr));
const std::string disabled_smooth_log = testing::internal::GetCapturedStdout();
EXPECT_NE(disabled_smooth_log.find("invalid configuration"), std::string::npos);
}
TEST(AdapterLog, FallbackSwitchDoesNotSuppressFailure)
@@ -332,6 +361,9 @@ TEST(AdapterLog, FallbackSwitchDoesNotSuppressFailure)
result.info.graph_reason = "no_route";
result.info.lattice_reason = "lattice_exhausted";
result.info.lattice_ms = 1.0;
result.info.lattice_gap_pass = "minimum";
result.info.min_gap_m = 0.08;
result.info.lattice_upgrade_ms = 12.3;
result.info.lattice_rung_reasons.push_back(result.info.lattice_reason);
testing::internal::CaptureStdout();
logPlanResult(result, config.debug_fallback);
@@ -342,6 +374,8 @@ TEST(AdapterLog, FallbackSwitchDoesNotSuppressFailure)
logPlanResult(result, true);
const std::string verbose = testing::internal::GetCapturedStdout();
EXPECT_NE(verbose.find("[debug] fallback tier=none"), std::string::npos);
EXPECT_NE(verbose.find("gap_pass=minimum min_gap_m=0.080"), std::string::npos);
EXPECT_NE(verbose.find("upgrade=12.3ms"), std::string::npos);
EXPECT_NE(verbose.find("plan failed: lattice_exhausted"), std::string::npos);
result.info.lattice_ms = 0.0;