# Euler angle convention in TF [closed]

http://www.ros.org/wiki/geometry/CoordinateFrameConventions

It says Euler angles are specified in yaw-pitch-roll (ZYX) format in ROS. However, the tf.transformations.quaternion_from_euler function seems to assume roll-pitch-yaw (XYZ) format, as on this page:

http://ros.org/wiki/tf/Overview/Transformations

Doesn't this violate the convention, or am I missing something?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Jeffrey Kane Johnson close date 2013-02-04 03:46:22

Sort by ยป oldest newest most voted

tf uses the Python transformation package written by Christoph Gohlke (see http://www.lfd.uci.edu/~gohlke/). This package supports any definition of Euler angles. Simply pass the desired convention as a second parameter to quaternion_from_euler:

def quaternion_from_euler(ai, aj, ak, axes='sxyz'):
"""Return quaternion from Euler angles and axis sequence.

ai, aj, ak : Euler's roll, pitch and yaw angles
axes : One of 24 axis sequences as string or encoded tuple

>>> q = quaternion_from_euler(1, 2, 3, 'ryxz')
>>> numpy.allclose(q, [0.310622, -0.718287, 0.444435, 0.435953])
True

"""


And from the documentation in the header of transformations.py:

"""
A triple of Euler angles can be applied/interpreted in 24 ways, which can
be specified using a 4 character string or encoded 4-tuple:

*Axes 4-string*: e.g. 'sxyz' or 'ryxy'

- first character : rotations are applied to 's'tatic or 'r'otating frame
- remaining characters : successive rotation axis 'x', 'y', or 'z'
"""


I suppose the tf maintainers didn't want to modify the underlying (external) python library to change the default behaviour.

So to comply with the ROS convention for Euler angles, simply use quaternion_from_euler like this:

q = tf.transformations.quaternion_from_euler(yaw, pitch, roll, 'rzyx')

more