Skip to content
Snippets Groups Projects
Commit d719479d authored by Scott K Logan's avatar Scott K Logan Committed by Carl Delsey
Browse files

Fixes for parameter declarations (#879)

Without these changes, I've been seeing lots of 'foo has already been
declared' errors.
parent da5360af
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,9 @@ public:
name_ = name;
costmap_ros_ = costmap_ros;
nh_ = nh;
nh_->declare_parameter(name_ + ".scale", rclcpp::ParameterValue(1.0));
if (!nh_->has_parameter(name_ + ".scale")) {
nh_->declare_parameter(name_ + ".scale", rclcpp::ParameterValue(1.0));
}
nh_->get_parameter(name_ + ".scale", scale_);
onInit();
}
......
......@@ -39,7 +39,9 @@ namespace dwb_critics
{
void TwirlingCritic::onInit()
{
nh_->declare_parameter(name_ + ".scale", rclcpp::ParameterValue(0.0));
if (!nh_->has_parameter(name_ + ".scale")) {
nh_->declare_parameter(name_ + ".scale", rclcpp::ParameterValue(0.0));
}
// Scale is set to 0 by default, so if it was not set otherwise, set to 0
nh_->get_parameter(name_ + ".scale", scale_);
......
......@@ -143,18 +143,15 @@ void moveParameter(
{
param_t value;
if (nh->get_parameter(current_name, value)) {
// TODO(crdelsey): What's the ROS 2 equivalent of deleteParam?
// if (should_delete)
// nh->deleteParam(old_name);
if (should_delete) {nh->undeclare_parameter(old_name);}
return;
}
if (nh->get_parameter(old_name, value)) {
// TODO(crdelsey): What's the ROS 2 equivalent of deleteParam?
// if (should_delete) nh->deleteParam(old_name);
if (should_delete) {nh->undeclare_parameter(old_name);}
} else {
value = default_value;
}
nh->set_parameters({rclcpp::Parameter(current_name, value)});
nh->set_parameter(rclcpp::Parameter(current_name, value));
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment