feat: add dock_anchor mating_edge for goals already offset to the docked pose
The charger detector offsets its target to the docked base_link pose (offset_x 0.40 from the V apex), so the charger face is at the robot's rear edge at the goal. dock_anchor=face places the face at the goal itself, so the pivot vertex came out 0.624 m in front of the goal, about 0.40 m more than needed. Robots standing 0.38-0.58 m out had to back off or failed to plan. dock_anchor=mating_edge keeps every face behaviour, except that the on-the-spot pivot clearance is measured from the real face, mating_extent behind the goal: vertex = max(straight_length, circumscribed - mating_extent + pivot_safety_margin). For the KIT robot (0.65 x 0.69) the vertex drops from 0.624 m to 0.4 m. footprint_dock is ignored, as with face. center, face, direct entry and single cusp are unchanged. Test: the 29/10 starts 0.579/0.292 and 0.427/0.155 now pivot directly at 0.4 m; 0.375/-0.149 backs off only to 0.45 m (26 poses against 36 with face).
This commit is contained in:
@@ -171,6 +171,13 @@ File mặc định đi kèm gói: `config/dock_global_params.yaml`. Cây đang c
|
||||
từng marker rồi rót vào namespace `DockPlanner` trước khi dựng plugin.
|
||||
`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
|
||||
trên offset sẵn thành vị trí `base_link` lúc dock xong (ví dụ trạm sạc dò bằng lidar với
|
||||
`offset_x`): mặt dock nằm sát mép robot đi vào tại goal, sau goal đúng `rear_extent`
|
||||
(lùi vào) hoặc `front_extent` (tiến vào). Chỉ điểm xoay của kiểu thẳng + xoay + thẳng
|
||||
(và kiểu lùi ra rồi xoay) đổi: `max(straight_length, bán kính ngoại tiếp − extent mép +
|
||||
pivot_safety_margin)`, thay vì đo từ goal như `face`. Robot KIT 0.65 × 0.69, trạm sạc:
|
||||
điểm xoay 0.4 m thay vì 0.624 m. Đường vào thẳng và đường cusp không đổi.
|
||||
|
||||
Điều kiện validate:
|
||||
|
||||
|
||||
@@ -18,11 +18,17 @@ inline constexpr double kPi = 3.14159265358979323846;
|
||||
* footprint_dock is added to the approach distance.
|
||||
* kFace: goal is already on the approach face; footprint_dock does not
|
||||
* contribute to the approach distance and is ignored entirely.
|
||||
* kMatingEdge: goal is the docked base_link pose, already offset upstream
|
||||
* (e.g. by the detector), and the dock face touches the robot's mating edge
|
||||
* there. Same as kFace, except that the on-the-spot pivot clearance is measured
|
||||
* from that real face, mating_extent behind the goal, instead of from the goal.
|
||||
* footprint_dock is ignored.
|
||||
*/
|
||||
enum class DockAnchor
|
||||
{
|
||||
kCenter,
|
||||
kFace,
|
||||
kMatingEdge,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -819,9 +819,16 @@ bool DockCalc::makePlanMoveToDock(
|
||||
// circumscribed radius here, which is always more than the mating extent
|
||||
// the straight terminal is sized from. Sizing the vertex from the terminal
|
||||
// instead would drive a corner of the robot into the dock.
|
||||
//
|
||||
// With dock_anchor=mating_edge the goal is the docked base_link pose and the
|
||||
// dock face sits at the robot's mating edge, mating_extent behind the goal.
|
||||
// The sweep clearance is measured from that real face. face and center keep
|
||||
// the face at the goal / at dock_extent, unchanged.
|
||||
const double pivot_face_offset =
|
||||
config_.dock_anchor == DockAnchor::kMatingEdge ? -mating_extent : dock_extent;
|
||||
const double pivot_vertex_distance = std::max(
|
||||
straight_distance,
|
||||
robot.circumscribed_radius + dock_extent + config_.pivot_safety_margin);
|
||||
robot.circumscribed_radius + pivot_face_offset + config_.pivot_safety_margin);
|
||||
|
||||
// The pivot shape needs a base that can change heading without moving. A
|
||||
// differential base can exactly when its declared turning radius is 0; a
|
||||
|
||||
@@ -322,14 +322,18 @@ bool DockPlanner::initialize(std::string name,
|
||||
}
|
||||
|
||||
std::vector<robot_geometry_msgs::Point> loaded_footprint;
|
||||
if (loaded_config.dock_anchor == DockAnchor::kFace)
|
||||
if (loaded_config.dock_anchor == DockAnchor::kFace ||
|
||||
loaded_config.dock_anchor == DockAnchor::kMatingEdge)
|
||||
{
|
||||
// Goal sits on the approach face: dock size never enters the approach
|
||||
// formula, so a declared footprint_dock is deliberately ignored.
|
||||
// Goal sits on the approach face (face) or the face touches the robot at
|
||||
// the goal (mating_edge): dock size never enters the approach formula,
|
||||
// so a declared footprint_dock is deliberately ignored.
|
||||
if (planner_nh.hasParam("footprint_dock"))
|
||||
{
|
||||
robot::log_info("[dock_planner] '%s' uses dock_anchor=face; footprint_dock is ignored.\n",
|
||||
name.c_str());
|
||||
robot::log_info("[dock_planner] '%s' uses dock_anchor=%s; footprint_dock is ignored.\n",
|
||||
name.c_str(),
|
||||
loaded_config.dock_anchor == DockAnchor::kFace ? "face"
|
||||
: "mating_edge");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -85,7 +85,13 @@ bool readDockAnchor(const robot::NodeHandle& nh, DockAnchor& anchor, std::string
|
||||
anchor = DockAnchor::kFace;
|
||||
return true;
|
||||
}
|
||||
error = "parameter 'dock_anchor' must be 'center' or 'face' (got '" + parsed + "')";
|
||||
if (parsed == "mating_edge")
|
||||
{
|
||||
anchor = DockAnchor::kMatingEdge;
|
||||
return true;
|
||||
}
|
||||
error = "parameter 'dock_anchor' must be 'center', 'face' or 'mating_edge' (got '" +
|
||||
parsed + "')";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -584,6 +584,57 @@ void testBackoffPivotRobotFailures()
|
||||
}
|
||||
}
|
||||
|
||||
void testMatingEdgeAnchor()
|
||||
{
|
||||
// KIT charger: the detector already offsets the goal to the docked
|
||||
// base_link pose, so the charger face is at the robot's rear edge there.
|
||||
const auto robot_footprint = robotFootprint065x069();
|
||||
const std::vector<robot_geometry_msgs::Point> no_dock_footprint;
|
||||
const auto goal = pose(0.0, 0.0, 0.0);
|
||||
const double circumscribed = std::hypot(0.325, 0.345);
|
||||
const double face_vertex = circumscribed + 0.15;
|
||||
// max(straight_length 0.4, 0.474 - 0.325 + 0.15 = 0.299)
|
||||
const double mating_vertex = std::max(0.4, circumscribed - 0.325 + 0.15);
|
||||
CHECK(near(mating_vertex, 0.4));
|
||||
|
||||
auto face_config = differentialBackoffConfig();
|
||||
face_config.dock_anchor = dock_planner::DockAnchor::kFace;
|
||||
face_config.pivot_backoff_max_distance = 1.0;
|
||||
auto mating_config = face_config;
|
||||
mating_config.dock_anchor = dock_planner::DockAnchor::kMatingEdge;
|
||||
dock_planner::DockCalc face_calc(face_config);
|
||||
dock_planner::DockCalc mating_calc(mating_config);
|
||||
|
||||
// The two 29/10 starts that needed a back-off with face now pivot in place
|
||||
// at 0.4 m, with no back-off leg.
|
||||
for (const auto& start : {pose(0.579, 0.292, 0.0), pose(0.427, 0.155, 0.0)})
|
||||
{
|
||||
std::vector<robot_geometry_msgs::Pose> path;
|
||||
CHECK(mating_calc.makePlanMoveToDock(start, goal, robot_footprint,
|
||||
no_dock_footprint, path));
|
||||
checkPivotPath(path, goal.pose, false, mating_vertex);
|
||||
}
|
||||
|
||||
// 29/10 15:36 start: still closer than the vertex, so it backs off, but
|
||||
// only to vertex + spacing (0.45 m) instead of 0.674 m.
|
||||
const auto close_start = pose(0.375, -0.149, 0.17);
|
||||
std::vector<robot_geometry_msgs::Pose> face_path;
|
||||
std::vector<robot_geometry_msgs::Pose> mating_path;
|
||||
CHECK(face_calc.makePlanMoveToDock(close_start, goal, robot_footprint,
|
||||
no_dock_footprint, face_path));
|
||||
CHECK(mating_calc.makePlanMoveToDock(close_start, goal, robot_footprint,
|
||||
no_dock_footprint, mating_path));
|
||||
checkBackoffPivotPath(face_path, close_start, goal, face_vertex);
|
||||
checkBackoffPivotPath(mating_path, close_start, goal, mating_vertex);
|
||||
double furthest = 0.0;
|
||||
for (const auto& path_pose : mating_path)
|
||||
{
|
||||
furthest = std::max(furthest, longitudinal(path_pose, goal.pose));
|
||||
}
|
||||
CHECK(furthest < mating_vertex + 0.05 + 1e-6);
|
||||
CHECK(mating_path.size() < face_path.size());
|
||||
}
|
||||
|
||||
void testExistingPlansUnchangedByBackoff()
|
||||
{
|
||||
const auto robot_footprint = apmFootprint();
|
||||
@@ -1176,6 +1227,7 @@ int main()
|
||||
{
|
||||
testConfig();
|
||||
testBackoffPivotRobotFailures();
|
||||
testMatingEdgeAnchor();
|
||||
testExistingPlansUnchangedByBackoff();
|
||||
testBackoffPivotGates();
|
||||
testCostmapCheckCallbacks();
|
||||
|
||||
Reference in New Issue
Block a user