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) (#263)

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 01b8af1 commit 1cee33d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gz_ros2_control/src/gz_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,13 @@ bool GazeboSimSystem::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 1cee33d

Please sign in to comment.