feat(lane_route): sharp corners as the last radius rung, heuristic field margin (R2.7)

max_kink_deg (default 45): in the graph's second pass, a corner where no
radius fits may become a sharp corner (two straight lines meeting at one
vertex pose, no turn in place) when the footprint can rotate at the
vertex; the verifier counts it in PathCheck::corners. The verifier's
bend limit now follows min_turn_radius_m (it blocked radii below ~0.72 m).

lattice_field_extra_clearance_m (default 0): extra clearance for a cell
to be passable in the lattice heuristic field only, with a rebuild of
the plain field when the margin field never reaches the start.

regress7 with the sim settings (0.4 m floor, margin 0.1): hook_150
1717/1757, kit 1716/1757 (R2.5: 1718, 1709); Python recheck finds no
curvature, corner, spin, zone or crossing errors. The graph tier's
30 mm gap still ignores unknown cells, as since R0.
This commit is contained in:
2026-11-09 23:30:46 +07:00
parent 907fa0c4dc
commit 527071827f
11 changed files with 112 additions and 15 deletions

View File

@@ -288,11 +288,24 @@ TEST(Verifier, FlagsEachHardRule)
spin_end.push_back({ straight.back().x, straight.back().y, 0.1 * i, 0.0 });
EXPECT_TRUE(verifyPath(spin_end, grid, 90.0, config).valid);
// Sharp bend without a turn in place.
// Sharp bend without a turn in place: a kink when sharp corners are off, a counted corner within max_kink_deg.
Path bend(straight.begin(), straight.begin() + 51);
for (int i = 1; i <= 50; ++i)
bend.push_back({ bend[50].x + 0.04 * i * std::cos(0.5), bend[50].y + 0.04 * i * std::sin(0.5), 0.5, 0.0 });
EXPECT_GT(verifyPath(bend, grid, 90.0, config).kinks, 0);
PlannerConfig no_corners = config;
no_corners.max_kink_deg = 0.0;
EXPECT_GT(verifyPath(bend, grid, 90.0, no_corners).kinks, 0);
PlannerConfig corners_45 = config;
corners_45.max_kink_deg = 45.0;
const PathCheck corner_check = verifyPath(bend, grid, 90.0, corners_45);
EXPECT_EQ(corner_check.kinks, 0);
EXPECT_EQ(corner_check.corners, 1);
EXPECT_LE(corner_check.max_curvature, 1.0 / corners_45.min_turn_radius_m + 1e-6);
// A 1.0 rad (57 deg) corner exceeds 45 deg.
Path steep(straight.begin(), straight.begin() + 51);
for (int i = 1; i <= 50; ++i)
steep.push_back({ steep[50].x + 0.04 * i * std::cos(1.0), steep[50].y + 0.04 * i * std::sin(1.0), 1.0, 0.0 });
EXPECT_FALSE(verifyPath(steep, grid, 90.0, corners_45).valid);
// A path that loops over itself.
Path loop;
@@ -2060,3 +2073,16 @@ TEST(LatticeTightArcs, OpenSpaceKeepsRegularRadius)
for (const PathPoint& point : result.path)
EXPECT_LE(std::abs(point.curvature), 1.0 / 1.06 + 1e-6);
}
TEST(LatticeFieldMargin, MarginThatClosesTheOnlyWayFallsBackToThePlainField)
{
// A 1.0 m corridor: with a 0.5 m extra field clearance no cell between the ends is passable, so the margin field never reaches
// the start. The tier must rebuild the plain field and still find the corridor path.
LatticeTestGrid map(120, 100);
preferredGapCorridor(&map, 40, 59);
PlannerConfig config = latticeConfig();
config.lattice_field_extra_clearance_m = 0.5;
const auto result = map.plan(latticeRequest(pose(1.0, 2.5, 0.0), pose(4.5, 2.5, 0.0)), config);
ASSERT_TRUE(result.ok) << result.info.reason;
EXPECT_EQ(result.info.tier_used, "lattice");
}