matrix_to_rpy

urdfpy.matrix_to_rpy(R, solution=1)[source]

Convert a 3x3 transform matrix to roll-pitch-yaw coordinates.

The roll-pitchRyaw axes in a typical URDF are defined as a rotation of r radians around the x-axis followed by a rotation of p radians around the y-axis followed by a rotation of y radians around the z-axis. These are the Z1-Y2-X3 Tait-Bryan angles. See Wikipedia for more information.

There are typically two possible roll-pitch-yaw coordinates that could have created a given rotation matrix. Specify solution=1 for the first one and solution=2 for the second one.

Parameters:
  • R ((3,3) float) – A 3x3 homogenous rotation matrix.
  • solution (int) – Either 1 or 2, indicating which solution to return.
Returns:

coords – The roll-pitch-yaw coordinates in order (x-rot, y-rot, z-rot).

Return type:

(3,) float