SpeedL in tool frame

Dear UR Community,

when I go inside the move tab (UR5e) and select “Tool” as Feature, I can accelerate in a direction with respect to the tool by pressing the buttons.

Is there a way to do this via URScript? With speedl the robot accelerates with respect to the base frame. But I am looking for something like speedl but with respect to the tool frame.

Thanks

Hi @minava

You can transform the coordinate system of the tool, and then use speedl with that speed vector.
In this example we created a parameter that is suitable for moving the robot along the tool Z axis when approaching the workpiece from above:

def MakeToolSpeedZ():
dir = get_actual_tcp_pose()
dir = p[0,0,0,dir[3],dir[4],dir[5]]
sp =pose_trans(dir, p[0,0,1,0,0,0])
tsp = [sp[0], sp[1], sp[2], 0, 0, 0]
return tsp
end

I hope this helps.

1 Like

Hi @csaba

I have test the speedl move in the tool Frame. The move of X Y Z on the tool Frame is correct. but the rotation of the RX RY RZ doesn’t correct.

Below is my program, could you tell me if it have some mistakes?

  • this can move in the X dirction along the tool Frame

def test_move():
v_speed=p[1,0,0,0,0,0] *the X speed of the tool
dir=get_actual_tcp_pose()
RT=p[0,0,0,dir[3],dir[4],dir[5]]
sp =pose_trans(RT,v_speed])
move_speed=[sp[0], sp[1], sp[2], 0, 0, 0]
speedl(move_speed,0.5,0.1)
end

  • However this program cant rotate the Rz dirction along the tool frame.

def test_rotation():
v_speed=p[0,0,0,0,0,1] *the Rz speed of the tool
dir=get_actual_tcp_pose()
RT=p[0,0,0,dir[3],dir[4],dir[5]]
sp =pose_trans(RT,v_speed])
move_speed=[0,0,0,sp[0], sp[1], sp[2]]
speedl(move_speed,0.5,0.1)
end

Hi @1175665020
Have you tried move_speed=[0,0,0,sp[3], sp[4], sp[5]] instead of using [0], [1], and [2]?
It may work as expected, but I haven’t tested it.
Best regards,
Csaba

Hi @csaba
Sorry for the type wrong. I have tested on the below program, but it show the same error which the rotation doesn’t correct.

def test_rotation():
v_speed=p[0,0,0,0,0,1] *the Rz speed of the tool
dir=get_actual_tcp_pose()
RT=p[0,0,0,dir[3],dir[4],dir[5]]
sp =pose_trans(RT,v_speed])
move_speed=[0,0,0,sp[3], sp[4], sp[5]]
speedl(move_speed,0.5,0.1)
end

Hi @1175665020 ,

I’m the original poster of this thread. It’s over a year ago but I remember that pose_trans isn’t sufficient for this task. Instead of this you need to use wrench_trans as in the following example:

global dir=get_actual_tcp_pose()
global rot=p[0,0,0,dir[3],dir[4],dir[5]]
global vec=wrench_trans(rot, p[1,0,0,0,0,0])
speedl(vec,a=5,v=1,t=0.002)

So I think replacing pose_trans with wrench_trans should solve the problem.

Hi @minava ,

it is ok now. Thank you.

The below program is modified which is move along the RZ of TCP frame.

global dir=get_actual_tcp_pose()
global rot=p[0,0,0,dir[3],dir[4],dir[5]]
global vec=wrench_trans(rot, [0,0,0,0,0,1])
speedl(vec,1)

As @minava suggested, you can transform a velocity to another frame by using the screw transformation implemented in the wrench_trans() function. Please note that you have to shift the order of the rotation and translation velocity forth and back as it is the transitional velocity that gets scaled and to the rotational.

Example:

def vel_trans(t, v):
  vw = wrench_trans(t, [v[3], v[4], v[5], v[0], v[1], v[2]])
  return [vw[3], vw[4], vw[5], vw[0], vw[1], vw[2]]
end