feat(lane_route): footprint-zone rule with entry/exit transition, longer lane-end links (R2.11)
- A footprint may overlap a direction zone against its heading only within zone_transition_m (default 1.0 m) of path where the centre is inside that same zone, or at a parked endpoint. Checked on whole paths by the verifier. - The lattice C-space keeps the strict per-pose rule so its paths always pass. - Lane-end junction links reach 8 m with up to 24 links (was 6 m / 12 tries). - lane_route_eval can dump the graph, attempts and routes per query.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "../src/lattice_internal.h"
|
||||
#include "../src/standability.h"
|
||||
#include "../src/footprint_zones.h"
|
||||
|
||||
using namespace lane_route_core;
|
||||
|
||||
@@ -1544,6 +1545,11 @@ TEST(Lattice, SameStartAndGoal)
|
||||
TEST(Lattice, InvalidParametersAreRejected)
|
||||
{
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.zone_transition_m = -0.01;
|
||||
EXPECT_FALSE(config.validate().empty());
|
||||
config.zone_transition_m = 0.0;
|
||||
EXPECT_TRUE(config.validate().empty());
|
||||
config = latticeConfig();
|
||||
config.lattice_heading_bins = 71;
|
||||
EXPECT_FALSE(config.validate().empty());
|
||||
config = latticeConfig();
|
||||
@@ -2443,3 +2449,285 @@ TEST(Standability, UnknownCellsAreCheckedDespiteHighLethalClearance)
|
||||
EXPECT_EQ(tests, 1u);
|
||||
EXPECT_EQ(rejected, 1u);
|
||||
}
|
||||
|
||||
TEST(FootprintZones, OppositeZoneAcrossNarrowGapIsRejected)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view();
|
||||
grid.resolution = 0.01;
|
||||
for (int x = 180; x < 310; ++x)
|
||||
{
|
||||
for (int y = 0; y < 85; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
for (int y = 116; y < map.height; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 5;
|
||||
}
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
const Path path{{4.0, 1.0, kPi, 0.0}, {1.0, 1.0, kPi, 0.0}};
|
||||
const PathCheck check = verifyPath(path, grid, 0.01, config);
|
||||
EXPECT_FALSE(check.valid);
|
||||
EXPECT_GT(check.zone_violations, 0);
|
||||
RouteRequest request = latticeRequest(pose(4.0, 1.0, kPi), pose(1.0, 1.0, kPi));
|
||||
PlanInfo info;
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
detail::LatticeMemory memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext context{request, grid, config, 0.01, deadline, info, memory};
|
||||
detail::LatticeCSpace space(context);
|
||||
EXPECT_FALSE(space.poseFree(2.5, 1.0, kPi));
|
||||
EXPECT_FALSE(space.segmentLegal({2.6, 1.0, kPi, 0.0}, {2.4, 1.0, kPi, 0.0}));
|
||||
}
|
||||
|
||||
TEST(FootprintZones, OverlapWithCompatibleDirectionIsAllowed)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int x = 180; x < 310; ++x)
|
||||
{
|
||||
for (int y = 0; y < 85; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 5;
|
||||
for (int y = 116; y < map.height; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 5;
|
||||
}
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
const Path path{{4.0, 1.0, kPi, 0.0}, {1.0, 1.0, kPi, 0.0}};
|
||||
const PathCheck check = verifyPath(path, grid, 0.01, config);
|
||||
EXPECT_TRUE(check.valid);
|
||||
EXPECT_EQ(check.zone_violations, 0);
|
||||
RouteRequest request = latticeRequest(pose(4.0, 1.0, kPi), pose(1.0, 1.0, kPi));
|
||||
PlanInfo info;
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
detail::LatticeMemory memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext context{request, grid, config, 0.01, deadline, info, memory};
|
||||
detail::LatticeCSpace space(context);
|
||||
EXPECT_TRUE(space.poseFree(2.5, 1.0, kPi));
|
||||
}
|
||||
|
||||
TEST(FootprintZones, InitialOverlapMayBeLeftButNotReentered)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int x = 245; x < 250; ++x)
|
||||
for (int y = 80; y < 85; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
const Path leaves{{2.0, 1.0, kPi, 0.0}, {1.0, 1.0, kPi, 0.0}};
|
||||
const PathCheck good = verifyPath(leaves, grid, 0.01, config);
|
||||
EXPECT_TRUE(good.valid);
|
||||
const Path approaches{{3.1, 1.0, kPi, 0.0}, {2.0, 1.0, kPi, 0.0}};
|
||||
EXPECT_TRUE(verifyPath(approaches, grid, 0.01, config).valid);
|
||||
const Path reenters{{2.0, 1.0, kPi, 0.0}, {1.0, 1.0, kPi, 0.0}, {3.1, 1.0, kPi, 0.0}};
|
||||
const PathCheck bad = verifyPath(reenters, grid, 0.01, config);
|
||||
EXPECT_FALSE(bad.valid);
|
||||
EXPECT_GT(bad.zone_violations, 0);
|
||||
}
|
||||
|
||||
TEST(FootprintZones, EndpointSpinCannotEnterANewIncompatibleZoneCell)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
map.direction[static_cast<std::size_t>(100) * map.width + 200] = 5;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.20; config.half_y_m = 0.10;
|
||||
const Path spin{{2.005, 1.005, 0.0, 0.0}, {2.005, 1.005, kPi, 0.0}};
|
||||
EXPECT_TRUE(verifyPath(spin, grid, 0.01, config).valid);
|
||||
// The rotated rectangle reaches this cell, though neither end pose does.
|
||||
map.direction[static_cast<std::size_t>(114) * map.width + 214] = 5;
|
||||
const PathCheck check = verifyPath(spin, grid, 0.01, config);
|
||||
EXPECT_FALSE(check.valid);
|
||||
EXPECT_GT(check.zone_violations, 0);
|
||||
}
|
||||
|
||||
TEST(FootprintZones, EndpointAllowanceFollowsTheConnectedZone)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int x = 120; x < 250; ++x)
|
||||
for (int y = 80; y < 85; ++y) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
const Path leaves{{2.0, 1.0, kPi, 0.0}, {0.6, 1.0, kPi, 0.0}};
|
||||
EXPECT_TRUE(verifyPath(leaves, grid, 0.01, config).valid);
|
||||
RouteRequest request = latticeRequest(pose(2.0, 1.0, kPi), pose(0.6, 1.0, kPi));
|
||||
PlanInfo info;
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
detail::LatticeMemory memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext context{request, grid, config, 0.01, deadline, info, memory};
|
||||
detail::LatticeCSpace space(context);
|
||||
EXPECT_TRUE(space.poseFree(1.5, 1.0, kPi));
|
||||
request.start.has_yaw = false;
|
||||
PlanInfo free_yaw_info;
|
||||
detail::LatticeMemory free_yaw_memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext free_yaw_context{request, grid, config, 0.01, deadline, free_yaw_info, free_yaw_memory};
|
||||
detail::LatticeCSpace free_yaw_space(free_yaw_context);
|
||||
EXPECT_TRUE(free_yaw_space.poseFree(1.5, 1.0, kPi));
|
||||
}
|
||||
|
||||
TEST(FootprintZones, EndpointAllowanceDoesNotCoverAnotherSameDirectionRegion)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int y = 80; y < 85; ++y)
|
||||
{
|
||||
for (int x = 245; x < 250; ++x) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
for (int x = 120; x < 130; ++x) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
}
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
const Path path{{2.0, 1.0, kPi, 0.0}, {0.6, 1.0, kPi, 0.0}};
|
||||
const PathCheck check = verifyPath(path, grid, 0.01, config);
|
||||
EXPECT_FALSE(check.valid);
|
||||
EXPECT_GT(check.zone_violations, 0);
|
||||
}
|
||||
|
||||
TEST(GraphTrace, CapturesQueryEdgesAndDijkstraAttempt)
|
||||
{
|
||||
PlannerConfig config = defaultConfig();
|
||||
const RidgeBackend backend = makeRidgeBackend(config);
|
||||
TestMap map(200, 60);
|
||||
map.finish(config);
|
||||
const GraphProvider provider = map.provider(config, backend);
|
||||
RouteRequest request;
|
||||
request.start = pose(1.0, 1.5, 0.0);
|
||||
request.goal = pose(8.0, 1.5, 0.0);
|
||||
GraphTrace trace;
|
||||
const PlanResult result = planRoute(provider, request, map.compileGrid(), config, backend, &trace);
|
||||
ASSERT_TRUE(result.ok) << result.info.reason;
|
||||
ASSERT_FALSE(trace.runs.empty());
|
||||
const GraphTraceRun& run = trace.runs.front();
|
||||
EXPECT_EQ(run.source, "compiled");
|
||||
ASSERT_GT(run.nodes.size(), static_cast<std::size_t>(run.goal_node));
|
||||
EXPECT_EQ(run.factors.size(), run.edges.size());
|
||||
EXPECT_GT(run.edges.size(), static_cast<std::size_t>(run.base_edges));
|
||||
ASSERT_FALSE(run.attempts.empty());
|
||||
bool saw_verified_route = false;
|
||||
for (const GraphTraceAttempt& attempt : run.attempts)
|
||||
{
|
||||
for (int32_t edge : attempt.route)
|
||||
{
|
||||
EXPECT_GE(edge, 0);
|
||||
EXPECT_LT(static_cast<std::size_t>(edge), run.edges.size());
|
||||
}
|
||||
saw_verified_route = saw_verified_route || (attempt.reason == "verified" && !attempt.route.empty());
|
||||
}
|
||||
EXPECT_TRUE(saw_verified_route);
|
||||
const PlanResult without_trace = planRoute(provider, request, map.compileGrid(), config, backend);
|
||||
ASSERT_TRUE(without_trace.ok) << without_trace.info.reason;
|
||||
ASSERT_EQ(without_trace.path.size(), result.path.size());
|
||||
for (std::size_t i = 0; i < result.path.size(); ++i)
|
||||
{
|
||||
EXPECT_DOUBLE_EQ(without_trace.path[i].x, result.path[i].x);
|
||||
EXPECT_DOUBLE_EQ(without_trace.path[i].y, result.path[i].y);
|
||||
EXPECT_DOUBLE_EQ(without_trace.path[i].yaw, result.path[i].yaw);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(FootprintZones, RegionsMatchEightConnectedReferenceGraphZones)
|
||||
{
|
||||
LatticeTestGrid map(20, 20);
|
||||
map.direction[5 * map.width + 5] = 1;
|
||||
map.direction[6 * map.width + 6] = 1;
|
||||
map.direction[10 * map.width + 10] = 1;
|
||||
map.direction[5 * map.width + 6] = 2;
|
||||
GridRef grid = map.view();
|
||||
detail::FootprintZoneIndex index(grid);
|
||||
const uint32_t first = index.component(5 * map.width + 5);
|
||||
ASSERT_NE(first, 0u);
|
||||
EXPECT_EQ(index.component(6 * map.width + 6), first);
|
||||
EXPECT_NE(index.component(10 * map.width + 10), first);
|
||||
EXPECT_NE(index.component(5 * map.width + 6), first);
|
||||
}
|
||||
|
||||
TEST(FootprintZones, SideEntryUsesPathDistanceAndZeroDisablesTransition)
|
||||
{
|
||||
LatticeTestGrid map(600, 600);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int y = 0; y < map.height; ++y)
|
||||
for (int x = 250; x < map.width; ++x) map.direction[static_cast<std::size_t>(y) * map.width + x] = 1;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955; config.max_deviation_deg = 10.0;
|
||||
config.zone_transition_m = 1.0;
|
||||
Path path;
|
||||
constexpr double radius = 1.5;
|
||||
for (int i = 0; i <= 90; ++i)
|
||||
{
|
||||
const double t = (kPi / 2.0) * i / 90.0;
|
||||
path.push_back({1.0 + radius * (1.0 - std::cos(t)), 1.0 + radius * std::sin(t), kPi / 2.0 - t, -1.0 / radius});
|
||||
}
|
||||
for (int i = 1; i <= 50; ++i) path.push_back({2.5 + 2.0 * i / 50.0, 2.5, 0.0, 0.0});
|
||||
const PathCheck allowed = verifyPath(path, grid, 10.0, config);
|
||||
EXPECT_TRUE(allowed.valid) << allowed.zone_violations;
|
||||
RouteRequest request = latticeRequest(pose(path.front().x, path.front().y, path.front().yaw),
|
||||
pose(path.back().x, path.back().y, path.back().yaw));
|
||||
PlanInfo info;
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
detail::LatticeMemory memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext context{request, grid, config, 10.0, deadline, info, memory};
|
||||
detail::LatticeCSpace space(context);
|
||||
// The lattice keeps the strict per-pose rule (see LatticeCSpace::zonePoseFree): this transition pose is legal on the
|
||||
// whole path above but not as a lattice state, so lattice paths always satisfy the path rule.
|
||||
EXPECT_FALSE(space.poseFree(path[69].x, path[69].y, path[69].yaw));
|
||||
config.zone_transition_m = 0.0;
|
||||
const PathCheck blocked = verifyPath(path, grid, 10.0, config);
|
||||
EXPECT_FALSE(blocked.valid);
|
||||
EXPECT_GT(blocked.zone_violations, 0);
|
||||
}
|
||||
|
||||
TEST(FootprintZones, LongWrongWayOverlapWithoutCentreEntryIsRejected)
|
||||
{
|
||||
LatticeTestGrid map(600, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int y = 115; y < 130; ++y)
|
||||
for (int x = 150; x < 450; ++x) map.direction[static_cast<std::size_t>(y) * map.width + x] = 5;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
config.max_deviation_deg = 90.0; config.zone_transition_m = 1.0;
|
||||
const Path path{{0.8, 1.0, 0.0, 0.0}, {5.2, 1.0, 0.0, 0.0}};
|
||||
const PathCheck check = verifyPath(path, grid, 90.0, config);
|
||||
EXPECT_FALSE(check.valid);
|
||||
EXPECT_GT(check.zone_violations, 0);
|
||||
RouteRequest request = latticeRequest(pose(0.8, 1.0, 0.0), pose(5.2, 1.0, 0.0));
|
||||
PlanInfo info;
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
detail::LatticeMemory memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext context{request, grid, config, 90.0, deadline, info, memory};
|
||||
detail::LatticeCSpace space(context);
|
||||
EXPECT_FALSE(space.poseFree(2.5, 1.0, 0.0));
|
||||
}
|
||||
|
||||
TEST(FootprintZones, BodyUsesQueryLimitWhileCentreUsesRung)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
map.direction[static_cast<std::size_t>(120) * map.width + 240] = 1;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955; config.max_deviation_deg = 45.0;
|
||||
config.zone_transition_m = 0.0;
|
||||
RouteRequest request = latticeRequest(pose(1.0, 1.0, 0.0), pose(4.0, 1.0, 0.0));
|
||||
const auto deadline = detail::Clock::now() + std::chrono::seconds(10);
|
||||
PlanInfo allowed_info;
|
||||
detail::LatticeMemory allowed_memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext allowed{request, grid, config, 0.01, deadline, allowed_info, allowed_memory};
|
||||
detail::LatticeCSpace allowed_space(allowed);
|
||||
EXPECT_TRUE(allowed_space.poseFree(2.0, 1.0, kPi / 6.0));
|
||||
config.max_deviation_deg = 10.0;
|
||||
PlanInfo blocked_info;
|
||||
detail::LatticeMemory blocked_memory(16 * 1024 * 1024);
|
||||
detail::LatticeContext blocked{request, grid, config, 0.01, deadline, blocked_info, blocked_memory};
|
||||
detail::LatticeCSpace blocked_space(blocked);
|
||||
EXPECT_FALSE(blocked_space.poseFree(2.0, 1.0, kPi / 6.0));
|
||||
}
|
||||
|
||||
TEST(FootprintZones, FinishedPathUsesQueryLimitRatherThanRung)
|
||||
{
|
||||
LatticeTestGrid map(500, 220);
|
||||
GridRef grid = map.view(); grid.resolution = 0.01;
|
||||
for (int y = 115; y < 130; ++y)
|
||||
for (int x = 180; x < 310; ++x) map.direction[static_cast<std::size_t>(y) * map.width + x] = 2;
|
||||
PlannerConfig config = latticeConfig();
|
||||
config.half_x_m = 0.511; config.half_y_m = 0.1955;
|
||||
config.max_deviation_deg = 45.0; config.zone_transition_m = 0.0;
|
||||
const Path path{{1.0, 1.0, 0.0, 0.0}, {4.0, 1.0, 0.0, 0.0}};
|
||||
EXPECT_TRUE(verifyPath(path, grid, 0.01, config).valid);
|
||||
config.max_deviation_deg = 10.0;
|
||||
const PathCheck blocked = verifyPath(path, grid, 0.01, config);
|
||||
EXPECT_FALSE(blocked.valid);
|
||||
EXPECT_GT(blocked.zone_violations, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user