From 1810e328fc2f102cdf6d82e8b4d9203967ea0200 Mon Sep 17 00:00:00 2001 From: Steve Macenski Date: Thu, 3 Jun 2021 10:59:07 -0700 Subject: [PATCH 1/3] adding node name to the executor runtime_error Signed-off-by: Steve Macenski --- rclcpp/src/rclcpp/executor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index ea08204798..3949ba47b6 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -268,7 +268,8 @@ Executor::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_pt // If the node already has an executor std::atomic_bool & has_executor = node_ptr->get_associated_with_executor_atomic(); if (has_executor.exchange(true)) { - throw std::runtime_error("Node has already been added to an executor."); + throw std::runtime_error( + std::string("Node (%s) has already been added to an executor.", node_ptr->get_name())); } std::lock_guard guard{mutex_}; for (auto & weak_group : node_ptr->get_callback_groups()) { From 4b072b4663f132977ed29d31994ddfdacef87865 Mon Sep 17 00:00:00 2001 From: Steve Macenski Date: Fri, 4 Jun 2021 10:34:08 -0700 Subject: [PATCH 2/3] changing get_name() to get_fully_qualified_name() + linting Signed-off-by: Steve Macenski --- rclcpp/src/rclcpp/executor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 3949ba47b6..31a466be5c 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -269,7 +269,9 @@ Executor::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_pt std::atomic_bool & has_executor = node_ptr->get_associated_with_executor_atomic(); if (has_executor.exchange(true)) { throw std::runtime_error( - std::string("Node (%s) has already been added to an executor.", node_ptr->get_name())); + std::string( + "Node (%s) has already been added to an executor.", + node_ptr->get_fully_qualified_name())); } std::lock_guard guard{mutex_}; for (auto & weak_group : node_ptr->get_callback_groups()) { From f037b97b26300b72e5d6e03ddbe0134388c05b13 Mon Sep 17 00:00:00 2001 From: Steve Macenski Date: Fri, 4 Jun 2021 16:34:38 -0700 Subject: [PATCH 3/3] changing print format for tests Signed-off-by: Steve Macenski --- rclcpp/src/rclcpp/executor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 31a466be5c..a69c89d735 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -269,9 +269,8 @@ Executor::add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_pt std::atomic_bool & has_executor = node_ptr->get_associated_with_executor_atomic(); if (has_executor.exchange(true)) { throw std::runtime_error( - std::string( - "Node (%s) has already been added to an executor.", - node_ptr->get_fully_qualified_name())); + std::string("Node '") + node_ptr->get_fully_qualified_name() + + "' has already been added to an executor."); } std::lock_guard guard{mutex_}; for (auto & weak_group : node_ptr->get_callback_groups()) {