Skip to content

Commit 499c85f

Browse files
Felix ExnerRobertWilbrandt
authored andcommitted
Do not advertise speed scaling service unless only position interface is
used The current implementation only works correctly when a position interface is used. When the hardware in fact slows down the robot (as UR does), also velocity interfaces should be scaled correctly, but that't rather an edge case right now.
1 parent 2e28e92 commit 499c85f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,15 +910,28 @@ controller_interface::CallbackReturn JointTrajectoryController::on_configure(
910910
std::string(get_node()->get_name()) + "/query_state",
911911
std::bind(&JointTrajectoryController::query_state_service, this, _1, _2));
912912

913-
set_scaling_factor_srv_ = get_node()->create_service<control_msgs::srv::SetScalingFactor>(
914-
"~/set_scaling_factor", std::bind(
915-
&JointTrajectoryController::set_scaling_factor, this,
916-
std::placeholders::_1, std::placeholders::_2));
913+
if (
914+
!has_velocity_command_interface_ && !has_acceleration_command_interface_ &&
915+
!has_effort_command_interface_)
916+
{
917+
set_scaling_factor_srv_ = get_node()->create_service<control_msgs::srv::SetScalingFactor>(
918+
"~/set_scaling_factor", std::bind(
919+
&JointTrajectoryController::set_scaling_factor, this,
920+
std::placeholders::_1, std::placeholders::_2));
921+
RCLCPP_INFO(
922+
logger, "Setting initial scaling factor to %2f", params_.scaling_factor_initial_default);
923+
scaling_factor_rt_buff_.writeFromNonRT(params_.scaling_factor_initial_default);
924+
}
925+
else
926+
{
927+
RCLCPP_WARN(
928+
logger,
929+
"Speed scaling is currently only supported for position interfaces. If you want to make use "
930+
"of speed scaling, please only use a position interface when configuring this controller.");
931+
scaling_factor_rt_buff_.writeFromNonRT(1.0);
932+
}
917933

918934
// set scaling factor to low value default
919-
RCLCPP_INFO(
920-
logger, "Setting initial scaling factor to %2f", params_.scaling_factor_initial_default);
921-
scaling_factor_rt_buff_.writeFromNonRT(params_.scaling_factor_initial_default);
922935

923936
return CallbackReturn::SUCCESS;
924937
}

0 commit comments

Comments
 (0)