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` (backport #261) (#262)

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
Co-authored-by: Patrick Roncagliolo <ronca.pat@gmail.com>
Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent cec39b6 commit f724da5
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 f724da5

Please sign in to comment.