feat(lane_route_planner): trim endpoint spin fans, load zone_deviation_weight (R2.12)
- New output_endpoint_spins (default false): the published plan starts at the first driving pose and ends with one goal pose. The local planner turns in place by itself; the planner still verifies both spins are collision free. - Load and clamp zone_deviation_weight; print both keys in the boot line. - Tests for the trim helper (29 pass).
This commit is contained in:
@@ -58,6 +58,12 @@ SessionConfig loadSessionConfig(const robot::NodeHandle& nh)
|
||||
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("zone_transition_m", p.zone_transition_m, d.zone_transition_m);
|
||||
load("zone_deviation_weight", p.zone_deviation_weight, d.zone_deviation_weight);
|
||||
if (!std::isfinite(p.zone_deviation_weight) || p.zone_deviation_weight < 0.0)
|
||||
{
|
||||
robot::log_warning("[lane_route_planner] zone_deviation_weight must be finite and >= 0; clamped to 0");
|
||||
p.zone_deviation_weight = 0.0;
|
||||
}
|
||||
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);
|
||||
@@ -111,6 +117,7 @@ SessionConfig loadSessionConfig(const robot::NodeHandle& nh)
|
||||
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("output_endpoint_spins", config.output_endpoint_spins, defaults.output_endpoint_spins);
|
||||
load("debug/fallback", config.debug_fallback, defaults.debug_fallback);
|
||||
load("debug/dump_dir", config.debug_dump_dir, defaults.debug_dump_dir);
|
||||
load("debug/dump_max_files", config.debug_dump_max_files, defaults.debug_dump_max_files);
|
||||
@@ -170,9 +177,10 @@ bool LaneRoutePlanner::initialize(std::string name, robot_costmap_2d::Costmap2DR
|
||||
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 zone_transition_m=%.3f debug_plan=%d debug_state=%d",
|
||||
robot::log_info("[lane_route_planner] %s: time_limit=%.2fs min_radius=%.3fm clearance_margin=%.3fm gap=%.3fm zone_transition_m=%.3f zone_deviation_weight=%.3f output_endpoint_spins=%d 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, p.zone_transition_m, config_.debug_plan, config_.debug_state);
|
||||
p.footprint_min_gap_m, p.zone_transition_m, p.zone_deviation_weight, config_.output_endpoint_spins,
|
||||
config_.debug_plan, config_.debug_state);
|
||||
robot::log_info("[lane_route_planner] fallback: lattice_enabled=%d fallback_time_limit_s=%.2f lattice_preferred_gap_m=%.3f lattice_preferred_time_fraction=%.2f lattice_smooth_enabled=%d lattice_smooth_max_checks=%lld lattice_heuristic_weight=%.2f lattice_heading_bins=%d lattice_max_memory_mb=%lld lattice_field_standability_relax_m=%.3f lattice_field_zone_margin_deg=%.1f lattice_alt_field_enabled=%d lattice_alt_field_relax_m=%.3f lattice_alt_field_switch_fraction=%.2f debug/fallback=%d",
|
||||
p.lattice_enabled, p.fallback_time_limit_s, p.lattice_preferred_gap_m, p.lattice_preferred_time_fraction,
|
||||
p.lattice_smooth_enabled, static_cast<long long>(p.lattice_smooth_max_checks), p.lattice_heuristic_weight, p.lattice_heading_bins,
|
||||
@@ -346,8 +354,11 @@ bool LaneRoutePlanner::makePlan(const robot_geometry_msgs::PoseStamped& start, c
|
||||
}
|
||||
}
|
||||
const auto stamp = robot::Time::now();
|
||||
plan.reserve(result.path.size());
|
||||
for (const auto& point : result.path)
|
||||
// The controller turns in place at the start and to the goal yaw by itself; it takes the goal yaw from the last
|
||||
// plan pose, which is set to the requested goal below.
|
||||
const lane_route_core::Path published = config_.output_endpoint_spins ? result.path : trimEndpointSpins(result.path);
|
||||
plan.reserve(published.size());
|
||||
for (const auto& point : published)
|
||||
{
|
||||
robot_geometry_msgs::PoseStamped pose;
|
||||
pose.header.frame_id = request.frame;
|
||||
|
||||
@@ -67,6 +67,27 @@ std::string SessionConfig::validate() const
|
||||
return planner.validate();
|
||||
}
|
||||
|
||||
lane_route_core::Path trimEndpointSpins(const lane_route_core::Path& path)
|
||||
{
|
||||
// The core writes an endpoint rotation as poses at one exact position, so a tight tolerance is enough.
|
||||
constexpr double kSamePositionM = 1e-6;
|
||||
const auto same = [&path](std::size_t a, std::size_t b) {
|
||||
return std::hypot(path[a].x - path[b].x, path[a].y - path[b].y) <= kSamePositionM;
|
||||
};
|
||||
if (path.size() < 3)
|
||||
return path;
|
||||
std::size_t first = 0;
|
||||
while (first + 1 < path.size() && same(first, first + 1))
|
||||
++first;
|
||||
std::size_t last = path.size() - 1;
|
||||
while (last > first && same(last - 1, last))
|
||||
--last;
|
||||
if (first >= last)
|
||||
return path;
|
||||
return lane_route_core::Path(path.begin() + static_cast<std::ptrdiff_t>(first),
|
||||
path.begin() + static_cast<std::ptrdiff_t>(last) + 1);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// Run-length text in the format lane_route_eval reads: "<key> <run count>" then "<value> <count>" pairs.
|
||||
|
||||
Reference in New Issue
Block a user