From d095f869c105aff20bba326fbc4d90f259ad299f Mon Sep 17 00:00:00 2001 From: YueErro Date: Tue, 10 Oct 2023 11:17:21 +0200 Subject: [PATCH] fix: Create ParamListener and get params on configure IMUSensorBroadcaster --- .../src/imu_sensor_broadcaster.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/imu_sensor_broadcaster/src/imu_sensor_broadcaster.cpp b/imu_sensor_broadcaster/src/imu_sensor_broadcaster.cpp index 04a28e5368..4a08349190 100644 --- a/imu_sensor_broadcaster/src/imu_sensor_broadcaster.cpp +++ b/imu_sensor_broadcaster/src/imu_sensor_broadcaster.cpp @@ -24,6 +24,12 @@ namespace imu_sensor_broadcaster { controller_interface::CallbackReturn IMUSensorBroadcaster::on_init() +{ + return CallbackReturn::SUCCESS; +} + +controller_interface::CallbackReturn IMUSensorBroadcaster::on_configure( + const rclcpp_lifecycle::State & /*previous_state*/) { try { @@ -33,18 +39,10 @@ controller_interface::CallbackReturn IMUSensorBroadcaster::on_init() catch (const std::exception & e) { RCLCPP_ERROR( - get_node()->get_logger(), "Exception thrown during init stage with message: %s \n", e.what()); + get_node()->get_logger(), "Exception thrown during configure stage with message: %s \n", e.what()); return CallbackReturn::ERROR; } - return CallbackReturn::SUCCESS; -} - -controller_interface::CallbackReturn IMUSensorBroadcaster::on_configure( - const rclcpp_lifecycle::State & /*previous_state*/) -{ - params_ = param_listener_->get_params(); - imu_sensor_ = std::make_unique( semantic_components::IMUSensor(params_.sensor_name)); try