direct_torque(torques, friction_comp=True)
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. Friction compensation is enabled by default, but can be disabled by setting friction_comp=False.
Parameters
torques: List of target joint torques (Nm) to be commanded to the robot joints (length 6).
friction_comp: (Optional) Enable internal friction compensation. Default is True.
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.
To disable friction compensation:
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 disable friction compensation:
direct_torque([0,0,0,0,0,0], friction_comp=False)