Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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')