File tree 3 files changed +15
-0
lines changed
behaviortree_ros2/include/behaviortree_ros2
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)
316
316
317
317
std::unique_lock lk (getMutex ());
318
318
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
+ }
319
324
action_client_key_ = std::string (node->get_fully_qualified_name ()) + " /" + action_name;
320
325
321
326
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)
282
282
283
283
std::unique_lock lk (getMutex ());
284
284
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
+ }
285
290
auto client_key = std::string (node->get_fully_qualified_name ()) + " /" + service_name;
286
291
287
292
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)
250
250
std::unique_lock lk (registryMutex ());
251
251
252
252
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
+ }
253
258
subscriber_key_ =
254
259
std::string (shared_node->get_fully_qualified_name ()) + " /" + topic_name;
255
260
You can’t perform that action at this time.
0 commit comments