@@ -108,8 +108,8 @@ SpeedScalingStateBroadcaster::on_configure(const rclcpp_lifecycle::State& /*prev
108108 RCLCPP_INFO (get_node ()->get_logger (), " Publisher rate set to : %.1f Hz" , publish_rate_);
109109
110110 try {
111- speed_scaling_state_publisher_ =
112- get_node ()->create_publisher <std_msgs::msg::Float64>(" ~/speed_scaling" , rclcpp::SystemDefaultsQoS ());
111+ speed_scaling_state_publisher_ = std::make_shared<realtime_tools::RealtimePublisher<std_msgs::msg::Float64>>(
112+ get_node ()->create_publisher <std_msgs::msg::Float64>(" ~/speed_scaling" , rclcpp::SystemDefaultsQoS ())) ;
113113 } catch (const std::exception& e) {
114114 // get_node() may throw, logging raw here
115115 fprintf (stderr, " Exception thrown during init stage with message: %s \n " , e.what ());
@@ -138,11 +138,18 @@ controller_interface::return_type SpeedScalingStateBroadcaster::update(const rcl
138138 speed_scaling_state_msg_.data = state_interfaces_[0 ].get_optional ().value_or (1.0 ) * 100.0 ;
139139
140140 // publish
141- speed_scaling_state_publisher_->publish (speed_scaling_state_msg_);
141+ speed_scaling_state_publisher_->try_publish (speed_scaling_state_msg_);
142142 }
143143 return controller_interface::return_type::OK ;
144144}
145145
146+ controller_interface::CallbackReturn
147+ SpeedScalingStateBroadcaster::on_cleanup (const rclcpp_lifecycle::State& /* previous_state*/ )
148+ {
149+ speed_scaling_state_publisher_.reset ();
150+ return controller_interface::CallbackReturn::SUCCESS ;
151+ }
152+
146153} // namespace ur_controllers
147154
148155#include " pluginlib/class_list_macros.hpp"
0 commit comments