feat(lane_route): radius ladder and failure dumps (R2.6)
Radius ladder: the first graph pass, the lattice and the smoother use only radii at or above regular_turn_radius_m (1.06 m), as before. When min_turn_radius_m is lower, the graph runs a second pass with all corner_radii_m if the first fails or returns a long detour, and keeps it only when at least 20% shorter. Optional lattice tight arcs exist behind lattice_tight_arcs (off: they cost many queries to timeouts). C++ defaults keep the old 1.06 m floor; regress7 output is identical. With a 0.4 m floor: graph-only coverage +5 (hook_150) and +8 (kit), none lost; with fallback, coverage unchanged and 27/29 queries move from lattice to graph; tight corners used 0.9 m. Failure dumps: with debug/dump_dir set, the plugin writes each failed query as lane_route_eval input (static cost, master cost, direction codes, poses, settings), at most debug/dump_max_files per session.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
@@ -740,4 +741,80 @@ TEST(AdapterParity, Inflation)
|
||||
{
|
||||
runParity(true);
|
||||
}
|
||||
TEST(AdapterDump, FailureDumpIsReadableRunLengthText)
|
||||
{
|
||||
// 4 x 3 grid: one lethal cell, one zone cell. The replay tool reads "<key> <runs>" and then value/count pairs.
|
||||
std::vector<uint8_t> master{ 60, 60, 254, 60, 60, 60, 60, 60, 253, 60, 60, 60 };
|
||||
const std::vector<uint8_t> static_cost{ 0, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
std::vector<uint8_t> directions(12, 0);
|
||||
directions[5] = 3;
|
||||
GridRef live;
|
||||
live.width = 4;
|
||||
live.height = 3;
|
||||
live.resolution = 0.05;
|
||||
live.origin_x = -1.5;
|
||||
live.origin_y = 2.25;
|
||||
live.cost = master.data();
|
||||
RouteRequest route;
|
||||
route.start = { 0.1, 0.2, 0.3, true };
|
||||
route.goal = { 0.4, 0.5, 0.0, false };
|
||||
PlannerConfig config;
|
||||
config.max_deviation_deg = 22.5;
|
||||
PlanResult result;
|
||||
result.info.reason = "lattice_timeout";
|
||||
const std::string dir = (std::filesystem::temp_directory_path() / "lane_route_dump_test").string();
|
||||
const std::string stem = writeFailureDump(dir, "case", live, static_cost, directions, route, config, result);
|
||||
ASSERT_EQ(stem, dir + "/case");
|
||||
|
||||
std::ifstream grid(stem + ".grid");
|
||||
std::string key;
|
||||
int version = 0, width = 0, height = 0, runs = 0, variants = 0;
|
||||
double resolution = 0.0, ox = 0.0, oy = 0.0;
|
||||
grid >> key >> version >> key >> width >> height >> key >> resolution >> key >> ox >> oy >> key >> runs;
|
||||
EXPECT_EQ(width, 4);
|
||||
EXPECT_EQ(height, 3);
|
||||
EXPECT_DOUBLE_EQ(resolution, 0.05);
|
||||
EXPECT_DOUBLE_EQ(ox, -1.5);
|
||||
EXPECT_DOUBLE_EQ(oy, 2.25);
|
||||
EXPECT_EQ(key, "cost");
|
||||
EXPECT_EQ(runs, 3); // 0 x2, 254 x1, 0 x9
|
||||
int value = 0, count = 0, total = 0;
|
||||
for (int i = 0; i < runs; ++i)
|
||||
{
|
||||
grid >> value >> count;
|
||||
total += count;
|
||||
}
|
||||
EXPECT_EQ(total, 12);
|
||||
grid >> key >> variants >> key >> runs;
|
||||
EXPECT_EQ(variants, 1);
|
||||
EXPECT_EQ(key, "direction");
|
||||
EXPECT_EQ(runs, 3);
|
||||
|
||||
std::ifstream scene(stem + ".scene");
|
||||
std::string id, grid_file, live_file;
|
||||
int variant = -1, has_start = -1, has_goal = -1, boxes = -1;
|
||||
double sx, sy, syaw, gx, gy, gyaw;
|
||||
scene >> id >> grid_file >> variant >> live_file >> has_start >> sx >> sy >> syaw >> has_goal >> gx >> gy >> gyaw >> boxes;
|
||||
EXPECT_EQ(id, "case");
|
||||
EXPECT_EQ(grid_file, stem + ".grid");
|
||||
EXPECT_EQ(live_file, stem + ".live");
|
||||
EXPECT_EQ(has_start, 1);
|
||||
EXPECT_DOUBLE_EQ(syaw, 0.3);
|
||||
EXPECT_EQ(has_goal, 0);
|
||||
EXPECT_EQ(boxes, 0);
|
||||
|
||||
std::ifstream master_file(stem + ".live");
|
||||
master_file >> key >> runs;
|
||||
EXPECT_EQ(key, "cost");
|
||||
EXPECT_EQ(runs, 5); // 60 x2, 254, 60 x5, 253, 60 x3
|
||||
std::ifstream meta(stem + ".txt");
|
||||
std::stringstream text;
|
||||
text << meta.rdbuf();
|
||||
EXPECT_NE(text.str().find("reason lattice_timeout"), std::string::npos);
|
||||
EXPECT_NE(text.str().find("max_deviation_deg 22.5"), std::string::npos);
|
||||
|
||||
// A grid whose static layer does not match the master size is refused instead of writing a misleading replay.
|
||||
EXPECT_TRUE(writeFailureDump(dir, "bad", live, std::vector<uint8_t>(5, 0), directions, route, config, result).empty());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user