Convert between quaternions and roll, pitch, yaw using ROS conventions, and copy the matching tf2 command or code.
Free
Runs in your browser
No sign-up
Euler angles (roll, pitch, yaw)
In degrees. ROS order: fixed-axis X, then Y, then Z (REP 103).
Quaternion (x, y, z, w)
Same order as geometry_msgs/Quaternion. Edit either side and the other updates.
Pitch is at or near ±90° (gimbal lock): roll and yaw turn about the same axis here, so many roll/yaw pairs describe this orientation. At exactly ±90° the converter reports yaw = 0 and puts the whole turn into roll.
Rotated frame
Coloured arrows: rotated axes (X red, Y green, Z blue). Dashed grey: original frame. Drag to orbit.
Quaternion
Same rotation (−q)
Roll, pitch, yaw
In radians
Axis–angle
Rotation matrix
Copy into your project
Static transform (quaternion)
Static transform (roll, pitch, yaw)
URDF fixed joint
geometry_msgs orientation (YAML)
Python, tf_transformations
Python, SciPy
C++, tf2
Advertisement
How to use the converter
Type angles or a quaternion. Edit roll, pitch and yaw (in degrees or radians), or paste the four quaternion numbers from a message or a log. The other side updates as you type.
Check the picture. The coloured arrows show where the rotated frame's axes point. If a camera "looking forward" shows its blue Z arrow pointing up, the rotation is not what you meant.
Copy the result. Set the parent and child frame names, then copy a ready-made static_transform_publisher command, a URDF joint, or code for Python and C++.
The convention this tool uses
ROS defines its axes in REP 103: X forward, Y left, Z up for a robot body, angles positive counter-clockwise by the right-hand rule. Roll, pitch and yaw are rotations about X, Y and Z, applied about the fixed axes in the order X, then Y, then Z. That is the same as yaw first, then pitch, then roll about the moving axes, and gives the rotation matrix:
This matches tf2::Quaternion::setRPY, tf_transformations.quaternion_from_euler, URDF rpy attributes and SciPy's lowercase 'xyz' sequence. We check the converter against SciPy and tf_transformations on thousands of random orientations; they agree to about 10−13 radians.
Three things that trip people up
Component order. ROS messages store x, y, z, w. Eigen's constructor, many textbooks and some libraries take w first. Mixing them up gives a completely different rotation without any error message.
q and −q are the same rotation. If two tools give quaternions with every sign flipped, both are right. Compare rotations, not raw numbers.
Degrees vs radians. ROS APIs, URDF and static_transform_publisher use radians. Entering 90 where 1.5708 was expected rotates by about 5157°, which wraps to 117°.
Camera images use a different frame (REP 103 "optical" frame: Z forward, X right, Y down). The Optical frame example above gives the rotation from a body frame to an optical frame: roll −90°, yaw −90°.
Frequently asked questions
What order are x, y, z, w in?
ROS messages such as geometry_msgs/Quaternion store x, y, z first and w last. Some libraries (Eigen's constructor, many maths texts) put w first, so check before copying numbers.
What rotation order does ROS use for roll, pitch, yaw?
Roll about the fixed X axis, then pitch about the fixed Y axis, then yaw about the fixed Z axis. That is the same as yaw, then pitch, then roll about the moving axes.
Why do I get a different but equivalent answer?
q and -q describe the same rotation, and near pitch = ±90° (gimbal lock) many roll/yaw pairs give the same orientation. The converter shows the standard solution.
My quaternion is not normalised. Is that a problem?
A rotation quaternion must have length 1. The converter normalises it for you and warns you, because an unnormalised quaternion in a message usually means a bug upstream.
Guides for this tool
In-depth articles that explain the ideas behind the Quaternion ↔ Euler Converter, with worked examples.