# SpeedL in tool frame

**URL:** <https://forum.universal-robots.com/t/speedl-in-tool-frame/7590>\
**Category:** URScript\
**Created:** [June 8, 2020, 11:28am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590 "2020-06-08T11:28:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![minava](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@minava](https://forum.universal-robots.com/u/minava)\
**Post date:** [June 8, 2020, 11:28am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/1 "2020-06-08T11:28:08Z")

</div>

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.

 ![wrtTool](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/f/fb0d5ae607f73cdfb408b97d367871f703b8454d.png)

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

---

<div class="post-metadata">

**Author:** ![anon62734967](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon62734967](https://forum.universal-robots.com/u/anon62734967)\
**Post date:** [June 8, 2020, 12:09pm UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/2 "2020-06-08T12:09:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anon60084398](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon60084398](https://forum.universal-robots.com/u/anon60084398)\
**Post date:** [December 14, 2021, 7:41am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/3 "2021-12-14T07:41:03Z")

</div>

Hi @anon62734967

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

---

<div class="post-metadata">

**Author:** ![anon62734967](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon62734967](https://forum.universal-robots.com/u/anon62734967)\
**Post date:** [December 15, 2021, 11:50am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/4 "2021-12-15T11:50:56Z")

</div>

Hi @anon60084398  
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

---

<div class="post-metadata">

**Author:** ![anon60084398](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon60084398](https://forum.universal-robots.com/u/anon60084398)\
**Post date:** [December 16, 2021, 7:14am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/5 "2021-12-16T07:14:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![minava](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@minava](https://forum.universal-robots.com/u/minava)\
**Post date:** [December 25, 2021, 6:31pm UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/6 "2021-12-25T18:31:05Z")

</div>

Hi @anon60084398 ,

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.

---

<div class="post-metadata">

**Author:** ![anon60084398](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon60084398](https://forum.universal-robots.com/u/anon60084398)\
**Post date:** [December 27, 2021, 1:53am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/7 "2021-12-27T01:53:51Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Rune](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@Rune](https://forum.universal-robots.com/u/Rune)\
**Post date:** [August 5, 2022, 6:58am UTC](https://forum.universal-robots.com/t/speedl-in-tool-frame/7590/8 "2022-08-05T06:58:34Z")

</div>

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:

```auto
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

```
