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:
2026-11-09 20:09:43 +07:00
parent 17ec2466b1
commit 88a2328ae8
5 changed files with 230 additions and 2 deletions

View File

@@ -28,6 +28,10 @@ struct SessionConfig
bool debug_fallback = true; ///< Enable per-request fallback diagnostics.
bool debug_plan = true; ///< Enable plan diagnostics.
bool debug_state = true; ///< Enable state-change diagnostics.
/// Directory for failed-query dumps that lane_route_eval can replay; empty disables them. Off by default, unlike the
/// log groups, because each dump writes a few MB to disk.
std::string debug_dump_dir;
int debug_dump_max_files = 20; ///< Dumps per session at most, so a repeating failure cannot fill the disk.
/** @return Empty when valid; otherwise the invalid key and its value, or the core validation error. */
std::string validate() const;
@@ -39,6 +43,19 @@ 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 Write a failed query in lane_route_eval's input format: <stem>.grid (static cost and direction codes),
* <stem>.live (master cost), <stem>.scene (one scene line) and <stem>.txt (reasons, effective settings, replay command).
* @param dir Output directory, created when missing.
* @param name File stem inside dir.
* @param live Master grid that the core planned on; its geometry is written.
* @param static_cost Static layer cost the graph was compiled from, width*height.
* @param directions Direction codes, width*height, or empty when the map has no zones.
* @return The stem path, or empty when a file could not be written. */
std::string writeFailureDump(const std::string& dir, const std::string& name, const lane_route_core::GridRef& live,
const std::vector<uint8_t>& static_cost, const std::vector<uint8_t>& directions,
const lane_route_core::RouteRequest& route, const lane_route_core::PlannerConfig& config,
const lane_route_core::PlanResult& result);
/** @brief Inputs for one planner-thread query. Shared snapshots and live bytes must outlive plan(). */
struct SessionRequest
{
@@ -126,6 +143,12 @@ public:
/** @brief Discard cached graphs and snapshot-derived data on the planner thread. */
void clearCache();
/** @brief Stem of the dump written by the last plan(), "!" + directory when writing failed, or empty. */
const std::string& lastDump() const
{
return last_dump_;
}
private:
SessionConfig config_;
std::vector<uint8_t> live_cost_;
@@ -145,6 +168,8 @@ private:
double half_x_ = -1; ///< [m] Cached footprint half length.
double half_y_ = -1; ///< [m] Cached footprint half width.
double inscribed_ = -1; ///< [m] Cached inscribed radius.
int dumps_attempted_ = 0; ///< Failed-query dumps tried by this session, including failed writes.
std::string last_dump_;
};
} // namespace lane_route_planner