Skip to content

Pose to Transformation Matrix

SUMMARY

pose_to_transformation_matrix converts a 6-element (deg/rad/rotvec) or 7-element (quat) pose into a 4x4 homogeneous transformation matrix.

UNITS

The pose's position component is in meters. Rotation is in degrees ("deg"), radians ("rad"/"rotvec"), or unitless ("quat"). The returned transformation matrix's translation is in meters.

The Skill

python
from telekinesis.tf import tfutils

T = tfutils.pose_to_transformation_matrix([0, 0, 1, 0, 0, 90], rot_type="deg")

Parameter Configuration

ParameterTypeDefaultDescription
poselist | np.ndarrayrequiredA 6-element [x, y, z, rx, ry, rz] pose ("deg"/"rad"/"rotvec"), or a 7-element [x, y, z, qw, qx, qy, qz] pose ("quat").
rot_typestr"deg"One of "deg", "rad", "quat", "rotvec".

Returns

TypeDescription
np.ndarrayThe corresponding (4, 4) transformation matrix.

Raises

ExceptionCondition
ValueErrorpose is not a list or np.ndarray.
TypeErrorrot_type is not a string.
ValueErrorrot_type is not one of "deg", "rad", "quat", "rotvec".
ValueErrorpose has 6 elements but rot_type="quat", or 7 elements but rot_type is not "quat".
ValueErrorpose has a size other than 6 or 7.