From d372af400943e73491143fd0bbc2439a345dc8ef Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Wed, 27 Mar 2024 15:05:47 +0100 Subject: [PATCH] Fix #259 --- gz_ros2_control/src/gz_system.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gz_ros2_control/src/gz_system.cpp b/gz_ros2_control/src/gz_system.cpp index 87b085ff..51375fcb 100644 --- a/gz_ros2_control/src/gz_system.cpp +++ b/gz_ros2_control/src/gz_system.cpp @@ -235,8 +235,12 @@ bool GazeboSimSystem::initSim( constexpr double default_gain = 0.1; - this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter( - "position_proportional_gain", default_gain); + try { + this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter( + "position_proportional_gain", default_gain); + } catch (rclcpp::exceptions::ParameterAlreadyDeclaredException & ex) { + /* avoid redeclaration */ + } RCLCPP_INFO_STREAM( this->nh_->get_logger(),