feat: cap the single_cusp cusp-to-goal straight (maximum_cusp_distance, per-marker override)
maneuver/maximum_cusp_distance [m] bounds the reverse/forward straight from the cusp to the goal; 0 keeps the old unlimited behaviour. dock_maximum_cusp_distance overrides it per docking marker for every dock_anchor. A cusp beyond the cap rejects single_cusp so the planner tries the remaining shapes.
This commit is contained in:
10
README.md
10
README.md
@@ -171,6 +171,7 @@ File mặc định đi kèm gói: `config/dock_global_params.yaml`. Cây đang c
|
||||
| `kinematics/minimum_turning_radius` | `0.0` | m | differential | 0 = xoay tại chỗ được |
|
||||
| `maneuver/minimum_forward_distance` | `0.25` | m | cả hai | Đoạn dẫn tối thiểu trước cusp |
|
||||
| `maneuver/maximum_forward_extension` | `3.0` | m | cả hai | Trần `cusp_extension`; vượt thì LOẠI kiểu 3 |
|
||||
| `maneuver/maximum_cusp_distance` | `0.0` | m | cả hai | Trần đoạn thẳng cusp → goal của `single_cusp`; 0 = không giới hạn |
|
||||
| `maneuver/direct_entry_min_curve_room` | `0.0` | m | cả hai | 0 = tắt kiểu 1 |
|
||||
| `maneuver/pivot_fallback_extension` | `0.0` | m | cả hai | 0 = tắt kiểu 2 (bỏ qua khi `turns_in_place`) |
|
||||
| `maneuver/pivot_safety_margin` | `0.15` | m | cả hai | Khe hở vòng quét khi xoay ↔ mặt dock |
|
||||
@@ -181,6 +182,7 @@ File mặc định đi kèm gói: `config/dock_global_params.yaml`. Cây đang c
|
||||
| `terminal/reverse_distance_padding` | `0.0` | m | cả hai | Khoảng hở cộng thêm cho đoạn cuối |
|
||||
| `terminal/straight_length` | `0.0` | m | cả hai | Độ dài đoạn thẳng cuối mong muốn |
|
||||
| `dock_straight_length` | unset | m | cả hai | Override `terminal/straight_length` theo marker, hợp lệ trong `[0, 2]` |
|
||||
| `dock_maximum_cusp_distance` | unset | m | cả hai | Override trần `maneuver/maximum_cusp_distance` theo marker; 0 = không giới hạn |
|
||||
| `sampling/path_point_spacing` | `0.05` | m | cả hai | Khoảng cách lấy mẫu |
|
||||
|
||||
`wheel_base` không khai trong YAML: nó là giá trị đo, để tránh cấu hình mâu thuẫn.
|
||||
@@ -198,6 +200,13 @@ theo marker và xoá bằng YAML `null` khi marker kế tiếp không khai. Kho
|
||||
với cả ba `dock_anchor`; nếu unset, DockPlanner dùng `terminal/straight_length`.
|
||||
Đoạn thẳng cuối được đặt theo `max(terminal floor, giá trị hiệu lực)`; tăng giá trị
|
||||
cần thêm khoảng trống từ vị trí bắt đầu và có thể đổi hình đường đi sang cusp hoặc xoay.
|
||||
`dock_maximum_cusp_distance` cũng nằm ở root planner namespace và hợp lệ với mọi
|
||||
`dock_anchor`. Thiếu hoặc YAML `null` dùng `maneuver/maximum_cusp_distance`;
|
||||
khai `0` tắt trần cho riêng marker, kể cả khi mặc định khác 0. Trần này giới hạn
|
||||
khoảng cách cusp → goal, khác với `maximum_forward_extension` chỉ giới hạn phần
|
||||
đi thêm từ vị trí xuất phát. Vượt trần thì loại `single_cusp`, thử các hình còn
|
||||
lại; nếu không có hình phù hợp thì planner báo lỗi. Giảm trần có thể tránh đoạn
|
||||
thẳng quá dài nhưng dễ thất bại hơn khi robot xuất phát xa goal.
|
||||
`dock_anchor: center` cộng nửa thân dock phía tiếp cận vào khoảng hở;
|
||||
`dock_anchor: face` bỏ qua `footprint_dock` hoàn toàn.
|
||||
`dock_anchor: mating_edge` cũng bỏ qua `footprint_dock`. Nó dành cho goal đã được tầng
|
||||
@@ -229,6 +238,7 @@ terminal là `0.2 m`, và `Xv = max(0.2, 0.474 - 0.40 + 0.10) = 0.2 m`.
|
||||
chối khởi động. `dock_face_offset` phải hữu hạn và thuộc `(0, 2] m`, còn
|
||||
`dock_pivot_safety_margin` phải hữu hạn và thuộc `[0, 1] m`.
|
||||
- `dock_straight_length` phải hữu hạn và thuộc `[0, 2] m`, với mọi `dock_anchor`.
|
||||
- `maneuver/maximum_cusp_distance` và `dock_maximum_cusp_distance` phải hữu hạn và >= 0 m.
|
||||
|
||||
`max_steering_angle` phải là góc lái tương đương theo bicycle model, không phải
|
||||
servo tick hay góc pivot tại vận tốc bằng không. Giá trị mặc định chỉ là điểm
|
||||
|
||||
@@ -101,6 +101,12 @@ DockPlanner:
|
||||
# xuống để đẩy sớm sang kiểu 2.
|
||||
maximum_forward_extension: 3.0
|
||||
|
||||
# [m] Trần đoạn thẳng từ cusp tới goal của single_cusp (khoảng xuất phát dọc trục + phần tiến thêm).
|
||||
# 0 = không giới hạn; vượt trần thì bỏ hình cusp và thử hình xoay, hết hình khả dụng thì báo fail.
|
||||
# Giảm giúp tránh lùi thẳng quá dài nhưng dễ fail khi robot xuất phát xa goal.
|
||||
# Marker có thể ghi đè bằng dock_maximum_cusp_distance trong maker_sources.yaml.
|
||||
maximum_cusp_distance: 0.0
|
||||
|
||||
# [m] Bật kiểu 1 (direct_entry — một cung hội tụ vào trục goal rồi đi thẳng
|
||||
# vào, giữ nguyên một chiều chạy) khi khoảng chỗ còn lại cho cung — khoảng
|
||||
# cách dọc trục từ robot tới goal trừ độ dài đoạn thẳng cuối — vượt số này.
|
||||
|
||||
@@ -81,6 +81,8 @@ struct DockPlannerConfig
|
||||
double reverse_distance_padding = 0.0; // [m], additional cusp clearance from dock
|
||||
double minimum_forward_distance = 0.25; // [m], guarantees a forward leg before reversing
|
||||
double maximum_forward_extension = 3.0; // [m], rejects unexpectedly large maneuvers
|
||||
/** [m] Maximum single-cusp terminal length; 0 disables the cap. */
|
||||
double maximum_cusp_distance = 0.0;
|
||||
double path_point_spacing = 0.05; // [m]
|
||||
|
||||
/**
|
||||
@@ -136,6 +138,9 @@ struct DockPlannerConfig
|
||||
/** [m] Per-marker override for terminal/straight_length; null means unset. */
|
||||
std::optional<double> dock_straight_length = std::nullopt;
|
||||
|
||||
/** [m] Per-marker override for maneuver/maximum_cusp_distance; null means unset. */
|
||||
std::optional<double> dock_maximum_cusp_distance = std::nullopt;
|
||||
|
||||
/** [m] Maximum straight back-off distance for the differential-only last-resort pivot. 0 disables it. */
|
||||
double pivot_backoff_max_distance = 0.0;
|
||||
|
||||
|
||||
@@ -339,6 +339,18 @@ bool DockCalc::cuspPlacement(double start_longitudinal, double start_lateral,
|
||||
return false;
|
||||
}
|
||||
|
||||
const double effective_maximum_cusp_distance =
|
||||
config_.dock_maximum_cusp_distance.value_or(config_.maximum_cusp_distance);
|
||||
if (effective_maximum_cusp_distance > 0.0 && placed > effective_maximum_cusp_distance)
|
||||
{
|
||||
robot::log_info(
|
||||
"[dock_calc] Single-cusp distance %.3f m exceeds cap %.3f m "
|
||||
"(source=%s); trying another shape.\n",
|
||||
placed, effective_maximum_cusp_distance,
|
||||
config_.dock_maximum_cusp_distance ? "marker" : "default");
|
||||
return false;
|
||||
}
|
||||
|
||||
cusp_distance = placed;
|
||||
extension = actual_extension;
|
||||
return true;
|
||||
@@ -830,6 +842,8 @@ bool DockCalc::makePlanMoveToDock(
|
||||
// before it enters the dock, and that is usually longer than its own overhang.
|
||||
const double effective_straight_length =
|
||||
config_.dock_straight_length.value_or(config_.straight_length);
|
||||
const double effective_maximum_cusp_distance =
|
||||
config_.dock_maximum_cusp_distance.value_or(config_.maximum_cusp_distance);
|
||||
const double straight_distance =
|
||||
std::max(minimum_cusp_distance, effective_straight_length);
|
||||
const double curve_room = start_longitudinal - straight_distance;
|
||||
@@ -1165,7 +1179,8 @@ bool DockCalc::makePlanMoveToDock(
|
||||
"cusp_reachable=%s (extension=%.3f m, max=%.3f m), "
|
||||
"pivot_enabled=%s (vertex=%.3f m, circumscribed=%.3f m), "
|
||||
"face_offset=%s, pivot_safety_margin=%.3f m, "
|
||||
"straight_length=%.3f m (source=%s), backoff_pivot=%s.\n",
|
||||
"straight_length=%.3f m (source=%s), "
|
||||
"maximum_cusp_distance=%.3f m (source=%s), backoff_pivot=%s.\n",
|
||||
differential ? "differential" : "ackermann",
|
||||
start_longitudinal, start_lateral, minimum_turning_radius,
|
||||
straight_distance, cusp_reachable ? "yes" : "no", cusp_extension,
|
||||
@@ -1173,6 +1188,8 @@ bool DockCalc::makePlanMoveToDock(
|
||||
pivot_vertex_distance, robot.circumscribed_radius,
|
||||
effective_face_offset_text.c_str(), effective_pivot_safety_margin,
|
||||
effective_straight_length, config_.dock_straight_length ? "marker" : "default",
|
||||
effective_maximum_cusp_distance,
|
||||
config_.dock_maximum_cusp_distance ? "marker" : "default",
|
||||
backoff_status.c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -1219,7 +1236,7 @@ bool DockCalc::makePlanMoveToDock(
|
||||
"curve_room=%.3f m, cusp_extension=%.3f m (pivot threshold=%.3f m), "
|
||||
"arc_radius=%.4f m, pivot_vertex=%.3f m, pivot_angle=%.4f rad, "
|
||||
"circumscribed_radius=%.3f m, face_offset=%s, pivot_safety_margin=%.3f m, "
|
||||
"straight_length=%.3f m (source=%s).\n",
|
||||
"straight_length=%.3f m (source=%s), maximum_cusp_distance=%.3f m (source=%s).\n",
|
||||
dock_with_front ? "front" : "rear", shapeName(selected),
|
||||
differential ? "differential" : "ackermann",
|
||||
plan.size(), approach_segment.size(), terminal_segment.size(),
|
||||
@@ -1228,7 +1245,9 @@ bool DockCalc::makePlanMoveToDock(
|
||||
cusp_extension, config_.pivot_fallback_extension, curve_radius,
|
||||
pivot_vertex_distance, pivot_angle, robot.circumscribed_radius,
|
||||
effective_face_offset_text.c_str(), effective_pivot_safety_margin,
|
||||
effective_straight_length, config_.dock_straight_length ? "marker" : "default");
|
||||
effective_straight_length, config_.dock_straight_length ? "marker" : "default",
|
||||
effective_maximum_cusp_distance,
|
||||
config_.dock_maximum_cusp_distance ? "marker" : "default");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -384,6 +384,7 @@ bool DockPlanner::initialize(std::string name,
|
||||
"max_steering_angle=%.4f rad, minimum_turning_radius=%.4f m, "
|
||||
"pivot_fallback_extension=%.3f m, pivot_safety_margin=%.3f m, "
|
||||
"dock_face_offset=%s, dock_pivot_safety_margin=%s, dock_straight_length=%s, "
|
||||
"maximum_cusp_distance=%.3f m (source=%s), "
|
||||
"pivot_backoff_max_distance=%.3f m, pivot_check_costmap=%s.\n",
|
||||
loaded_config.requiresAxleTf() ? "ackermann" : "differential",
|
||||
loaded_config.requiresAxleTf() ? loaded_config.front_axle_frame.c_str() : "-",
|
||||
@@ -393,6 +394,8 @@ bool DockPlanner::initialize(std::string name,
|
||||
loaded_config.pivot_safety_margin,
|
||||
dock_face_offset_text.c_str(), dock_pivot_safety_margin_text.c_str(),
|
||||
dock_straight_length_text.c_str(),
|
||||
loaded_config.dock_maximum_cusp_distance.value_or(loaded_config.maximum_cusp_distance),
|
||||
loaded_config.dock_maximum_cusp_distance ? "marker" : "default",
|
||||
loaded_config.pivot_backoff_max_distance,
|
||||
loaded_config.pivot_check_costmap ? "true" : "false");
|
||||
return true;
|
||||
|
||||
@@ -192,6 +192,8 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
||||
loaded.minimum_forward_distance, error) ||
|
||||
!readOptionalDouble(nh, "maneuver/maximum_forward_extension",
|
||||
loaded.maximum_forward_extension, error) ||
|
||||
!readOptionalDouble(nh, "maneuver/maximum_cusp_distance",
|
||||
loaded.maximum_cusp_distance, error) ||
|
||||
!readOptionalDouble(nh, "terminal/straight_length",
|
||||
loaded.straight_length, error) ||
|
||||
!readOptionalDouble(nh, "maneuver/direct_entry_min_curve_room",
|
||||
@@ -208,7 +210,9 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
||||
!readNullableOptionalDouble(nh, "dock_pivot_safety_margin",
|
||||
loaded.dock_pivot_safety_margin, error) ||
|
||||
!readNullableOptionalDouble(nh, "dock_straight_length",
|
||||
loaded.dock_straight_length, error))
|
||||
loaded.dock_straight_length, error) ||
|
||||
!readNullableOptionalDouble(nh, "dock_maximum_cusp_distance",
|
||||
loaded.dock_maximum_cusp_distance, error))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -225,6 +229,11 @@ bool DockPlannerConfig::load(const robot::NodeHandle& nh, DockPlannerConfig& con
|
||||
|
||||
bool DockPlannerConfig::validate(std::string& error) const
|
||||
{
|
||||
if (!std::isfinite(maximum_cusp_distance) || maximum_cusp_distance < 0.0)
|
||||
{
|
||||
error = "parameter 'maneuver/maximum_cusp_distance' must be finite and >= 0 m";
|
||||
return false;
|
||||
}
|
||||
const struct
|
||||
{
|
||||
const char* name;
|
||||
@@ -240,6 +249,7 @@ bool DockPlannerConfig::validate(std::string& error) const
|
||||
{"terminal/straight_length", straight_length},
|
||||
{"maneuver/minimum_forward_distance", minimum_forward_distance},
|
||||
{"maneuver/maximum_forward_extension", maximum_forward_extension},
|
||||
{"maneuver/maximum_cusp_distance", maximum_cusp_distance},
|
||||
{"maneuver/direct_entry_min_curve_room", direct_entry_min_curve_room},
|
||||
{"sampling/path_point_spacing", path_point_spacing},
|
||||
};
|
||||
@@ -295,6 +305,13 @@ bool DockPlannerConfig::validate(std::string& error) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dock_maximum_cusp_distance.has_value() &&
|
||||
(!std::isfinite(*dock_maximum_cusp_distance) || *dock_maximum_cusp_distance < 0.0))
|
||||
{
|
||||
error = "parameter 'dock_maximum_cusp_distance' must be finite and >= 0 m";
|
||||
return false;
|
||||
}
|
||||
|
||||
// A differential base has no steered axle: validating axle frames or a
|
||||
// steering limit there would reject a perfectly valid configuration and
|
||||
// stop the plugin from loading at all.
|
||||
|
||||
@@ -935,6 +935,113 @@ void testDockStraightLengthOverride()
|
||||
}
|
||||
}
|
||||
|
||||
void testMaximumCuspDistancePlanning()
|
||||
{
|
||||
auto config = apmConfig();
|
||||
config.pivot_fallback_extension = 1.0;
|
||||
const auto start = pose(2.8, 0.05, 0.0);
|
||||
const auto goal = pose(0.0, 0.0, 0.0);
|
||||
const auto robot_footprint = apmFootprint();
|
||||
const auto dock_footprint = apmDockFootprint();
|
||||
dock_planner::DockCalc calculator(config);
|
||||
const auto original = generatePath(calculator, start, goal, robot_footprint, dock_footprint);
|
||||
const std::size_t cusp = checkSingleCuspPath(
|
||||
original, goal.pose, 1.0 / config.minimumTurningRadius(), false);
|
||||
if (cusp >= original.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const double cusp_distance = std::fabs(longitudinal(original[cusp], goal.pose));
|
||||
CHECK(cusp_distance > 3.0);
|
||||
|
||||
config.maximum_cusp_distance = 0.0;
|
||||
calculator.setConfig(config);
|
||||
const auto unlimited = generatePath(calculator, start, goal, robot_footprint, dock_footprint);
|
||||
CHECK(pathsEqualExactly(original, unlimited));
|
||||
|
||||
config.maximum_cusp_distance = 3.0;
|
||||
calculator.setConfig(config);
|
||||
const auto pivot = generatePath(calculator, start, goal, robot_footprint, dock_footprint, true);
|
||||
checkPivotPath(pivot, goal.pose, false,
|
||||
std::max(0.85, std::hypot(1.65, 0.40) + 0.50 + config.pivot_safety_margin));
|
||||
|
||||
config.pivot_fallback_extension = 0.0;
|
||||
calculator.setConfig(config);
|
||||
std::vector<robot_geometry_msgs::Pose> path;
|
||||
CHECK(!calculator.makePlanMoveToDock(start, goal, robot_footprint, dock_footprint, path));
|
||||
CHECK(path.empty());
|
||||
|
||||
// A marker may raise the cap or disable a nonzero default cap entirely.
|
||||
config.dock_maximum_cusp_distance = cusp_distance + 1.0;
|
||||
calculator.setConfig(config);
|
||||
const auto raised_cap = generatePath(calculator, start, goal, robot_footprint, dock_footprint);
|
||||
CHECK(pathsEqualExactly(original, raised_cap));
|
||||
config.dock_maximum_cusp_distance = 0.0;
|
||||
calculator.setConfig(config);
|
||||
const auto disabled_cap = generatePath(calculator, start, goal, robot_footprint, dock_footprint);
|
||||
CHECK(pathsEqualExactly(original, disabled_cap));
|
||||
}
|
||||
|
||||
void testMaximumCuspDistanceConfig()
|
||||
{
|
||||
robot::NodeHandle root_nh;
|
||||
YAML::Node parameters(YAML::NodeType::Map);
|
||||
parameters["maneuver"]["maximum_cusp_distance"] = 3.0;
|
||||
root_nh.setParam("maximum_cusp_distance_test", parameters);
|
||||
robot::NodeHandle planner_nh(root_nh, "maximum_cusp_distance_test");
|
||||
dock_planner::DockPlannerConfig config;
|
||||
std::string error;
|
||||
|
||||
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
CHECK(!config.dock_maximum_cusp_distance.has_value());
|
||||
CHECK(near(config.maximum_cusp_distance, 3.0));
|
||||
planner_nh.setParam("dock_maximum_cusp_distance", 0.0);
|
||||
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
CHECK(config.dock_maximum_cusp_distance.has_value());
|
||||
CHECK(near(config.dock_maximum_cusp_distance.value_or(-1.0), 0.0));
|
||||
planner_nh.setParam("dock_maximum_cusp_distance", YAML::Node(YAML::NodeType::Null));
|
||||
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
CHECK(!config.dock_maximum_cusp_distance.has_value());
|
||||
CHECK(near(config.maximum_cusp_distance, 3.0));
|
||||
|
||||
// Verify the null value really restores the cap in planning.
|
||||
config.wheel_base = 1.3268;
|
||||
dock_planner::DockCalc calculator(config);
|
||||
std::vector<robot_geometry_msgs::Pose> path;
|
||||
CHECK(!calculator.makePlanMoveToDock(pose(2.8, 0.05, 0.0), pose(0.0, 0.0, 0.0),
|
||||
apmFootprint(), apmDockFootprint(), path));
|
||||
CHECK(path.empty());
|
||||
|
||||
planner_nh.setParam("dock_maximum_cusp_distance", 4.0);
|
||||
for (const char* anchor : {"center", "face", "mating_edge"})
|
||||
{
|
||||
planner_nh.setParam("dock_anchor", YAML::Node(anchor));
|
||||
CHECK(dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
}
|
||||
for (const char* key : {"maneuver/maximum_cusp_distance", "dock_maximum_cusp_distance"})
|
||||
{
|
||||
planner_nh.setParam(key, -0.01);
|
||||
CHECK(!dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
CHECK(error == std::string("parameter '") + key + "' must be finite and >= 0 m");
|
||||
planner_nh.setParam(key, std::numeric_limits<double>::quiet_NaN());
|
||||
CHECK(!dock_planner::DockPlannerConfig::load(planner_nh, config, error));
|
||||
CHECK(error.find(key) != std::string::npos);
|
||||
planner_nh.setParam(key, 0.0);
|
||||
}
|
||||
for (const double value : {-0.01, std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::infinity()})
|
||||
{
|
||||
config = dock_planner::DockPlannerConfig{};
|
||||
config.maximum_cusp_distance = value;
|
||||
CHECK(!config.validate(error));
|
||||
CHECK(error == "parameter 'maneuver/maximum_cusp_distance' must be finite and >= 0 m");
|
||||
config.maximum_cusp_distance = 0.0;
|
||||
config.dock_maximum_cusp_distance = value;
|
||||
CHECK(!config.validate(error));
|
||||
CHECK(error == "parameter 'dock_maximum_cusp_distance' must be finite and >= 0 m");
|
||||
}
|
||||
}
|
||||
|
||||
void testExistingPlansUnchangedByBackoff()
|
||||
{
|
||||
const auto robot_footprint = apmFootprint();
|
||||
@@ -1531,6 +1638,8 @@ int main()
|
||||
testMatingEdgeFaceOffset();
|
||||
testDockPivotSafetyMarginOverride();
|
||||
testDockStraightLengthOverride();
|
||||
testMaximumCuspDistancePlanning();
|
||||
testMaximumCuspDistanceConfig();
|
||||
testExistingPlansUnchangedByBackoff();
|
||||
testBackoffPivotGates();
|
||||
testCostmapCheckCallbacks();
|
||||
|
||||
Reference in New Issue
Block a user