diff --git a/tf2_ros/include/tf2_ros/static_transform_broadcaster.h b/tf2_ros/include/tf2_ros/static_transform_broadcaster.h index a0d4f15b7..d577703b7 100644 --- a/tf2_ros/include/tf2_ros/static_transform_broadcaster.h +++ b/tf2_ros/include/tf2_ros/static_transform_broadcaster.h @@ -66,6 +66,15 @@ class StaticTransformBroadcaster rclcpp::QosPolicyKind::Depth, rclcpp::QosPolicyKind::History, rclcpp::QosPolicyKind::Reliability}; + /* + This flag disables intra-process communication while publishing to + /tf_static topic, when the StaticTransformBroadcaster 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( @@ -87,6 +96,15 @@ class StaticTransformBroadcaster rclcpp::QosPolicyKind::Depth, rclcpp::QosPolicyKind::History, rclcpp::QosPolicyKind::Reliability}; + /* + This flag disables intra-process communication while publishing to + /tf_static topic, when the StaticTransformBroadcaster 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; } ()) { diff --git a/tf2_ros/test/test_static_transform_broadcaster.cpp b/tf2_ros/test/test_static_transform_broadcaster.cpp index 98755052e..37dbbfcc7 100644 --- a/tf2_ros/test/test_static_transform_broadcaster.cpp +++ b/tf2_ros/test/test_static_transform_broadcaster.cpp @@ -50,6 +50,22 @@ class CustomNode : public rclcpp::Node std::shared_ptr 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(shared_from_this()); + } + +private: + std::shared_ptr tf_broadcaster_; +}; + TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_rclcpp_node) { auto node = rclcpp::Node::make_shared("tf2_ros_message_filter"); @@ -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(options); + custom_node->init_tf_broadcaster(); +} + TEST(tf2_test_static_transform_broadcaster, transform_broadcaster_custom_rclcpp_node) { auto node = std::make_shared("tf2_ros_message_filter");