# Linear move while rotating?

**URL:** <https://forum.universal-robots.com/t/linear-move-while-rotating/25569>\
**Category:** General Application Help: How do I?\
**Tags:** speedl, tool\_frame, speed\_rotation\
**Created:** [December 9, 2022, 1:50pm UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569 "2022-12-09T13:50:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon33028421](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@anon33028421](https://forum.universal-robots.com/u/anon33028421)\
**Post date:** [December 9, 2022, 1:50pm UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569/1 "2022-12-09T13:50:37Z")

</div>

Hi, I am trying to do a linear move while also rotating the wrist of my UR3.  
I know you can’t use joint rotations on a MoveL so I was thinking that right before the MoveL I could have it set a variable to true so that a thread can detect the variable is true and then start spinning until the MoveL finishes and sets the variable back to false.

Problem is I cannot find a function to make the wrist rotate. Is there a better way to move linearly (for precision) and spin?  
I need to insert a piece into a hole while spinning it and apply force and being pretty precise on movement.  
I appreciate any help.

---

<div class="post-metadata">

**Author:** ![anon33028421](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@anon33028421](https://forum.universal-robots.com/u/anon33028421)\
**Post date:** [December 12, 2022, 12:13pm UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569/2 "2022-12-12T12:13:37Z")

</div>

Does anyone have any idea? I hope I provided enough information.

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [December 12, 2022, 1:28pm UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569/3 "2022-12-12T13:28:11Z")

</div>

Hi @anon33028421,

Welcome to the UR community. I am assuming that you would like to spin the wrist more than a full rotation during your movement?

In that case you can take a look at the _speedl()_ script function or alternatively the _path\_offset_ if you would like to seperate the linear movement and the rotation.

I hope that assist you your way to what you would like to achieve!

Best regards  
Ebbe

---

<div class="post-metadata">

**Author:** ![anon33028421](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@anon33028421](https://forum.universal-robots.com/u/anon33028421)\
**Post date:** [December 13, 2022, 3:26pm UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569/4 "2022-12-13T15:26:42Z")

</div>

Hello @Ebbe,

My coworker and I have been attempting to use Offset() and SpeedL() but they seems to be oriented around the base when we need it to be oriented around the TCP so that it will rotate.

We are looking to have wrist 3 rotate counter clockwise while having the TCP move on the Z axis. We were hoping to use the MoveL so that it would stick to the specified line.

Thanks  
-Jimmy

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [December 14, 2022, 8:24am UTC](https://forum.universal-robots.com/t/linear-move-while-rotating/25569/5 "2022-12-14T08:24:46Z")

</div>

Hi @anon33028421,

For the _path\_offset_ you can actually specify the type and thereby let it act in the tool frame.  
In the _speedl_ case you need to apply the math your self. Hopefully you can use this snippet as inspiration:

```auto
def rotate_speed_in_frame(frame, speed):
  local p_tcp = p[0,0,0, frame[3], frame[4], frame[5]]

  local speed_pos_p = p[speed[0], speed[1], speed[2], 0, 0, 0]
  local speed_rot_p = p[speed[3], speed[4], speed[5], 0, 0, 0]

  local trans = pose_trans(p_tcp, speed_pos_p)
  local rot = pose_trans(p_tcp, speed_rot_p)

  return [trans[0], trans[1], trans[2], rot[0], rot[1], rot[2]]
end

tool_speed = [0,0,0.1, 0,0,-6]
acceleration = 10
t = 2
base_speed = rotate_speed_in_frame(pose_inv(get_target_tcp_pose()), tool_speed )
speedl(base_speed, acceleration, t) 

```

Then you need to adjust _tool\_speed_, _acceleration_ and _t_ to your needs.

Feel free to ask if that did not answer your question.

Ebbe
