32 #ifndef TF2_ROS__TRANSFORM_LISTENER_H_
33 #define TF2_ROS__TRANSFORM_LISTENER_H_
35 #include <tf2/buffer_core.h>
39 #include <tf2_msgs/msg/tf_message.hpp>
40 #include <rclcpp/rclcpp.hpp>
55 template<
class AllocatorT = std::allocator<
void>>
56 rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>
59 rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options;
60 options.qos_overriding_options = rclcpp::QosOverridingOptions{
61 rclcpp::QosPolicyKind::Depth,
62 rclcpp::QosPolicyKind::Durability,
63 rclcpp::QosPolicyKind::History,
64 rclcpp::QosPolicyKind::Reliability};
68 template<
class AllocatorT = std::allocator<
void>>
69 rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>
72 rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options;
73 options.qos_overriding_options = rclcpp::QosOverridingOptions{
74 rclcpp::QosPolicyKind::Depth,
75 rclcpp::QosPolicyKind::History,
76 rclcpp::QosPolicyKind::Reliability};
90 template<
class NodeT,
class AllocatorT = std::allocator<
void>>
92 tf2::BufferCore & buffer,
94 bool spin_thread =
true,
97 const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options =
98 detail::get_default_transform_listener_sub_options<AllocatorT>(),
99 const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & static_options =
100 detail::get_default_transform_listener_static_sub_options<AllocatorT>())
103 init(node, spin_thread, qos, static_qos, options, static_options);
104 node_logging_interface_ = node->get_node_logging_interface();
111 template<
class NodeT,
class AllocatorT = std::allocator<
void>>
115 const rclcpp::QoS & qos,
116 const rclcpp::QoS & static_qos,
117 const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options,
118 const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & static_options)
120 node_logging_interface_ = node->get_node_logging_interface();
122 using callback_t =
std::function<void (tf2_msgs::msg::TFMessage::SharedPtr)>;
124 &TransformListener::subscription_callback,
this, std::placeholders::_1,
false);
126 &TransformListener::subscription_callback,
this, std::placeholders::_1,
true);
128 message_subscription_tf_ = rclcpp::create_subscription<tf2_msgs::msg::TFMessage>(
134 message_subscription_tf_static_ = rclcpp::create_subscription<tf2_msgs::msg::TFMessage>(
142 initThread(node->get_node_base_interface());
148 rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface);
152 void subscription_callback(tf2_msgs::msg::TFMessage::SharedPtr msg,
bool is_static);
157 thread_ptr dedicated_listener_thread_;
159 rclcpp::Node::SharedPtr optional_default_node_ =
nullptr;
160 rclcpp::Subscription<tf2_msgs::msg::TFMessage>::SharedPtr message_subscription_tf_;
161 rclcpp::Subscription<tf2_msgs::msg::TFMessage>::SharedPtr message_subscription_tf_static_;
162 tf2::BufferCore & buffer_;
163 tf2::TimePoint last_update_;
164 rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_interface_;
168 #endif // TF2_ROS__TRANSFORM_LISTENER_H_