ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange

# joint orientation (rotation)

Hello.

It looks like the joint rotation is given with the roll, pitch and yaw in this order:

And too bad, the document of the robot I'm working on is in the ypr order. And moreover, this last oder looks more common, as I found a lot of documentation based on this convention.

How to convert ypr to rpy?

Why has it been changed for ROS? Am I the only one to be disturbed by this?

Thanks in advance for the support.

edit retag close merge delete

Sort by ยป oldest newest most voted

Is your documentation using a fixed axis or rotating axis (extrinsic or intrinsic rotation?)

The URDF documentation is using a fixed axis rotation. This is described in more detail here: REP 103

Also, here: Rotation Methods (ROS)

If your documentation is using rotating axis (intrinsic rotation) there is no problem as ypr on a rotating axis is same as rpy on a fixed axis.

Otherwise:

The easiest way might to convert rotations between Euler angles is to use an intermediate representation like a quaternion.

In ROS if you are using Python, you can use the transformations.py module mentioned here (with a link to the full source): transformations.py

Example Python session using this (first way is with quaternions, second with matrices):

\$ python
Python 2.7.3 (default, Jul  5 2013, 08:52:38)
[GCC 4.6.3] on linux2
>>> import transformations
>>> import math
>>> q=transformations.quaternion_from_euler(math.pi,0,0,'szyx')
>>> q
array([  0.00000000e+00,  -0.00000000e+00,   1.00000000e+00,
6.12303177e-17])
>>> transformations.euler_from_quaternion(q,'sxyz')
(0.0, -0.0, 3.141592653589793)
>>> m=transformations.euler_matrix(math.pi,0,0,'szyx')
>>> m
array([[ -1.00000000e+00,  -1.22460635e-16,  -0.00000000e+00,
0.00000000e+00],
[  1.22460635e-16,  -1.00000000e+00,   0.00000000e+00,
0.00000000e+00],
[ -0.00000000e+00,   0.00000000e+00,   1.00000000e+00,
0.00000000e+00],
[  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
1.00000000e+00]])
>>> transformations.euler_from_matrix(m,'sxyz')
(0.0, 0.0, 3.141592653589793)

more

Note that fixed axis rotation can mean in general about any axis, but in the ROS documentation I linked to it is referring to 3 rotations around fixed axes x y and z ('sxyz' in transformations.py). This should be the same as 'rzyx' in transformations.py).

( 2013-09-29 23:38:01 -0600 )edit

Hello.

Thanks to you, I have understood a couple of things that I did not get during the readings:

• extrinsic rotations are independent (that's what I have seen with a couple of example and that was only an assumption)
• the yrp notation does not imply extrinsic or intrinsic, I understood that it was always extrinsic, but that was wrong

Thanks also for the python tools. I use python a lot, so this is really helpful.

So I had a fresh look at the documentation and the description is given using intrinsic rotations and that explain why I was not able to use the values directly in ROS. I should be able to manage it now.

more

Arno, I am unsure what you mean by independent. You should see that m=transformations.euler_matrix(0,math.pi,math.pi,'sxyz') is the same as m2=transformations.euler_matrix(math.pi,0,0,'sxyz') for example (try m2[numpy.abs(m2)<0.001]=0 and m[numpy.abs(m)<0.001]=0 to clean them up).