Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable StaticTransformBroadcaster in Intra-process enabled components #607

Merged
merged 4 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tf2_ros/include/tf2_ros/static_transform_broadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class StaticTransformBroadcaster
rclcpp::QosPolicyKind::Depth,
rclcpp::QosPolicyKind::History,
rclcpp::QosPolicyKind::Reliability};
/*
This flag disables intra-process communication while subscribing to
/tf_static topic, when the TransformListener is constructed using an existing
node handle which happens to be a component (in rclcpp terminology).
Required until rclcpp intra-process communication supports
transient_local QoS durability.
*/
options.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable;
return options;
} ())
: StaticTransformBroadcaster(
Expand All @@ -87,6 +95,14 @@ class StaticTransformBroadcaster
rclcpp::QosPolicyKind::Depth,
rclcpp::QosPolicyKind::History,
rclcpp::QosPolicyKind::Reliability};
/*
This flag disables intra-process communication while subscribing to
/tf_static topic, when the TransformListener is constructed using an existing
node handle which happens to be a component (in rclcpp terminology).
Required until rclcpp intra-process communication supports
transient_local QoS durability.
*/
options.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable;
return options;
} ())
{
Expand Down
25 changes: 25 additions & 0 deletions tf2_ros/test/test_static_transform_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ class CustomNode : public rclcpp::Node
std::shared_ptr<tf2_ros::StaticTransformBroadcaster> tf_broadcaster_;
};

class CustomComposableNode : public rclcpp::Node
{
public:
explicit CustomComposableNode(const rclcpp::NodeOptions & options)
: rclcpp::Node("tf2_ros_test_static_transform_broadcaster_composable_node", options)
{}

void init_tf_broadcaster()
{
tf_broadcaster_ = std::make_shared<tf2_ros::StaticTransformBroadcaster>(shared_from_this());
}

private:
std::shared_ptr<tf2_ros::StaticTransformBroadcaster> tf_broadcaster_;
};

TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_rclcpp_node)
{
auto node = rclcpp::Node::make_shared("tf2_ros_message_filter");
Expand All @@ -70,6 +86,15 @@ TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_rclcpp_node)
}
}

TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_with_intraprocess)
{
rclcpp::executors::SingleThreadedExecutor exec;
rclcpp::NodeOptions options;
options = options.use_intra_process_comms(true);
auto custom_node = std::make_shared<CustomComposableNode>(options);
custom_node->init_tf_broadcaster();
}

TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_custom_rclcpp_node)
{
auto node = std::make_shared<NodeWrapper>("tf2_ros_message_filter");
Expand Down