Convert position types
Convert the orientation of a UR pose between rotation vector, roll pitch yaw, 4x4 transform and quaternion with the Pose class.
The class Pose holds a Cartesian position of a Universal Robots cobot, and converts its orientation between the formats used by robots and vision systems. This page lists the conversions. They run on the PC, without a robot.
The Pose class
A Pose has 6 values, as in URScript: X, Y, Z in meters, then RX, RY, RZ, a rotation vector in radians. RxDegrees, RyDegrees and RzDegrees give the rotation in degrees: they are computed from RX, RY, RZ, not stored.
The SDK returns a Pose for the positions of the robot (RTDE ActualTcpPose, Primary Interface CartesianInfo.AsPose()), and accepts one as the answer of an XML-RPC call.
Conversions
| From | To | Method |
|---|---|---|
| Rotation vector | Roll, pitch, yaw | FromRotationVectorToRPY() |
| Roll, pitch, yaw | Rotation vector | FromRPYToRotationVector() |
| Rotation vector | 4x4 transform | FromRotationVectorTo4x4Matrix() |
| Roll, pitch, yaw | 4x4 transform | FromRPYTo4x4Matrix() |
| 4x4 transform | Rotation vector | Pose.From4x4MatrixToRotationVector(matrix) |
| 4x4 transform | Roll, pitch, yaw | Pose.From4x4MatrixToRPY(matrix) |
| Rotation vector | Quaternion | FromRotationVectorToQuaternion(out x, out y, out z, out w) |
| Quaternion | Rotation vector | Pose.FromQuaternionToRotationVector(x, y, z, w) |
Text p[x, y, z, rx, ry, rz] | Pose | Pose.TryParse(text, out pose) |
The roll, pitch and yaw are stored in RX, RY and RZ of the returned Pose. The X, Y, Z do not change.
static void Main(string[] args){// X, Y, Z in meters, then a rotation vector RX, RY, RZ in radiansvar pose = new Pose(0.4, -0.1, 0.3, 0, 3.14, 0);// Rotation in degrees, computed from RX, RY, RZdouble rxDegrees = pose.RxDegrees;// Same position, rotation as roll, pitch, yawPose rpy = pose.FromRotationVectorToRPY();// And back to a rotation vectorPose rotationVector = rpy.FromRPYToRotationVector();// 4x4 homogeneous transformsdouble[,] matrix = pose.FromRotationVectorTo4x4Matrix();Pose fromMatrix = Pose.From4x4MatrixToRotationVector(matrix);// Quaternionpose.FromRotationVectorToQuaternion(out double qx, out double qy, out double qz, out double qw);Pose fromQuaternion = Pose.FromQuaternionToRotationVector(qx, qy, qz, qw);// Text of the form "p[0.4, -0.1, 0.3, 0, 3.14, 0]"bool ok = Pose.TryParse("p[0.4, -0.1, 0.3, 0, 3.14, 0]", out Pose parsed);}}
In Python, FromRotationVectorToQuaternion and TryParse are not usable: they have out parameters.
Try it in the demo application
Everything on this page can be tried without writing code, in the Convert position types page of the demo application.

The demo application is open source. The C# source of this page is ToolsControl.cs.
Reference
Represents a UR pose
| Member | Type | Description |
|---|---|---|
Pose() Constructor | Creates a new pose with all coordinates set to zero. | |
Pose(double, double, double) Constructor | Creates a new pose with the specified translation and zero rotation.
| |
Pose(double, double, double, double, double, double) Constructor | Creates a new pose with the specified translation and rotation.
| |
Pose(Pose) Constructor | Creates a new pose by copying values from another pose.
| |
RxDegrees Property | double | RX rotation in degrees or °/s |
RyDegrees Property | double | RY rotation in degrees or °/s |
RzDegrees Property | double | RZ rotation in degrees or °/s |
From4x4MatrixToRPY(double[,]) Method static | Pose | Convert a transformation 4x4 matrix to RPY pose |
From4x4MatrixToRotationVector(double[,]) Method static | Pose | Convert a transformation 4x4 matrix to rotation vector |
FromQuaternionToRotationVector(double, double, double, double) Method static | Pose | Converts a quaternion to UR rotation vector |
FromRPYTo4x4Matrix() Method | double[,] | Consider this pose as a RPY (Roll-Pitch-Yaw) representation and return a 4x4 homogeneous transformation matrix. |
FromRPYToRotationVector() Method | Pose | Consider this pose as RPY And convert it to a new Rotation Vector |
FromRotationVectorTo4x4Matrix() Method | double[,] | Consider this pose as a rotation vector and return a 4x4 homogeneous transformation matrix. |
FromRotationVectorToQuaternion(out double, out double, out double, out double) Method | void | Converts a rotation vector to quaternion |
FromRotationVectorToRPY() Method | Pose | Consider this pose as a Rotation Vector And convert it to a new RPY position |
ToString() Method | string | Returns 6 comma separated coordinated with G1 format |
TryParse(string, out Pose) Method static | bool | Parse a pose from its string representation
|
What to read next
- Kinematics: from joint positions to a pose, and back.
- Get the robot position.