# Determined turning direction when moving TCP around 180°

**URL:** <https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071>\
**Category:** Technical Questions\
**Created:** [June 5, 2018, 9:45am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071 "2018-06-05T09:45:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 5, 2018, 9:45am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/1 "2018-06-05T09:45:32Z")

</div>

Hello,

is there a way to get a determimed rotation direction if I want to turn the TCP about 180° degree.  
Code could look like this:  
ptcp = get\_actual\_tcp\_pose()  
movel(pose\_trans(ptcp,p[0,0,0,0,0,d2r(180)]),rAcc,rVel,r=0)

Sometimes the robot turns left, sometimes the robot turns right.

Is there a possibility to get a detemined direction ?  
My workaround is to split the movement in pieces so the robot is forced to turn in my preferred direction. The downside is, that the robot stops at each of the split movements.

Code could looks something like that  
ptcp = get\_actual\_tcp\_pose()  
movel(pose\_trans(ptcp,p[0,0,0,0,0,d2r(90)]),rAcc,rVel,r=0)  
movel(pose\_trans(ptcp,p[0,0,0,0,0,d2r(180)]),rAcc,rVel,r=0)

Blending the movements doesn´t work because the position of the TCP is always the same and the blending algorithm doesn´t consider the orientation of the TCP.

Any ideas about another solution or an additional workaround for the blending ?

Thank you  
Best Regards,  
Alexander Apostolidis

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [June 8, 2018, 12:09pm UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/2 "2018-06-08T12:09:22Z")

</div>

movel chooses the shortest path between current pose, and target pose.  
Would it be feasible for you application to rotate 179 or 181 degrees?

---

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 11, 2018, 5:57am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/3 "2018-06-11T05:57:12Z")

</div>

Hello,

thank you for your answer.  
Perhaps I can try something like 179,999 instead of 180. This should also be shorter.

Independendly of this it would be great if you could give the robot the preferred direction as user input, but I See the problem that you than need 1 input for each joint, what wouldnt be user friendly.

So perhaps you know a better way to bend the rotation movements ? Am I right with my assumption, that the blending algorith does not consider TCP orientation, only TCP Position ? Is there a workaround to get a movement without stop ?

Thank you,  
Alexander Apostolidis

---

<div class="post-metadata">

**Author:** ![lcs](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@lcs](https://forum.universal-robots.com/u/lcs)\
**Post date:** [June 11, 2018, 6:46am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/4 "2018-06-11T06:46:11Z")

</div>

If your TCP is only translated along the z-axis, then you could consider just using the PTP motions instead and add the wanted rotation yourself to the current configuration of your robot.  
Otherwise you can always use the invkin solver to find the configuration it will want to go to and use it to check if it rotates “the correct way” according to your need.

---

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 11, 2018, 7:20am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/5 "2018-06-11T07:20:07Z")

</div>

> [@lcs](#):
>
> PTP motions

Hi lcs, thanky for your reply.

How can I rotate a single axis ? I dont know an command that does this.

Your second point: Looking at the target joint-positions and decide if it was the right direction ? That would of course work to prevent a turning in the “wrong” direction but how would I achieve the turning in the “right” direction?

Regards,  
Alexander

---

<div class="post-metadata">

**Author:** ![lcs](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@lcs](https://forum.universal-robots.com/u/lcs)\
**Post date:** [June 11, 2018, 7:44am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/6 "2018-06-11T07:44:22Z")

</div>

1. would roughly look like this:  
config = get\_actual\_joint\_positions()  
config[5] = config[5] + 6.28 # + or - depending on direction # number in bracket depends on joint number  
movej(config, a, v, t, r) # replace a,v,r,t with your values  
NOTE: You should make sure that the joint limits are not exceeded after modifying the config

see the pdf “The URScript Programming Language” from the download page

1. 

you can iteratively reduce the angle a little from 180 until you find a rotation that yields a configuration that turns your desired direction.  
but the above is a lot easier in many cases.

---

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 11, 2018, 8:11am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/7 "2018-06-11T08:11:11Z")

</div>

> [@lcs](#):
>
> would roughly look like this:

Thanks for the code. Ok, I understand. This will work.

By your reply I noticed that it is better to save positions as joint-positions instead of poses (x,y,z,rx,ry,rz) because poses are not well-defined regarding joint positions, what was/is one weakpoint of my program at the moment! Really helpful. Thanks for this thought-provoking impulse ans sharing your experience.

regards,  
Alexander

---

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 11, 2018, 11:30am UTC](https://forum.universal-robots.com/t/determined-turning-direction-when-moving-tcp-around-180/2071/8 "2018-06-11T11:30:55Z")

</div>

I did a short test to show the difference between Pose and Joint Positions: Pics attached

Calculation of values  
 ![poseJointPos](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/347476a1f74ede94c4cf084494899623df257c5e.PNG)

Values  
 ![poseJointPos2](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/2c219110e985fe880fd1e26fae717ea42519c3f6.PNG)

Regards,  
Alexander
