Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed May 5, 2024
1 parent 3ccd2e7 commit 16baeb5
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,19 @@ inline bool RosTopicSubNode<T>::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<SubscriberInstance>(shared_node, topic_name);
sub_instance_ = std::make_shared<SubscriberInstance>(node, topic_name);
registry.insert({ subscriber_key_, sub_instance_ });

RCLCPP_INFO(logger(), "Node [%s] created Subscriber to topic [%s]", name().c_str(),
Expand Down

0 comments on commit 16baeb5

Please sign in to comment.