skrobot.coordinates.math.ypr2matrix

skrobot.coordinates.math.ypr2matrix(yaw, pitch, roll)[source]

Create rotation matrix from yaw, pitch, roll angles.

This is a clearly named wrapper around rpy_matrix that explicitly indicates the parameter order. The rotation is applied in Z-Y-X order (yaw around Z, then pitch around Y, then roll around X).

Parameters:
  • yaw (float) – Rotation around Z-axis in radians

  • pitch (float) – Rotation around Y-axis in radians

  • roll (float) – Rotation around X-axis in radians

Returns:

matrix – 3x3 rotation matrix

Return type:

numpy.ndarray

Examples

>>> import numpy as np
>>> from skrobot.coordinates.math import ypr2matrix, matrix2ypr
>>> yaw, pitch, roll = np.pi/6, np.pi/4, np.pi/3
>>> rot = ypr2matrix(yaw, pitch, roll)
>>> recovered = matrix2ypr(rot)
>>> np.allclose(recovered, [yaw, pitch, roll])
True

# Compare with rpy_matrix (which has same parameter order) >>> from skrobot.coordinates.math import rpy_matrix >>> rot_old = rpy_matrix(yaw, pitch, roll) >>> np.allclose(rot, rot_old) True