feat: take the detection frame from robot_base_frame, drop prior_frame
The search fan, prior and mount checks are now expressed in the context's robot_base_frame, like DockPatternActionHandler. A leftover prior_frame equal to it loads with one warning; a different one fails init. The tape core threshold and plateau fraction keys are optional.
This commit is contained in:
@@ -74,8 +74,9 @@ double angleError(double first, double second)
|
||||
class Rig
|
||||
{
|
||||
public:
|
||||
Rig()
|
||||
explicit Rig(const std::string& base_frame = "base_link")
|
||||
{
|
||||
context.robot_base_frame = base_frame;
|
||||
robot_sensor_ports::SensorStoreConfig config;
|
||||
for (const char* topic : {"/f_scan", "/b_scan2"})
|
||||
{
|
||||
@@ -95,7 +96,6 @@ public:
|
||||
context.tf = &tf;
|
||||
context.sensors = &store;
|
||||
context.global_frame = "map";
|
||||
context.robot_base_frame = "base_link";
|
||||
registry.setContext(context);
|
||||
loaded = registry.loadFromConfig(nh, kNamespace);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
const double cp = std::cos(pitch / 2), sp = std::sin(pitch / 2);
|
||||
const double cy = std::cos(yaw / 2), sy = std::sin(yaw / 2);
|
||||
tf3::TransformStampedMsg transform;
|
||||
transform.header.frame_id = "base_link";
|
||||
transform.header.frame_id = context.robot_base_frame;
|
||||
transform.child_frame_id = child;
|
||||
transform.transform.rotation.w = cr * cp * cy + sr * sp * sy;
|
||||
transform.transform.rotation.x = sr * cp * cy - cr * sp * sy;
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
tf3::TransformStampedMsg transform;
|
||||
transform.header.stamp = tf3::Time(time.sec, time.nsec);
|
||||
transform.header.frame_id = "map";
|
||||
transform.child_frame_id = "base_link";
|
||||
transform.child_frame_id = context.robot_base_frame;
|
||||
transform.transform.translation.x = x;
|
||||
transform.transform.rotation.w = 1.0;
|
||||
tf.setTransform(transform, "test", false);
|
||||
@@ -179,6 +179,86 @@ public:
|
||||
bool loaded = false;
|
||||
};
|
||||
|
||||
TEST(WallReflectorAction, AbsentPriorFrameDetectsInContextBaseFrame)
|
||||
{
|
||||
Rig rig("custom_robot_base");
|
||||
ASSERT_TRUE(rig.store_ok);
|
||||
ASSERT_FALSE(rig.nh.hasParam("actions_wall/forward/prior_frame"));
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
auto* handler = rig.registry.find("DetectWallReflectors");
|
||||
ASSERT_NE(handler, nullptr);
|
||||
ASSERT_TRUE(handler->start(action("DetectWallReflectors"), robot::Time(10.0)));
|
||||
const auto result = rig.happy(handler);
|
||||
EXPECT_EQ(result.status, ActionStatus::kSucceeded) << result.message;
|
||||
EXPECT_TRUE(rig.hasOutput(kTarget));
|
||||
}
|
||||
|
||||
TEST(WallReflectorAction, LegacyPriorFrameEqualToContextBaseLoads)
|
||||
{
|
||||
Rig rig("custom_robot_base");
|
||||
const std::string root = "actions_wall/forward";
|
||||
YAML::Node current;
|
||||
ASSERT_TRUE(rig.nh.getParam(root, current));
|
||||
const YAML::Node original = YAML::Clone(current);
|
||||
rig.nh.setParam(root + "/prior_frame", "custom_robot_base");
|
||||
ActionRegistry registry;
|
||||
registry.setContext(rig.context);
|
||||
EXPECT_TRUE(registry.loadFromConfig(rig.nh, kNamespace));
|
||||
EXPECT_NE(registry.find("DetectWallReflectors"), nullptr);
|
||||
rig.nh.setParam(root, original);
|
||||
}
|
||||
|
||||
TEST(WallReflectorAction, LegacyPriorFrameDifferentFromContextBaseFails)
|
||||
{
|
||||
Rig rig;
|
||||
const std::string root = "actions_wall/forward";
|
||||
YAML::Node current;
|
||||
ASSERT_TRUE(rig.nh.getParam(root, current));
|
||||
const YAML::Node original = YAML::Clone(current);
|
||||
rig.nh.setParam(root + "/prior_frame", "other_frame");
|
||||
ActionRegistry registry;
|
||||
registry.setContext(rig.context);
|
||||
EXPECT_FALSE(registry.loadFromConfig(rig.nh, kNamespace));
|
||||
EXPECT_EQ(registry.find("DetectWallReflectors"), nullptr);
|
||||
rig.nh.setParam(root, original);
|
||||
}
|
||||
|
||||
TEST(WallReflectorAction, EmptyContextBaseFrameFails)
|
||||
{
|
||||
Rig rig;
|
||||
rig.context.robot_base_frame.clear();
|
||||
ActionRegistry registry;
|
||||
registry.setContext(rig.context);
|
||||
EXPECT_FALSE(registry.loadFromConfig(rig.nh, kNamespace));
|
||||
EXPECT_EQ(registry.find("DetectWallReflectors"), nullptr);
|
||||
}
|
||||
|
||||
TEST(WallReflectorAction, ProfileWithoutOptionalThresholdsLoadsAndDetects)
|
||||
{
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.store_ok);
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
const std::string key = "actions_wall/forward/profiles/standard";
|
||||
YAML::Node current;
|
||||
ASSERT_TRUE(rig.nh.getParam(key, current));
|
||||
const YAML::Node original = YAML::Clone(current);
|
||||
YAML::Node without_optional = YAML::Clone(current);
|
||||
without_optional.remove("tape_core_intensity");
|
||||
without_optional.remove("tape_plateau_min_fraction");
|
||||
rig.nh.setParam(key, without_optional);
|
||||
ActionRegistry registry;
|
||||
registry.setContext(rig.context);
|
||||
const bool loaded = registry.loadFromConfig(rig.nh, kNamespace);
|
||||
rig.nh.setParam(key, original);
|
||||
ASSERT_TRUE(loaded);
|
||||
auto* handler = registry.find("DetectWallReflectors");
|
||||
ASSERT_NE(handler, nullptr);
|
||||
ASSERT_TRUE(handler->start(action("DetectWallReflectors"), robot::Time(10.0)));
|
||||
const auto result = rig.happy(handler);
|
||||
ASSERT_EQ(result.status, ActionStatus::kSucceeded) << result.message;
|
||||
EXPECT_NEAR(rig.output(kTarget).transform.translation.x, 0.4, 0.01);
|
||||
}
|
||||
|
||||
TEST(WallReflectorAction, PluginLoadAndForwardTarget)
|
||||
{
|
||||
Rig rig;
|
||||
|
||||
Reference in New Issue
Block a user