File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
behaviortree_ros2/include/behaviortree_ros2 Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,11 @@ inline bool RosActionNode<T>::createClient(const std::string& action_name)
316316
317317 std::unique_lock lk (getMutex ());
318318 auto node = node_.lock ();
319+ if (!node)
320+ {
321+ throw RuntimeError (" The ROS node went out of scope. RosNodeParams doesn't take the "
322+ " ownership of the node." );
323+ }
319324 action_client_key_ = std::string (node->get_fully_qualified_name ()) + " /" + action_name;
320325
321326 auto & registry = getRegistry ();
Original file line number Diff line number Diff line change @@ -282,6 +282,11 @@ inline bool RosServiceNode<T>::createClient(const std::string& service_name)
282282
283283 std::unique_lock lk (getMutex ());
284284 auto node = node_.lock ();
285+ if (!node)
286+ {
287+ throw RuntimeError (" The ROS node went out of scope. RosNodeParams doesn't take the "
288+ " ownership of the node." );
289+ }
285290 auto client_key = std::string (node->get_fully_qualified_name ()) + " /" + service_name;
286291
287292 auto & registry = getRegistry ();
Original file line number Diff line number Diff line change @@ -250,6 +250,11 @@ inline bool RosTopicSubNode<T>::createSubscriber(const std::string& topic_name)
250250 std::unique_lock lk (registryMutex ());
251251
252252 auto shared_node = node_.lock ();
253+ if (!node)
254+ {
255+ throw RuntimeError (" The ROS node went out of scope. RosNodeParams doesn't take the "
256+ " ownership of the node." );
257+ }
253258 subscriber_key_ =
254259 std::string (shared_node->get_fully_qualified_name ()) + " /" + topic_name;
255260
You can’t perform that action at this time.
0 commit comments