@@ -176,12 +176,8 @@ ImuFilterMadgwickRos::ImuFilterMadgwickRos(const rclcpp::NodeOptions &options)
176176 mag_bias_.y , mag_bias_.z );
177177
178178 // **** register dynamic reconfigure
179- parameters_client_ = std::make_shared<rclcpp::AsyncParametersClient>(
180- this ->get_node_base_interface (), this ->get_node_topics_interface (),
181- this ->get_node_graph_interface (), this ->get_node_services_interface ());
182-
183- parameter_event_sub_ = parameters_client_->on_parameter_event (
184- std::bind (&ImuFilterMadgwickRos::reconfigCallback, this , _1));
179+ post_set_parameters_callback_handle_ =
180+ this ->add_post_set_parameters_callback (std::bind (&ImuFilterMadgwickRos::postSetParametersCallback, this , std::placeholders::_1));
185181
186182 // **** register publishers
187183 imu_publisher_ = create_publisher<sensor_msgs::msg::Imu>(" imu/data" , 5 );
@@ -498,42 +494,39 @@ void ImuFilterMadgwickRos::publishRawMsg(const rclcpp::Time &t, float roll,
498494 rpy_raw_debug_publisher_->publish (rpy);
499495}
500496
501- void ImuFilterMadgwickRos::reconfigCallback (
502- const rcl_interfaces::msg::ParameterEvent::SharedPtr event )
497+ void ImuFilterMadgwickRos::postSetParametersCallback (
498+ const std::vector<rclcpp::Parameter>& parameters )
503499{
504- double gain, zeta;
505500 std::lock_guard<std::mutex> lock (mutex_);
506501
507- for (auto & changed_parameter : event-> changed_parameters )
502+ for (const auto & changed_parameter : parameters )
508503 {
509- const auto &type = changed_parameter.value . type ;
510- const auto &name = changed_parameter.name ;
511- const auto &value = changed_parameter.value ;
504+ const auto &type = changed_parameter.get_type () ;
505+ const auto &name = changed_parameter.get_name () ;
506+ const auto &value = changed_parameter.get_value < double >() ;
512507
513508 if (type == ParameterType::PARAMETER_DOUBLE)
514509 {
515510 RCLCPP_INFO (get_logger (), " Parameter %s set to %f" , name.c_str (),
516- value. double_value );
511+ value);
517512 if (name == " gain" )
518513 {
519- gain = value.double_value ;
520- filter_.setAlgorithmGain (gain);
514+ filter_.setAlgorithmGain (value);
521515 } else if (name == " zeta" )
522516 {
523- zeta = value.double_value ;
524- filter_.setDriftBiasGain (zeta);
517+ filter_.setDriftBiasGain (value);
525518 } else if (name == " mag_bias_x" )
526519 {
527- mag_bias_.x = value. double_value ;
520+ mag_bias_.x = value;
528521 } else if (name == " mag_bias_y" )
529522 {
530- mag_bias_.y = value. double_value ;
523+ mag_bias_.y = value;
531524 } else if (name == " mag_bias_z" )
532525 {
533- mag_bias_.z = value. double_value ;
526+ mag_bias_.z = value;
534527 } else if (name == " orientation_stddev" )
535528 {
536- double orientation_stddev = value. double_value ;
529+ double orientation_stddev = value;
537530 orientation_variance_ = orientation_stddev * orientation_stddev;
538531 }
539532 }
0 commit comments