From 16baeb5f4c3852d5ce8a60895152435a3e5b31c3 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Sun, 5 May 2024 16:07:47 +0200 Subject: [PATCH] fix --- .../include/behaviortree_ros2/bt_topic_sub_node.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp b/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp index f3a6d87..211f41c 100644 --- a/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp +++ b/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp @@ -249,20 +249,19 @@ inline bool RosTopicSubNode::createSubscriber(const std::string& topic_name) // find SubscriberInstance in the registry std::unique_lock lk(registryMutex()); - auto shared_node = node_.lock(); + auto node = node_.lock(); if(!node) { throw RuntimeError("The ROS node went out of scope. RosNodeParams doesn't take the " "ownership of the node."); } - subscriber_key_ = - std::string(shared_node->get_fully_qualified_name()) + "/" + topic_name; + subscriber_key_ = std::string(node->get_fully_qualified_name()) + "/" + topic_name; auto& registry = getRegistry(); auto it = registry.find(subscriber_key_); if(it == registry.end() || it->second.expired()) { - sub_instance_ = std::make_shared(shared_node, topic_name); + sub_instance_ = std::make_shared(node, topic_name); registry.insert({ subscriber_key_, sub_instance_ }); RCLCPP_INFO(logger(), "Node [%s] created Subscriber to topic [%s]", name().c_str(),