Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,7 @@ BtActionServer<ActionT, NodeT>::BtActionServer(
logger_ = node->get_logger();
clock_ = node->get_clock();

// Declare this node's parameters
if (!node->has_parameter("bt_loop_duration")) {
node->declare_parameter("bt_loop_duration", 10);
}
if (!node->has_parameter("default_server_timeout")) {
node->declare_parameter("default_server_timeout", 20);
}
if (!node->has_parameter("always_reload_bt_xml")) {
node->declare_parameter("always_reload_bt_xml", false);
}
if (!node->has_parameter("wait_for_service_timeout")) {
node->declare_parameter("wait_for_service_timeout", 1000);
}

std::vector<std::string> error_code_name_prefixes = {
std::vector<std::string> default_error_code_name_prefixes = {
"assisted_teleop",
"backup",
"compute_path",
Expand All @@ -95,32 +81,26 @@ BtActionServer<ActionT, NodeT>::BtActionServer(
" Please review migration guide and update your configuration.");
}

if (!node->has_parameter("error_code_name_prefixes")) {
const rclcpp::ParameterValue value = node->declare_parameter(
"error_code_name_prefixes",
rclcpp::PARAMETER_STRING_ARRAY);
if (value.get_type() == rclcpp::PARAMETER_NOT_SET) {
std::string error_code_name_prefixes_str;
for (const auto & error_code_name_prefix : error_code_name_prefixes) {
error_code_name_prefixes_str += " " + error_code_name_prefix;
}
RCLCPP_WARN_STREAM(
logger_, "error_code_name_prefixes parameters were not set. Using default values of:"
<< error_code_name_prefixes_str + "\n"
<< "Make sure these match your BT and there are not other sources of error codes you"
"reported to your application");
rclcpp::Parameter error_code_name_prefixes_param("error_code_name_prefixes",
error_code_name_prefixes);
node->set_parameter(error_code_name_prefixes_param);
} else {
error_code_name_prefixes = value.get<std::vector<std::string>>();
std::string error_code_name_prefixes_str;
for (const auto & error_code_name_prefix : error_code_name_prefixes) {
error_code_name_prefixes_str += " " + error_code_name_prefix;
}
RCLCPP_INFO_STREAM(logger_, "Error_code parameters were set to:"
<< error_code_name_prefixes_str);
}
// Declare and get error code name prefixes parameter
error_code_name_prefixes_ = node->declare_or_get_parameter(
"error_code_name_prefixes",
default_error_code_name_prefixes);

// Provide informative logging about error code prefixes
std::string error_code_name_prefixes_str;
for (const auto & error_code_name_prefix : error_code_name_prefixes_) {
error_code_name_prefixes_str += " " + error_code_name_prefix;
}

if (error_code_name_prefixes_ == default_error_code_name_prefixes) {
RCLCPP_WARN_STREAM(
logger_, "error_code_name_prefixes parameters were not set. Using default values of:"
<< error_code_name_prefixes_str + "\n"
<< "Make sure these match your BT and there are not other sources of error codes you"
<< "reported to your application");
} else {
RCLCPP_INFO_STREAM(logger_, "Error_code parameters were set to:"
<< error_code_name_prefixes_str);
}
}

Expand Down Expand Up @@ -170,16 +150,17 @@ bool BtActionServer<ActionT, NodeT>::on_configure()
nullptr, std::chrono::milliseconds(500), false);

// Get parameters for BT timeouts
int bt_loop_duration;
node->get_parameter("bt_loop_duration", bt_loop_duration);
bt_loop_duration_ = std::chrono::milliseconds(bt_loop_duration);
int default_server_timeout;
node->get_parameter("default_server_timeout", default_server_timeout);
default_server_timeout_ = std::chrono::milliseconds(default_server_timeout);
int wait_for_service_timeout;
node->get_parameter("wait_for_service_timeout", wait_for_service_timeout);
wait_for_service_timeout_ = std::chrono::milliseconds(wait_for_service_timeout);
node->get_parameter("always_reload_bt_xml", always_reload_bt_);
bt_loop_duration_ = std::chrono::milliseconds(
node->declare_or_get_parameter("bt_loop_duration", 10));

default_server_timeout_ = std::chrono::milliseconds(
node->declare_or_get_parameter("default_server_timeout", 20));

wait_for_service_timeout_ = std::chrono::milliseconds(
node->declare_or_get_parameter("wait_for_service_timeout", 1000));

always_reload_bt_ = node->declare_or_get_parameter(
"always_reload_bt_xml", false);

// Get error code id names to grab off of the blackboard
error_code_name_prefixes_ = node->get_parameter("error_code_name_prefixes").as_string_array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ void GoalReachedCondition::initialize()
{
node_ = config().blackboard->get<nav2::LifecycleNode::SharedPtr>("node");

nav2::declare_parameter_if_not_declared(
node_, "goal_reached_tol",
rclcpp::ParameterValue(0.25));
node_->get_parameter_or<double>("goal_reached_tol", goal_reached_tol_, 0.25);
goal_reached_tol_ = node_->declare_or_get_parameter("goal_reached_tol", 0.25);
tf_ = config().blackboard->get<std::shared_ptr<tf2_ros::Buffer>>("tf_buffer");

node_->get_parameter("transform_tolerance", transform_tolerance_);
Expand Down
Loading