From d372af400943e73491143fd0bbc2439a345dc8ef Mon Sep 17 00:00:00 2001
From: Patrick Roncagliolo <ronca.pat@gmail.com>
Date: Wed, 27 Mar 2024 15:05:47 +0100
Subject: [PATCH 1/2] 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<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) {
+    /* avoid redeclaration */
+  }
 
   RCLCPP_INFO_STREAM(
     this->nh_->get_logger(),

From d25e013402be165d36086f45891a6f19bc214e1e Mon Sep 17 00:00:00 2001
From: Patrick Roncagliolo <ronca.pat@gmail.com>
Date: Wed, 27 Mar 2024 18:23:35 +0100
Subject: [PATCH 2/2] Update gz_system.cpp

---
 gz_ros2_control/src/gz_system.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gz_ros2_control/src/gz_system.cpp b/gz_ros2_control/src/gz_system.cpp
index 51375fcb..231d1424 100644
--- a/gz_ros2_control/src/gz_system.cpp
+++ b/gz_ros2_control/src/gz_system.cpp
@@ -239,7 +239,8 @@ bool GazeboSimSystem::initSim(
     this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter<double>(
       "position_proportional_gain", default_gain);
   }  catch (rclcpp::exceptions::ParameterAlreadyDeclaredException & ex) {
-    /* avoid redeclaration */
+    this->nh_->get_parameter(
+      "position_proportional_gain", this->dataPtr->position_proportional_gain_);
   }
 
   RCLCPP_INFO_STREAM(