direct_torque(torque, viscous_scale=[0.9, 0.9, 0.8, 0.9, 0.9, 0.9], coulomb_scale=[0.8, 0.8, 0.7, 0.8, 0.8, 0.8])
Direct Joint Torque Control enables low-level torque control. Sets the target torque for all robot joints at 500Hz. This function must be called continuously at each robot time step; otherwise, the robot will return to position control mode. The function always compensates for gravity, meaning that the provided target torque should not include gravity compensation.
Based on feedback from the Direct Torque Control V1 feature released in versions 5.23 and 10.10, significant improvements have been made to friction and stiction compensation. Additionally, access to individually scale the viscous and Coulomb friction parameters for each joint is now available. This enhancement offers greater flexibility to adjust the settings according to specific needs.
Parameters
torque: List of target joint torques (Nm) to be commanded to the robot joints (length 6).
viscous_scale: (Optional) An array where you can define the scale of viscous compensation from the friction model, within the range [0-1]. If not provided, the default scale will be [0.9, 0.9, 0.8, 0.9, 0.9, 0.9].
coulomb_scale: (Optional) An array where you can define the scale of Coulomb compensation from the friction model, within the range [0-1]. If not provided, the default scale will be [0.8, 0.8, 0.7, 0.8, 0.8, 0.8].
Deprecated:
friction_comp: The old friction_comp argument is still functional and enables the previous friction model. However, if used, a message will be logged the first time a program utilizes this deprecated argument. It will be ignored if any of the new scale arguments (viscous_scale or coulomb_scale) are provided.
Notes:
- This function is an advanced low-level function, as it bypasses many of the compliance features, which means it needs to be used with care.
- You are responsible for keeping the robot within safety limits. If the robot violates these limits, it will result in a violation and the robot will stop.
- It uses one timestep regardless of speed scaling, similar to
sync(). - If not called every timestep, the robot will revert to position control mode.
get_target_joint_accelerations()will return zeros when usingdirect_torque(), as there is no commanded target acceleration in this mode. Please useget_actual_joint_accelerations()instead, as these values are derived from the encoders.- When returning to position control mode, the robot arm needs to receive a command indicating how to continue the movement or stop. This can be done, for example, by using
speedj()to continue moving orstopj()to make it stop. - It is recommended to run your control loop in URScript and receive targets or gains via RTDE, sockets, or ROS 2 (PolyScopeX only) to avoid communication delays.
Example command:
This example shows how to call direct_torque() and thereby go into torque control and back to position control mode and to a standstill after 10 seconds.
timer = 0.0
while timer < 10: # Run for 10 seconds
timer = timer + get_steptime()
tau = [0,0,0,0,0,0] # or any other torque values
direct_torque(tau)
end
stopj(10)
To use custom friction scaling:
direct_torque([0,0,0,0,0,0], viscous_scale=[0.8, 0.8, 0.7, 0.8, 0.8, 0.8], coulomb_scale=[0.7, 0.7, 0.6, 0.7, 0.7, 0.7])