torchcontrol.transform package

Submodules

torchcontrol.transform.rotation module

class torchcontrol.transform.rotation.RotationObj(q: Tensor)

Bases: object

A scriptable rotation object used for storing & manipulating rotations in 3D space. The API is similar to that of scipy.spatial.transform.Rotation.

Rotation parameters are stored as quaternions due to:
  1. Efficient computational properties

  2. Compactness (compared to rotation matrices)

  3. Avoidance of gimbal lock (euler angles), ambiguity (axis-angle)

Quaternions follow the convention of <x, y, z, w>.

apply(v)

Applies the rotation to a vector

Parameters:

v – Input vector of shape (3,)

Returns:

Resulting vector of shape (3,)

as_matrix() Tensor
Returns:

Matrix representation of rotation

as_quat() Tensor
Returns:

Quaternion representation of rotation

as_rotvec() Tensor
Returns:

Rotation vector representation of rotation

axis() Tensor
Returns:

Axis of rotation

inv() RotationObj

Inverts the rotation

Returns:

Inverted RotationObj

magnitude() Tensor
Returns:

Magnitude of rotation

torchcontrol.transform.rotation.from_matrix(matrix: Tensor) RotationObj

Creates a rotation object from a rotation matrix

Parameters:

quat – Matrix representation

Returns:

Resulting RotationObj

torchcontrol.transform.rotation.from_quat(quat: Tensor) RotationObj

Creates a rotation object from a quaternion

Parameters:

quat – Quaternion representation

Returns:

Resulting RotationObj

torchcontrol.transform.rotation.from_rotvec(rotvec: Tensor) RotationObj

Creates a rotation object from a rotation vector

Parameters:

quat – Rotation vector representation

Returns:

Resulting RotationObj

torchcontrol.transform.rotation.identity() RotationObj

Creates a zero rotation object

Returns:

Identity RotationObj

torchcontrol.transform.rotation_conversions module

torchcontrol.transform.transformation module

class torchcontrol.transform.transformation.TransformationObj(rotation: RotationObj, translation: Tensor)

Bases: object

A scriptable transformation object used for storing & manipulating transformations in 3D space. A transformation consists of a translation and a rotation.

Quaternions follow the convention of <x, y, z, w>.

apply(v: Tensor)

Applies the transformation to a vector tf.apply(v) = tf.rotation().apply(v) + tf.translation

as_matrix() Tensor
Returns:

Matrix representation of transformation (4-by-4)

as_twist() Tensor
inv() TransformationObj

Inverts the transformation :returns: Inverted TransformationObj

rotation() RotationObj
Returns:

Rotation component as a RotationObj

translation() Tensor
Returns:

Translation component as a vector

torchcontrol.transform.transformation.from_matrix(T: Tensor) TransformationObj

Creates a translation object from a translation vector and a rotation object

Parameters:

T – Transformation matrix representation

Returns:

Resulting TranslationObj

torchcontrol.transform.transformation.from_rot_xyz(rotation: RotationObj, translation: Tensor) TransformationObj

Creates a translation object from a translation vector and a a rotation object

Parameters:
  • translation – Translation component as a vector

  • rotation – Rotation component as a RotationObj

Returns:

Resulting TranslationObj

torchcontrol.transform.transformation.identity() TransformationObj

Creates a zero transformation object

Returns:

Identity TransformationObject

Module contents