From d1d76037483f512b07ee98cb3b2383eb4361f483 Mon Sep 17 00:00:00 2001 From: Joshua Wallace Date: Thu, 15 Jun 2023 21:27:33 -0400 Subject: [PATCH 1/4] correct error message --- .../bt_action_server_impl.hpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp index 11110b09c2c..3f54ca67d07 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp @@ -16,6 +16,7 @@ #define NAV2_BEHAVIOR_TREE__BT_ACTION_SERVER_IMPL_HPP_ #include +#include #include #include #include @@ -67,16 +68,22 @@ BtActionServer::BtActionServer( }; if (!node->has_parameter("error_code_names")) { - std::string error_codes_str; - for (const auto & error_code : error_code_names) { - error_codes_str += error_code + "\n"; - } - RCLCPP_WARN_STREAM( - logger_, "Error_code parameters were not set. Using default values of: " - << error_codes_str - << "Make sure these match your BT and there are not other sources of error codes you want " - "reported to your application"); + + const rclcpp::ParameterValue value = node->declare_parameter( + "error_code_names", + rclcpp::PARAMETER_STRING_ARRAY); + if (value.get_type() == rclcpp::PARAMETER_NOT_SET) { + std::string error_codes_str; + for (const auto & error_code : error_code_names) { + error_codes_str += error_code + "\n"; + } + RCLCPP_WARN_STREAM( + logger_, "Error_code parameters were not set. Using default values of: " + << error_codes_str + << "Make sure these match your BT and there are not other sources of error codes you" + "reported to your application"); node->declare_parameter("error_code_names", error_code_names); + } } } From e88b8dd47645fd7cff24edcfeb4469a940f9a520 Mon Sep 17 00:00:00 2001 From: Joshua Wallace Date: Sat, 17 Jun 2023 15:21:26 -0400 Subject: [PATCH 2/4] clean up --- .../include/nav2_behavior_tree/bt_action_server_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp index 3f54ca67d07..f56b1286035 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp @@ -75,11 +75,11 @@ BtActionServer::BtActionServer( if (value.get_type() == rclcpp::PARAMETER_NOT_SET) { std::string error_codes_str; for (const auto & error_code : error_code_names) { - error_codes_str += error_code + "\n"; + error_codes_str += "\n" + error_code; } RCLCPP_WARN_STREAM( logger_, "Error_code parameters were not set. Using default values of: " - << error_codes_str + << error_codes_str + "\n" << "Make sure these match your BT and there are not other sources of error codes you" "reported to your application"); node->declare_parameter("error_code_names", error_code_names); From 369f5fb6c6e7ffd48e42590d641ff50f1fc91418 Mon Sep 17 00:00:00 2001 From: Joshua Wallace Date: Sat, 17 Jun 2023 15:41:45 -0400 Subject: [PATCH 3/4] cleanup --- .../include/nav2_behavior_tree/bt_action_server_impl.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp index f56b1286035..828a0bbf352 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp @@ -16,6 +16,7 @@ #define NAV2_BEHAVIOR_TREE__BT_ACTION_SERVER_IMPL_HPP_ #include +#include #include #include #include @@ -68,9 +69,8 @@ BtActionServer::BtActionServer( }; if (!node->has_parameter("error_code_names")) { - const rclcpp::ParameterValue value = node->declare_parameter( - "error_code_names", + "error_code_names", rclcpp::PARAMETER_STRING_ARRAY); if (value.get_type() == rclcpp::PARAMETER_NOT_SET) { std::string error_codes_str; @@ -78,11 +78,12 @@ BtActionServer::BtActionServer( error_codes_str += "\n" + error_code; } RCLCPP_WARN_STREAM( - logger_, "Error_code parameters were not set. Using default values of: " + logger_, "Error_code parameters were not set. Using default values of: " << error_codes_str + "\n" << "Make sure these match your BT and there are not other sources of error codes you" "reported to your application"); - node->declare_parameter("error_code_names", error_code_names); + rclcpp::Parameter error_code_names_param("error_code_names", error_code_names); + node->set_parameter(error_code_names_param); } } } From 70e3515c13b1eec95d1c44d4e00b759172f26b84 Mon Sep 17 00:00:00 2001 From: Joshua Wallace Date: Sun, 18 Jun 2023 13:54:23 -0400 Subject: [PATCH 4/4] remove header --- .../include/nav2_behavior_tree/bt_action_server_impl.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp index 828a0bbf352..c23c4198ac9 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp @@ -16,8 +16,6 @@ #define NAV2_BEHAVIOR_TREE__BT_ACTION_SERVER_IMPL_HPP_ #include -#include -#include #include #include #include