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)
  • Loading branch information
roncapat authored Mar 28, 2024
1 parent a105607 commit 2526653
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 @@ -235,8 +235,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 2526653

Please sign in to comment.