From a563414aba52c603deeab5c7b19b0b89dc789749 Mon Sep 17 00:00:00 2001 From: Graziato Davide <85335579+Fixit-Davide@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:57:42 +0100 Subject: [PATCH] Fix #247 --- gz_ros2_control/src/gz_system.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gz_ros2_control/src/gz_system.cpp b/gz_ros2_control/src/gz_system.cpp index a60a4eb3..87b085ff 100644 --- a/gz_ros2_control/src/gz_system.cpp +++ b/gz_ros2_control/src/gz_system.cpp @@ -234,15 +234,14 @@ bool GazeboSimSystem::initSim( this->dataPtr->joints_.resize(this->dataPtr->n_dof_); constexpr double default_gain = 0.1; - if (!this->nh_->get_parameter_or( - "position_proportional_gain", - this->dataPtr->position_proportional_gain_, default_gain)) - { - RCLCPP_WARN_STREAM( - this->nh_->get_logger(), - "The position_proportional_gain parameter was not defined, defaulting to: " << - default_gain); - } + + this->dataPtr->position_proportional_gain_ = this->nh_->declare_parameter( + "position_proportional_gain", default_gain); + + RCLCPP_INFO_STREAM( + this->nh_->get_logger(), + "The position_proportional_gain has been set to: " << + this->dataPtr->position_proportional_gain_); if (this->dataPtr->n_dof_ == 0) { RCLCPP_ERROR_STREAM(this->nh_->get_logger(), "There is no joint available");