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:
2026-10-29 15:59:47 +07:00
parent 7c93fe47aa
commit 9d31c0e5db
6 changed files with 89 additions and 7 deletions

View File

@@ -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();