feat(lane_route): smooth lattice paths (R2) and expose the lattice tier in the plugin (R3)
- lane_route_core: port of the S3 smoother for lattice paths (direct, greedy and bounded graph improvement over witness anchors, then clothoid corners when budget remains), shape metrics and smoother diagnostics in PlanInfo and lane_route_eval. - lane_route_planner: loads the lattice keys from YAML, logs a config summary at start-up and one debug/fallback line per lattice request. regress7: coverage unchanged from R1, every lattice path smoothed, 0 bad in the independent recheck. Local snapshot for history only; not pushed.
This commit is contained in:
@@ -76,9 +76,15 @@ option(BUILD_LANE_ROUTE_PLANNER_TESTS "Build adapter tests" ${BUILDING_WITH_CATK
|
||||
if(BUILD_LANE_ROUTE_PLANNER_TESTS)
|
||||
find_package(GTest REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(yaml-cpp REQUIRED)
|
||||
if(TARGET yaml-cpp::yaml-cpp)
|
||||
set(LANE_ROUTE_YAML_TARGET yaml-cpp::yaml-cpp)
|
||||
else()
|
||||
set(LANE_ROUTE_YAML_TARGET yaml-cpp)
|
||||
endif()
|
||||
add_executable(lane_route_planner_test test/lane_route_planner_test.cpp)
|
||||
target_link_libraries(lane_route_planner_test PRIVATE
|
||||
lane_route_planner GTest::GTest GTest::Main Threads::Threads
|
||||
lane_route_planner GTest::GTest GTest::Main Threads::Threads ${LANE_ROUTE_YAML_TARGET}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
28
README.md
28
README.md
@@ -10,6 +10,30 @@ The cached compiled graphs are dropped when the reference generation, footprint,
|
||||
or the exact preferred-cell mask changes. Other master costs are read again at query time. The core
|
||||
uses the worker's ridge parameters for a live rebuild. `time_limit_s` defaults to 20 seconds.
|
||||
|
||||
## Lattice fallback
|
||||
|
||||
The optional weighted A* SE(2) lattice runs after an eligible graph-tier failure. It retains the
|
||||
core's forward-only, curvature, end-spin, footprint-gap and direction-zone checks. It is off by
|
||||
default; set `lattice_enabled: true` to enable it. The sim/dev runtime YAML enables it for testing.
|
||||
The fallback shares `time_limit_s` and has its own `fallback_time_limit_s` budget across rungs and
|
||||
smoothing; a graph result or an early failure can prevent it from running.
|
||||
|
||||
Keys (defaults from `PlannerConfig`):
|
||||
|
||||
- `lattice_enabled: false`, `lattice_heading_bins: 72`, `lattice_closed_resolution_m: 0.10`,
|
||||
`lattice_heuristic_weight: 3.0`, `lattice_bucket_width_m: 0.25`.
|
||||
- `lattice_field_clearance_weight_m: 0.25`, `lattice_wall_weight_m: 0.25`,
|
||||
`lattice_switch_cost_m: 0.35`, `lattice_steer_cost_m: 0.012`.
|
||||
- `lattice_primitive_multiple_1: 1`, `lattice_primitive_multiple_2: 3`,
|
||||
`lattice_primitive_multiple_3: 6`.
|
||||
- `lattice_analytic_radius_m: 1.08`, `lattice_analytic_interval: 20000`,
|
||||
`lattice_analytic_near_goal_m: 2.0`, `lattice_analytic_goal_headings: 16`.
|
||||
- `lattice_field_time_fraction: 0.4`, `lattice_field_cell_factor: 0`,
|
||||
`lattice_field_max_cells: 1000000`, `fallback_time_limit_s: 3.0`,
|
||||
`lattice_end_relax_radius_m: 1.0`, `lattice_max_memory_mb: 512` (MiB).
|
||||
- `debug/fallback: true` enables one diagnostic line per request when lattice ran; failure logs
|
||||
remain enabled. See the runtime YAML for units, tuning effects and valid ranges.
|
||||
|
||||
Cancellation is checked during graph compilation and core planning. Preferred-region centre-line
|
||||
extraction does not itself accept cancellation: a request arriving during that call waits until it
|
||||
returns. It runs only on compilation when the master has preferred cells; its worst-case time is
|
||||
@@ -19,6 +43,6 @@ Master cost 100 is interpreted as UNPREFERRED. Inflation can produce exactly 100
|
||||
parameter sets, causing a small penalty and potentially an extra neutral pass on failure. The
|
||||
current inflation parameters have not produced that value; no normalization is applied.
|
||||
|
||||
The session tests exercise snapshots and grids without a real Costmap2DROBOT. Plugin loading,
|
||||
NodeHandle parameter discovery, external-grid lifetime, snapshot synchronization, output headers,
|
||||
The tests exercise snapshots, grids and NodeHandle configuration without a real Costmap2DROBOT. Plugin loading,
|
||||
runtime parameter discovery, external-grid lifetime, snapshot synchronization, output headers,
|
||||
and integration with the navigation host still require runtime validation.
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <lane_route_core/route_planner.h>
|
||||
|
||||
namespace robot { class NodeHandle; }
|
||||
|
||||
namespace lane_route_planner
|
||||
{
|
||||
/** @brief Tunable parameters; footprint and direction limit are supplied per request by the costmap. */
|
||||
@@ -23,6 +25,7 @@ struct SessionConfig
|
||||
double clearance_min_margin_m = 0.035; ///< [m] Added to inscribed radius for hard clearance.
|
||||
double clearance_preferred_margin_m = 0.30; ///< [m] Added to inscribed radius for preferred clearance.
|
||||
double collision_check_margin_m = 0.056; ///< [m] Added to the bounding rectangle's circumscribed radius.
|
||||
bool debug_fallback = true; ///< Enable per-request fallback diagnostics.
|
||||
bool debug_plan = true; ///< Enable plan diagnostics.
|
||||
bool debug_state = true; ///< Enable state-change diagnostics.
|
||||
|
||||
@@ -30,6 +33,12 @@ struct SessionConfig
|
||||
std::string validate() const;
|
||||
};
|
||||
|
||||
/** @brief Read the plugin namespace with PlannerConfig defaults; malformed types throw. */
|
||||
SessionConfig loadSessionConfig(const robot::NodeHandle& nh);
|
||||
|
||||
/** @brief Log fallback diagnostics when enabled and always report a failed result. */
|
||||
void logPlanResult(const lane_route_core::PlanResult& result, bool debug_fallback);
|
||||
|
||||
/** @brief Inputs for one planner-thread query. Shared snapshots and live bytes must outlive plan(). */
|
||||
struct SessionRequest
|
||||
{
|
||||
|
||||
@@ -31,67 +31,128 @@ void setExternalGridOn(robot_nav_core::BaseGlobalPlanner* planner, const robot_c
|
||||
robot::log_error("[lane_route_planner] ExternalGrid: wrong planner instance");
|
||||
}
|
||||
|
||||
SessionConfig loadSessionConfig(const robot::NodeHandle& nh)
|
||||
{
|
||||
SessionConfig config;
|
||||
const auto load = [&nh](const char* key, auto& value, const auto& fallback)
|
||||
{
|
||||
if (nh.hasParam(key))
|
||||
{
|
||||
if (!nh.getParam(key, value, fallback))
|
||||
throw std::invalid_argument(std::string("invalid parameter: ") + key);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = fallback;
|
||||
}
|
||||
};
|
||||
SessionConfig defaults;
|
||||
auto& p = config.planner;
|
||||
const auto& d = defaults.planner;
|
||||
load("min_turn_radius_m", p.min_turn_radius_m, d.min_turn_radius_m);
|
||||
load("corner_radii_m", p.corner_radii_m, d.corner_radii_m);
|
||||
load("clearance_min_margin_m", config.clearance_min_margin_m, defaults.clearance_min_margin_m);
|
||||
load("clearance_preferred_margin_m", config.clearance_preferred_margin_m, defaults.clearance_preferred_margin_m);
|
||||
load("collision_check_margin_m", config.collision_check_margin_m, defaults.collision_check_margin_m);
|
||||
load("footprint_min_gap_m", p.footprint_min_gap_m, d.footprint_min_gap_m);
|
||||
load("footprint_gap_shortcut_raise_m", p.footprint_gap_shortcut_raise_m, d.footprint_gap_shortcut_raise_m);
|
||||
load("deviation_ladder_deg", p.deviation_ladder_deg, d.deviation_ladder_deg);
|
||||
load("route_too_long_ratio", p.route_too_long_ratio, d.route_too_long_ratio);
|
||||
load("route_too_long_margin_m", p.route_too_long_margin_m, d.route_too_long_margin_m);
|
||||
load("suspicious_ratio", p.suspicious_ratio, d.suspicious_ratio);
|
||||
load("suspicious_margin_m", p.suspicious_margin_m, d.suspicious_margin_m);
|
||||
load("max_route_attempts", p.max_route_attempts, d.max_route_attempts);
|
||||
load("time_limit_s", p.time_limit_s, d.time_limit_s);
|
||||
load("output_step_m", p.output_step_m, d.output_step_m);
|
||||
load("live_ridge_pad_m", p.live_ridge_pad_m, d.live_ridge_pad_m);
|
||||
int max_cells = static_cast<int>(d.live_ridge_max_cells);
|
||||
load("live_ridge_max_cells", max_cells, max_cells);
|
||||
p.live_ridge_max_cells = max_cells;
|
||||
load("lattice_enabled", p.lattice_enabled, d.lattice_enabled);
|
||||
load("lattice_heading_bins", p.lattice_heading_bins, d.lattice_heading_bins);
|
||||
load("lattice_closed_resolution_m", p.lattice_closed_resolution_m, d.lattice_closed_resolution_m);
|
||||
load("lattice_heuristic_weight", p.lattice_heuristic_weight, d.lattice_heuristic_weight);
|
||||
load("lattice_bucket_width_m", p.lattice_bucket_width_m, d.lattice_bucket_width_m);
|
||||
load("lattice_field_clearance_weight_m", p.lattice_field_clearance_weight_m, d.lattice_field_clearance_weight_m);
|
||||
load("lattice_wall_weight_m", p.lattice_wall_weight_m, d.lattice_wall_weight_m);
|
||||
load("lattice_switch_cost_m", p.lattice_switch_cost_m, d.lattice_switch_cost_m);
|
||||
load("lattice_steer_cost_m", p.lattice_steer_cost_m, d.lattice_steer_cost_m);
|
||||
load("lattice_primitive_multiple_1", p.lattice_primitive_multiple_1, d.lattice_primitive_multiple_1);
|
||||
load("lattice_primitive_multiple_2", p.lattice_primitive_multiple_2, d.lattice_primitive_multiple_2);
|
||||
load("lattice_primitive_multiple_3", p.lattice_primitive_multiple_3, d.lattice_primitive_multiple_3);
|
||||
load("lattice_analytic_radius_m", p.lattice_analytic_radius_m, d.lattice_analytic_radius_m);
|
||||
load("lattice_analytic_interval", p.lattice_analytic_interval, d.lattice_analytic_interval);
|
||||
load("lattice_analytic_near_goal_m", p.lattice_analytic_near_goal_m, d.lattice_analytic_near_goal_m);
|
||||
load("lattice_analytic_goal_headings", p.lattice_analytic_goal_headings, d.lattice_analytic_goal_headings);
|
||||
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<int>(d.lattice_field_max_cells);
|
||||
load("lattice_field_max_cells", field_max_cells, field_max_cells);
|
||||
p.lattice_field_max_cells = field_max_cells;
|
||||
load("fallback_time_limit_s", p.fallback_time_limit_s, d.fallback_time_limit_s);
|
||||
load("lattice_end_relax_radius_m", p.lattice_end_relax_radius_m, d.lattice_end_relax_radius_m);
|
||||
int max_memory_mb = static_cast<int>(d.lattice_max_memory_mb);
|
||||
load("lattice_max_memory_mb", max_memory_mb, max_memory_mb);
|
||||
p.lattice_max_memory_mb = max_memory_mb;
|
||||
load("debug/fallback", config.debug_fallback, defaults.debug_fallback);
|
||||
load("debug_plan", config.debug_plan, defaults.debug_plan);
|
||||
load("debug_state", config.debug_state, defaults.debug_state);
|
||||
return config;
|
||||
}
|
||||
|
||||
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 expanded=%llu field=%.1fms search=%.1fms verify=%.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(),
|
||||
static_cast<unsigned long long>(result.info.lattice_states_expanded), result.info.lattice_field_ms,
|
||||
result.info.lattice_search_ms, result.info.lattice_verify_ms,
|
||||
static_cast<double>(result.info.lattice_peak_bytes) / (1024.0 * 1024.0));
|
||||
if (!result.ok || result.path.empty() || !result.check.valid)
|
||||
{
|
||||
const char* reason = result.ok ? "invalid_or_empty_verified_path" : result.info.reason.c_str();
|
||||
robot::log_warning("[lane_route_planner] plan failed: %s", reason);
|
||||
}
|
||||
}
|
||||
|
||||
bool LaneRoutePlanner::initialize(std::string name, robot_costmap_2d::Costmap2DROBOT* costmap)
|
||||
{
|
||||
if (initialized_)
|
||||
return true;
|
||||
if (!costmap || !costmap->getLayeredCostmap() || !costmap->getCostmap())
|
||||
{
|
||||
robot::log_error("[lane_route_planner] initialize: missing costmap");
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
robot::NodeHandle root;
|
||||
robot::NodeHandle nh(root, name);
|
||||
const auto load = [&nh](const char* key, auto& value, const auto& fallback)
|
||||
config_ = loadSessionConfig(nh);
|
||||
std::string error = config_.validate();
|
||||
// Core validates lattice limits only when enabled; reject invalid dormant settings too.
|
||||
if (error.empty() && !config_.planner.lattice_enabled)
|
||||
{
|
||||
if (nh.hasParam(key))
|
||||
{
|
||||
if (!nh.getParam(key, value, fallback))
|
||||
throw std::invalid_argument(std::string("invalid parameter: ") + key);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = fallback;
|
||||
}
|
||||
};
|
||||
SessionConfig defaults;
|
||||
auto& p = config_.planner;
|
||||
const auto& d = defaults.planner;
|
||||
load("min_turn_radius_m", p.min_turn_radius_m, d.min_turn_radius_m);
|
||||
load("corner_radii_m", p.corner_radii_m, d.corner_radii_m);
|
||||
load("clearance_min_margin_m", config_.clearance_min_margin_m, defaults.clearance_min_margin_m);
|
||||
load("clearance_preferred_margin_m", config_.clearance_preferred_margin_m, defaults.clearance_preferred_margin_m);
|
||||
load("collision_check_margin_m", config_.collision_check_margin_m, defaults.collision_check_margin_m);
|
||||
load("footprint_min_gap_m", p.footprint_min_gap_m, d.footprint_min_gap_m);
|
||||
load("footprint_gap_shortcut_raise_m", p.footprint_gap_shortcut_raise_m, d.footprint_gap_shortcut_raise_m);
|
||||
load("deviation_ladder_deg", p.deviation_ladder_deg, d.deviation_ladder_deg);
|
||||
load("route_too_long_ratio", p.route_too_long_ratio, d.route_too_long_ratio);
|
||||
load("route_too_long_margin_m", p.route_too_long_margin_m, d.route_too_long_margin_m);
|
||||
load("suspicious_ratio", p.suspicious_ratio, d.suspicious_ratio);
|
||||
load("suspicious_margin_m", p.suspicious_margin_m, d.suspicious_margin_m);
|
||||
load("max_route_attempts", p.max_route_attempts, d.max_route_attempts);
|
||||
load("time_limit_s", p.time_limit_s, d.time_limit_s);
|
||||
load("output_step_m", p.output_step_m, d.output_step_m);
|
||||
load("live_ridge_pad_m", p.live_ridge_pad_m, d.live_ridge_pad_m);
|
||||
int max_cells = static_cast<int>(d.live_ridge_max_cells);
|
||||
load("live_ridge_max_cells", max_cells, max_cells);
|
||||
p.live_ridge_max_cells = max_cells;
|
||||
load("debug_plan", config_.debug_plan, defaults.debug_plan);
|
||||
load("debug_state", config_.debug_state, defaults.debug_state);
|
||||
const std::string error = config_.validate();
|
||||
auto lattice_config = config_.planner;
|
||||
lattice_config.lattice_enabled = true;
|
||||
error = lattice_config.validate();
|
||||
}
|
||||
if (!error.empty())
|
||||
{
|
||||
robot::log_error("[lane_route_planner] invalid configuration: %s", error.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!costmap || !costmap->getLayeredCostmap() || !costmap->getCostmap())
|
||||
{
|
||||
robot::log_error("[lane_route_planner] initialize: missing costmap");
|
||||
return false;
|
||||
}
|
||||
const auto& p = config_.planner;
|
||||
costmap_ = costmap;
|
||||
session_.setConfig(config_);
|
||||
initialized_ = true;
|
||||
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_heuristic_weight=%.2f lattice_heading_bins=%d lattice_max_memory_mb=%lld debug/fallback=%d",
|
||||
p.lattice_enabled, p.fallback_time_limit_s, p.lattice_heuristic_weight, p.lattice_heading_bins,
|
||||
static_cast<long long>(p.lattice_max_memory_mb), config_.debug_fallback);
|
||||
if (costmap_->getLayeredCostmap()->getReferenceGraphSnapshot().state == robot_costmap_2d::ReferenceGraphState::kDisabled)
|
||||
robot::log_error("[lane_route_planner] reference graph is disabled; plans will fail until enabled");
|
||||
return true;
|
||||
@@ -222,12 +283,9 @@ bool LaneRoutePlanner::makePlan(const robot_geometry_msgs::PoseStamped& start, c
|
||||
result.info.query_ms, result.info.compile_ms, result.info.search_ms, result.info.build_ms, result.info.verify_ms,
|
||||
result.info.live_ridge_ms, result.info.min_gap_m, result.info.gap_shortcut_raise_m, result.info.gap_exemption_used,
|
||||
result.info.swing_windows, result.info.swing_line_checks, result.info.swing_builds, result.info.swing_selected);
|
||||
logPlanResult(result, config_.debug_fallback);
|
||||
if (!result.ok || result.path.empty() || !result.check.valid)
|
||||
{
|
||||
const char* reason = result.ok ? "invalid_or_empty_verified_path" : result.info.reason.c_str();
|
||||
robot::log_warning("[lane_route_planner] plan failed: %s", reason);
|
||||
return false;
|
||||
}
|
||||
const auto final_graph = layered->getReferenceGraphSnapshot();
|
||||
const auto final_direction = layered->getDirectionFieldSnapshot();
|
||||
if (preempt_.load(std::memory_order_relaxed) || final_graph.state != request.graph.state ||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <lane_route_planner/lane_route_session.h>
|
||||
#include <lane_route_planner/lane_route_planner.h>
|
||||
|
||||
#include <robot/node_handle.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
@@ -226,6 +228,130 @@ TEST(AdapterConfig, RejectsInvalidParameters)
|
||||
EXPECT_FALSE(c.validate().empty());
|
||||
}
|
||||
|
||||
TEST(AdapterConfig, LatticeYamlReachesPlannerConfig)
|
||||
{
|
||||
robot::NodeHandle root;
|
||||
root.setParam("LaneRouteLatticeConfigTest", YAML::Load(R"(
|
||||
lattice_enabled: true
|
||||
lattice_heading_bins: 64
|
||||
lattice_closed_resolution_m: 0.2
|
||||
lattice_heuristic_weight: 2.0
|
||||
lattice_bucket_width_m: 0.3
|
||||
lattice_field_clearance_weight_m: 0.4
|
||||
lattice_wall_weight_m: 0.5
|
||||
lattice_switch_cost_m: 0.6
|
||||
lattice_steer_cost_m: 0.02
|
||||
lattice_primitive_multiple_1: 1
|
||||
lattice_primitive_multiple_2: 2
|
||||
lattice_primitive_multiple_3: 4
|
||||
lattice_analytic_radius_m: 1.2
|
||||
lattice_analytic_interval: 123
|
||||
lattice_analytic_near_goal_m: 1.5
|
||||
lattice_analytic_goal_headings: 8
|
||||
lattice_field_time_fraction: 0.3
|
||||
lattice_field_cell_factor: 2
|
||||
lattice_field_max_cells: 123456
|
||||
fallback_time_limit_s: 2.0
|
||||
lattice_end_relax_radius_m: 0.8
|
||||
lattice_max_memory_mb: 256
|
||||
debug: {fallback: false}
|
||||
)"));
|
||||
robot::NodeHandle nh(root, "LaneRouteLatticeConfigTest");
|
||||
const SessionConfig config = loadSessionConfig(nh);
|
||||
const auto& p = config.planner;
|
||||
EXPECT_TRUE(config.validate().empty());
|
||||
EXPECT_TRUE(p.lattice_enabled);
|
||||
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);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_bucket_width_m, 0.3);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_field_clearance_weight_m, 0.4);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_wall_weight_m, 0.5);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_switch_cost_m, 0.6);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_steer_cost_m, 0.02);
|
||||
EXPECT_EQ(p.lattice_primitive_multiple_1, 1);
|
||||
EXPECT_EQ(p.lattice_primitive_multiple_2, 2);
|
||||
EXPECT_EQ(p.lattice_primitive_multiple_3, 4);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_analytic_radius_m, 1.2);
|
||||
EXPECT_EQ(p.lattice_analytic_interval, 123);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_analytic_near_goal_m, 1.5);
|
||||
EXPECT_EQ(p.lattice_analytic_goal_headings, 8);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_field_time_fraction, 0.3);
|
||||
EXPECT_EQ(p.lattice_field_cell_factor, 2);
|
||||
EXPECT_EQ(p.lattice_field_max_cells, 123456);
|
||||
EXPECT_DOUBLE_EQ(p.fallback_time_limit_s, 2.0);
|
||||
EXPECT_DOUBLE_EQ(p.lattice_end_relax_radius_m, 0.8);
|
||||
EXPECT_EQ(p.lattice_max_memory_mb, 256);
|
||||
EXPECT_FALSE(config.debug_fallback);
|
||||
|
||||
root.setParam("LaneRouteLatticeDefaultsTest", YAML::Load("{other: 1}"));
|
||||
const auto defaults = loadSessionConfig(robot::NodeHandle(root, "LaneRouteLatticeDefaultsTest"));
|
||||
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.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);
|
||||
EXPECT_TRUE(defaults.debug_fallback);
|
||||
|
||||
// A non-default first primitive is invalid, but must still reach core validation.
|
||||
root.setParam("LaneRouteBadPrimitiveTest", YAML::Load("{lattice_enabled: true, lattice_primitive_multiple_1: 2}"));
|
||||
const auto invalid = loadSessionConfig(robot::NodeHandle(root, "LaneRouteBadPrimitiveTest"));
|
||||
EXPECT_EQ(invalid.planner.lattice_primitive_multiple_1, 2);
|
||||
EXPECT_NE(invalid.validate().find("lattice primitive multiples"), std::string::npos);
|
||||
}
|
||||
|
||||
TEST(AdapterConfig, InvalidLatticeRejectsPluginInitialization)
|
||||
{
|
||||
robot::NodeHandle root;
|
||||
root.setParam("LaneRouteInvalidLatticeTest", YAML::Load("{lattice_enabled: true, lattice_heading_bins: 7}"));
|
||||
LaneRoutePlanner planner;
|
||||
testing::internal::CaptureStdout();
|
||||
const bool initialized = planner.initialize("LaneRouteInvalidLatticeTest", nullptr);
|
||||
const std::string log = testing::internal::GetCapturedStdout();
|
||||
EXPECT_FALSE(initialized);
|
||||
EXPECT_NE(log.find("invalid configuration: lattice_heading_bins must be even and in [8, 1024]"), std::string::npos);
|
||||
|
||||
root.setParam("LaneRouteDisabledInvalidLatticeTest", YAML::Load("{lattice_enabled: false, lattice_heading_bins: 7}"));
|
||||
LaneRoutePlanner disabled;
|
||||
testing::internal::CaptureStdout();
|
||||
const bool disabled_initialized = disabled.initialize("LaneRouteDisabledInvalidLatticeTest", nullptr);
|
||||
const std::string disabled_log = testing::internal::GetCapturedStdout();
|
||||
EXPECT_FALSE(disabled_initialized);
|
||||
EXPECT_NE(disabled_log.find("invalid configuration: lattice_heading_bins must be even and in [8, 1024]"),
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
TEST(AdapterLog, FallbackSwitchDoesNotSuppressFailure)
|
||||
{
|
||||
robot::NodeHandle root;
|
||||
root.setParam("LaneRouteFallbackLogTest", YAML::Load("{debug: {fallback: false}}"));
|
||||
const auto config = loadSessionConfig(robot::NodeHandle(root, "LaneRouteFallbackLogTest"));
|
||||
PlanResult result;
|
||||
result.info.reason = "lattice_exhausted";
|
||||
result.info.graph_reason = "no_route";
|
||||
result.info.lattice_reason = "lattice_exhausted";
|
||||
result.info.lattice_ms = 1.0;
|
||||
result.info.lattice_rung_reasons.push_back(result.info.lattice_reason);
|
||||
testing::internal::CaptureStdout();
|
||||
logPlanResult(result, config.debug_fallback);
|
||||
const std::string quiet = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(quiet.find("[debug] fallback tier="), std::string::npos);
|
||||
EXPECT_NE(quiet.find("plan failed: lattice_exhausted"), std::string::npos);
|
||||
testing::internal::CaptureStdout();
|
||||
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("plan failed: lattice_exhausted"), std::string::npos);
|
||||
|
||||
result.info.lattice_ms = 0.0;
|
||||
testing::internal::CaptureStdout();
|
||||
logPlanResult(result, true);
|
||||
const std::string no_lattice = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(no_lattice.find("[debug] fallback tier="), std::string::npos);
|
||||
EXPECT_NE(no_lattice.find("plan failed: lattice_exhausted"), std::string::npos);
|
||||
}
|
||||
|
||||
TEST(AdapterConfig, FootprintBoundsAndCollisionDistances)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
Reference in New Issue
Block a user