Skip to content

Commit

Permalink
Fix #259 - ParameterAlreadyDeclaredException for parameter `positio…
Browse files Browse the repository at this point in the history
…n_proportional_gain` (#261)

(cherry picked from commit 2526653)
  • Loading branch information
roncapat authored and mergify[bot] committed Mar 28, 2024
1 parent cec39b6 commit 69e338a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ign_ros2_control/src/ign_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ bool IgnitionSystem::initSim(

constexpr double default_gain = 0.1;

this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter<double>(
"position_proportional_gain", default_gain);
try {
this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter<double>(
"position_proportional_gain", default_gain);
} catch (rclcpp::exceptions::ParameterAlreadyDeclaredException & ex) {
this->nh_->get_parameter(
"position_proportional_gain", this->dataPtr->position_proportional_gain_);
}

RCLCPP_INFO_STREAM(
this->nh_->get_logger(),
Expand Down

0 comments on commit 69e338a

Please sign in to comment.