feat(planner_runner): bind dock_face_offset and dock_pivot_safety_margin per marker
Two new DockPlanner keys, valid only with dock_anchor: mating_edge, are copied from docking_marker_profiles/<marker> into the planner namespace like footprint_dock and dock_anchor. Unlike those two, the new keys are optional. A marker that does not declare one would keep the value bound by the previous marker, so the charger's smaller pivot margin could leak into a later trolley docking. When the marker lacks a key that the planner namespace still holds, the binder writes a YAML null, which DockPlanner reads as unset, and counts it as a change so that the instance is rebuilt. footprint_dock and dock_anchor keep their old behaviour.
This commit is contained in:
@@ -774,6 +774,51 @@ TEST(PlannerRunnerDockingMarker, ProfileWithoutFootprintDockIsAcceptedAndChanges
|
||||
EXPECT_EQ(pluginInitializeCount(), before);
|
||||
}
|
||||
|
||||
TEST(PlannerRunnerDockingMarker, CopiesAndClearsOptionalDockOverridesPerMarker)
|
||||
{
|
||||
Fixture fixture;
|
||||
ASSERT_TRUE(fixture.ok()) << fixture.error();
|
||||
|
||||
robot::NodeHandle nh;
|
||||
// Create isolated profiles in the shared test parameter tree so this test does not alter the
|
||||
// checked-in fixture or affect the existing dock_a/dock_b footprint tests.
|
||||
nh.setParam("docking_marker_profiles/dock_override/dock_face_offset", 0.40);
|
||||
nh.setParam("docking_marker_profiles/dock_override/dock_pivot_safety_margin", 0.10);
|
||||
nh.setParam("docking_marker_profiles/dock_no_override/global_planner",
|
||||
YAML::Node("TestPlannerOk"));
|
||||
|
||||
const std::size_t before = pluginInitializeCount();
|
||||
ASSERT_TRUE(fixture.runner_.bindDockingMarker("dock_override", "TestPlannerOk"));
|
||||
YAML::Node copied_face_offset;
|
||||
YAML::Node copied_margin;
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_face_offset", copied_face_offset));
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_pivot_safety_margin", copied_margin));
|
||||
EXPECT_DOUBLE_EQ(copied_face_offset.as<double>(), 0.40);
|
||||
EXPECT_DOUBLE_EQ(copied_margin.as<double>(), 0.10);
|
||||
ASSERT_TRUE(fixture.runner_.swapPlanner("TestPlannerOk"));
|
||||
EXPECT_EQ(pluginInitializeCount(), before + 1);
|
||||
|
||||
ASSERT_TRUE(fixture.runner_.bindDockingMarker("dock_no_override", "TestPlannerOk"));
|
||||
YAML::Node cleared_face_offset;
|
||||
YAML::Node cleared_margin;
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_face_offset", cleared_face_offset));
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_pivot_safety_margin", cleared_margin));
|
||||
EXPECT_TRUE(cleared_face_offset.IsNull());
|
||||
EXPECT_TRUE(cleared_margin.IsNull());
|
||||
ASSERT_TRUE(fixture.runner_.swapPlanner("TestPlannerOk"));
|
||||
EXPECT_EQ(pluginInitializeCount(), before + 2);
|
||||
|
||||
ASSERT_TRUE(fixture.runner_.bindDockingMarker("dock_override", "TestPlannerOk"));
|
||||
YAML::Node restored_face_offset;
|
||||
YAML::Node restored_margin;
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_face_offset", restored_face_offset));
|
||||
ASSERT_TRUE(nh.getParam("TestPlannerOk/dock_pivot_safety_margin", restored_margin));
|
||||
EXPECT_DOUBLE_EQ(restored_face_offset.as<double>(), 0.40);
|
||||
EXPECT_DOUBLE_EQ(restored_margin.as<double>(), 0.10);
|
||||
ASSERT_TRUE(fixture.runner_.swapPlanner("TestPlannerOk"));
|
||||
EXPECT_EQ(pluginInitializeCount(), before + 3);
|
||||
}
|
||||
|
||||
TEST(PlannerRunnerDockingMarker, EmptyMarkerOrPlannerNameIsANoOp)
|
||||
{
|
||||
Fixture fixture;
|
||||
|
||||
Reference in New Issue
Block a user