# Rotate TCP in Rx direction only

**URL:** <https://forum.universal-robots.com/t/rotate-tcp-in-rx-direction-only/35398>\
**Category:** URScript\
**Created:** [July 24, 2024, 1:42am UTC](https://forum.universal-robots.com/t/rotate-tcp-in-rx-direction-only/35398 "2024-07-24T01:42:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![d.verhofstadt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/d.verhofstadt/32/1466_2.png) [@d.verhofstadt](https://forum.universal-robots.com/u/d.verhofstadt)\
**Post date:** [July 26, 2024, 7:42am UTC](https://forum.universal-robots.com/t/rotate-tcp-in-rx-direction-only/35398/5 "2024-07-26T07:42:46Z")

</div>

Hi @francis

If you want to program just a rotation, you have to keep in mind that the last 3 elements in the pose array are of a rotation vector type. We cannot, or at least very difficultly, interpret this. When we want a rotation, we think in the “RPY” type.

This means that, if you want a rotation of 179deg around your y-axis of your chosen TCP (your Y-axis points outward of the tool flange), then you can accomplish this by doing these steps:

1. A rotation of 179deg, transform it to radians:  
rot\_rad\_rpy = [0, d2r(179), 0]

2. This “rot\_rad\_rpy” as we interpret is, is of the type “RPY”. So we need to transform it “Rotation vector”:  
rot\_rad\_rotvec = rpy2rotvec(rot\_rad\_rpy)

3. At this point, we have a rotation, of the type “rotation vector”. Now all that is left, is to tell the robot to use this rotation around your TCP, which you already did correctly in your code:  
new\_pose = pose\_trans ( get\_actual\_tcp\_pose(), p[0, 0, 0, rot\_rad\_rotvec[0], rot\_rad\_rotvec [1], rot\_rad\_rotvec[2] ] )

When you try this, you will see that the robot will turn correctly.  
Keep in mind that this is a rotation around your TCP Y-axis. If you kept the TCP as default (so Z pointing outward), then in the first step you would need to do: rot\_rad\_rpy = [0, 0, d2r(179)]

If you have any questions, feel free to contact me.

Kind regards  
Dieter

---

_[View the full topic](https://forum.universal-robots.com/t/rotate-tcp-in-rx-direction-only/35398)._
