Skip to content

Commit

Permalink
[ForceTorqueSensorBroadcaster] Create ParamListener and get parameter…
Browse files Browse the repository at this point in the history
…s on configure (backport #698) (#750)

* [ForceTorqueSensorBroadcaster] Create ParamListener and get parameters on configure (#698)

* Create ParamListener and get parameters on configure

* Declare parameters for test_force_torque_sensor_broadcaster

Since the parameters are not declared on init anymore, they cannot be
set without declaring them before

---------

Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
(cherry picked from commit 32aaef7)

* Fix "parameter is already declared" error

---------

Co-authored-by: Noel Jiménez García <noel.jimenez@pal-robotics.com>
Co-authored-by: Christoph Froehlich <christoph.froehlich@ait.ac.at>
  • Loading branch information
3 people committed Dec 5, 2023
1 parent 13ba381 commit 2916b79
Showing 1 changed file with 7 additions and 9 deletions.
Expand Up @@ -29,6 +29,12 @@ ForceTorqueSensorBroadcaster::ForceTorqueSensorBroadcaster()
}

controller_interface::CallbackReturn ForceTorqueSensorBroadcaster::on_init()
{
return controller_interface::CallbackReturn::SUCCESS;
}

controller_interface::CallbackReturn ForceTorqueSensorBroadcaster::on_configure(
const rclcpp_lifecycle::State & /*previous_state*/)
{
try
{
Expand All @@ -37,18 +43,10 @@ controller_interface::CallbackReturn ForceTorqueSensorBroadcaster::on_init()
}
catch (const std::exception & e)
{
fprintf(stderr, "Exception thrown during init stage with message: %s \n", e.what());
fprintf(stderr, "Exception thrown during configure stage with message: %s \n", e.what());
return controller_interface::CallbackReturn::ERROR;
}

return controller_interface::CallbackReturn::SUCCESS;
}

controller_interface::CallbackReturn ForceTorqueSensorBroadcaster::on_configure(
const rclcpp_lifecycle::State & /*previous_state*/)
{
params_ = param_listener_->get_params();

const bool no_interface_names_defined =
params_.interface_names.force.x.empty() && params_.interface_names.force.y.empty() &&
params_.interface_names.force.z.empty() && params_.interface_names.torque.x.empty() &&
Expand Down

0 comments on commit 2916b79

Please sign in to comment.