@@ -59,6 +59,7 @@ CallbackReturn JointStateTopicSystem::on_init(const hardware_interface::Hardware
5959 joint_commands_.resize (standard_interfaces_.size ());
6060 joint_states_.resize (standard_interfaces_.size ());
6161 velocity_limits_.resize (get_hardware_info ().joints .size ());
62+ limited_velocity_commands_.resize (get_hardware_info ().joints .size ());
6263 nonlimited_velocity_commands_.resize (get_hardware_info ().joints .size ());
6364 for (auto i = 0u ; i < standard_interfaces_.size (); i++)
6465 {
@@ -155,7 +156,8 @@ CallbackReturn JointStateTopicSystem::on_configure(const rclcpp_lifecycle::State
155156{
156157 REGISTER_ROS2_CONTROL_INTROSPECTION (" nonlimited_left_wheel_velocity" , &nonlimited_velocity_commands_[0 ]);
157158 REGISTER_ROS2_CONTROL_INTROSPECTION (" nonlimited_right_wheel_velocity" , &nonlimited_velocity_commands_[1 ]);
158-
159+ REGISTER_ROS2_CONTROL_INTROSPECTION (" limited_left_wheel_velocity" , &limited_velocity_commands_[0 ]);
160+ REGISTER_ROS2_CONTROL_INTROSPECTION (" limited_right_wheel_velocity" , &limited_velocity_commands_[1 ]);
159161 return CallbackReturn::SUCCESS;
160162}
161163
@@ -285,14 +287,12 @@ hardware_interface::return_type JointStateTopicSystem::write(const rclcpp::Time&
285287 }
286288 else if (interface.name == hardware_interface::HW_IF_VELOCITY)
287289 {
290+ nonlimited_velocity_commands_[i] = joint_commands_[VELOCITY_INTERFACE_INDEX][i];
288291 if (enable_command_limiting_)
289292 {
290- // RCLCPP_WARN(get_node()->get_logger(),"Before clamp: %f",joint_commands_[VELOCITY_INTERFACE_INDEX][i]);
291- nonlimited_velocity_commands_[i] = joint_commands_[VELOCITY_INTERFACE_INDEX][i];
292- joint_commands_[VELOCITY_INTERFACE_INDEX][i] = std::clamp (nonlimited_velocity_commands_[i], velocity_limits_[i].min , velocity_limits_[i].max );
293- // RCLCPP_WARN(get_node()->get_logger(),"After clamp: %f",joint_commands_[VELOCITY_INTERFACE_INDEX][i]);
293+ limited_velocity_commands_[i] = std::clamp (nonlimited_velocity_commands_[i], velocity_limits_[i].min , velocity_limits_[i].max );
294294 }
295- joint_state.velocity .push_back (joint_commands_[VELOCITY_INTERFACE_INDEX] [i]);
295+ joint_state.velocity .push_back (limited_velocity_commands_ [i]);
296296 }
297297 else if (interface.name == hardware_interface::HW_IF_EFFORT)
298298 {
0 commit comments