Transforms¶
Lie group interface for rigid transforms, ported from jaxlie. Used by Viser internally and in examples.
Implements SO(2), SO(3), SE(2), and SE(3) Lie groups. Rotations are parameterized via S^1 and S^3.
- class viser.transforms.MatrixLieGroup[source]¶
Bases:
ABCInterface definition for matrix Lie groups.
- classmethod __init_subclass__(matrix_dim: int = 0, parameters_dim: int = 0, tangent_dim: int = 0, space_dim: int = 0) None[source]¶
Set class properties for subclasses. We default to dummy values.
- __matmul__(other: Self) Self[source]¶
- __matmul__(other: NDArray[floating]) NDArray[floating]
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- abstract classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) Self[source]¶
Returns identity element.
- abstract classmethod from_matrix(matrix: NDArray[floating]) Self[source]¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- abstract as_matrix() NDArray[floating][source]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- abstract parameters() NDArray[floating][source]¶
Get underlying representation.
- Return type:
NDArray[floating]
- abstract apply(target: NDArray[floating]) NDArray[floating][source]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- abstract classmethod exp(tangent: NDArray[floating]) Self[source]¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- abstract log() NDArray[floating][source]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- abstract adjoint() NDArray[floating][source]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- abstract inverse() Self[source]¶
Computes the inverse of our transform.
- Returns:
Output.
- Return type:
- abstract normalize() Self[source]¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- class viser.transforms.SEBase[source]¶
Bases:
Generic[ContainedSOType],MatrixLieGroupBase class for special Euclidean groups.
Each SE(N) group member contains an SO(N) rotation, as well as an N-dimensional translation vector.
- abstract classmethod from_rotation_and_translation(rotation: ContainedSOType, translation: NDArray[floating]) Self[source]¶
Construct a rigid transform from a rotation and a translation.
- Parameters:
rotation (ContainedSOType) – Rotation term.
translation (NDArray[floating]) – translation term.
- Returns:
Constructed transformation.
- Return type:
- classmethod from_rotation(rotation: ContainedSOType) Self[source]¶
- Parameters:
rotation (ContainedSOType)
- Return type:
- classmethod from_translation(translation: NDArray[floating]) Self[source]¶
- Parameters:
translation (NDArray[floating])
- Return type:
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- abstract adjoint() NDArray[floating]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- abstract as_matrix() NDArray[floating]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- abstract classmethod exp(tangent: NDArray[floating]) Self¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- abstract classmethod from_matrix(matrix: NDArray[floating]) Self¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).
- abstract classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) Self¶
Returns identity element.
- abstract log() NDArray[floating]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- abstract parameters() NDArray[floating]¶
Get underlying representation.
- Return type:
NDArray[floating]
- abstract rotation() ContainedSOType[source]¶
Returns a transform’s rotation term.
- Return type:
ContainedSOType
- abstract classmethod sample_uniform(rng: ~numpy.random._generator.Generator, batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) Self¶
Draw a uniform sample from the group. Translations (if applicable) are in the range [-1, 1].
- abstract translation() NDArray[floating][source]¶
Returns a transform’s translation term.
- Return type:
NDArray[floating]
- apply(target: NDArray[floating]) NDArray[floating][source]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- class viser.transforms.SOBase[source]¶
Bases:
MatrixLieGroupBase class for special orthogonal groups.
- classmethod __init_subclass__(matrix_dim: int = 0, parameters_dim: int = 0, tangent_dim: int = 0, space_dim: int = 0) None¶
Set class properties for subclasses. We default to dummy values.
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- abstract adjoint() NDArray[floating]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- abstract apply(target: NDArray[floating]) NDArray[floating]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- abstract as_matrix() NDArray[floating]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- abstract classmethod exp(tangent: NDArray[floating]) Self¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- abstract classmethod from_matrix(matrix: NDArray[floating]) Self¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).
- abstract classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) Self¶
Returns identity element.
- abstract log() NDArray[floating]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- abstract normalize() Self¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- abstract parameters() NDArray[floating]¶
Get underlying representation.
- Return type:
NDArray[floating]
- class viser.transforms.SE2[source]¶
-
Special Euclidean group for proper rigid transforms in 2D. Broadcasting rules are the same as for numpy.
Ported to numpy from jaxlie.SE2.
Internal parameterization is (cos, sin, x, y). Tangent parameterization is (vx, vy, omega).
- unit_complex_xy: npt.NDArray[np.floating]¶
Internal parameters. (cos, sin, x, y). Shape should be (*, 4).
- static from_xy_theta(x: float | NDArray[floating], y: float | NDArray[floating], theta: float | NDArray[floating]) SE2[source]¶
Construct a transformation from standard 2D pose parameters.
This is not the same as integrating over a length-3 twist.
- classmethod from_rotation_and_translation(rotation: SO2, translation: NDArray[floating]) SE2[source]¶
Construct a rigid transform from a rotation and a translation.
- translation() NDArray[floating][source]¶
Returns a transform’s translation term.
- Return type:
NDArray[floating]
- classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) SE2[source]¶
Returns identity element.
- classmethod from_matrix(matrix: NDArray[floating]) SE2[source]¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- parameters() NDArray[floating][source]¶
Get underlying representation.
- Return type:
NDArray[floating]
- as_matrix() NDArray[floating][source]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- classmethod exp(tangent: NDArray[floating]) SE2[source]¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- log() NDArray[floating][source]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- adjoint() NDArray[floating][source]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Parameters:
self (SE2)
- Return type:
NDArray[floating]
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- apply(target: NDArray[floating]) NDArray[floating]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- classmethod from_rotation(rotation: ContainedSOType) Self¶
- Parameters:
rotation (ContainedSOType)
- Return type:
- classmethod from_translation(translation: NDArray[floating]) Self¶
- Parameters:
translation (NDArray[floating])
- Return type:
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).
- normalize() Self¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- class viser.transforms.SE3[source]¶
-
Special Euclidean group for proper rigid transforms in 3D. Broadcasting rules are the same as for numpy.
Ported to numpy from jaxlie.SE3.
Internal parameterization is (qw, qx, qy, qz, x, y, z). Tangent parameterization is (vx, vy, vz, omega_x, omega_y, omega_z).
- wxyz_xyz: npt.NDArray[np.floating]¶
Internal parameters. wxyz quaternion followed by xyz translation. Shape should be (*, 7).
- classmethod from_rotation_and_translation(rotation: SO3, translation: NDArray[floating]) SE3[source]¶
Construct a rigid transform from a rotation and a translation.
- translation() NDArray[floating][source]¶
Returns a transform’s translation term.
- Return type:
NDArray[floating]
- classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) SE3[source]¶
Returns identity element.
- classmethod from_matrix(matrix: NDArray[floating]) SE3[source]¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- as_matrix() NDArray[floating][source]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- parameters() NDArray[floating][source]¶
Get underlying representation.
- Return type:
NDArray[floating]
- classmethod exp(tangent: NDArray[floating]) SE3[source]¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- log() NDArray[floating][source]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- adjoint() NDArray[floating][source]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- apply(target: NDArray[floating]) NDArray[floating]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- classmethod from_rotation(rotation: ContainedSOType) Self¶
- Parameters:
rotation (ContainedSOType)
- Return type:
- classmethod from_translation(translation: NDArray[floating]) Self¶
- Parameters:
translation (NDArray[floating])
- Return type:
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).
- normalize() Self¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- class viser.transforms.SO2[source]¶
Bases:
SOBaseSpecial orthogonal group for 2D rotations. Broadcasting rules are the same as for numpy.
Ported to numpy from jaxlie.SO2.
Internal parameterization is (cos, sin). Tangent parameterization is (omega,).
- unit_complex: npt.NDArray[np.floating]¶
Internal parameters. (cos, sin). Shape should be (*, 2).
- static from_radians(theta: float | NDArray[floating]) SO2[source]¶
Construct a rotation object from a scalar angle.
- as_radians() NDArray[floating][source]¶
Compute a scalar angle from a rotation object.
- Return type:
NDArray[floating]
- classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) SO2[source]¶
Returns identity element.
- classmethod from_matrix(matrix: NDArray[floating]) SO2[source]¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- as_matrix() NDArray[floating][source]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- parameters() NDArray[floating][source]¶
Get underlying representation.
- Return type:
NDArray[floating]
- apply(target: NDArray[floating]) NDArray[floating][source]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- classmethod exp(tangent: NDArray[floating]) SO2[source]¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- log() NDArray[floating][source]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- adjoint() NDArray[floating][source]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- normalize() SO2[source]¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- classmethod __init_subclass__(matrix_dim: int = 0, parameters_dim: int = 0, tangent_dim: int = 0, space_dim: int = 0) None¶
Set class properties for subclasses. We default to dummy values.
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).
- class viser.transforms.SO3[source]¶
Bases:
SOBaseSpecial orthogonal group for 3D rotations. Broadcasting rules are the same as for numpy.
Ported to numpy from jaxlie.SO3.
Internal parameterization is (qw, qx, qy, qz). Tangent parameterization is (omega_x, omega_y, omega_z).
- wxyz: onpt.NDArray[onp.floating]¶
Internal parameters. (w, x, y, z) quaternion. Shape should be (*, 4).
- static from_rpy_radians(roll: float | NDArray[floating], pitch: float | NDArray[floating], yaw: float | NDArray[floating]) SO3[source]¶
Generates a transform from a set of Euler angles. Uses the ZYX mobile robot convention.
- static from_quaternion_xyzw(xyzw: NDArray[floating]) SO3[source]¶
Construct a rotation from an xyzw quaternion.
Note that wxyz quaternions can be constructed using the default dataclass constructor.
- Parameters:
xyzw (NDArray[floating]) – xyzw quaternion. Shape should be
(*, 4).- Returns:
Output.
- Return type:
- as_quaternion_xyzw() NDArray[floating][source]¶
Grab parameters as xyzw quaternion.
- Return type:
NDArray[floating]
- as_rpy_radians() RollPitchYaw[source]¶
Computes roll, pitch, and yaw angles. Uses the ZYX mobile robot convention.
- Returns:
NamedTuple containing Euler angles in radians.
- Return type:
RollPitchYaw
- compute_roll_radians() NDArray[floating][source]¶
Compute roll angle. Uses the ZYX mobile robot convention.
- Returns:
Euler angle in radians.
- Return type:
NDArray[floating]
- compute_pitch_radians() NDArray[floating][source]¶
Compute pitch angle. Uses the ZYX mobile robot convention.
- Returns:
Euler angle in radians.
- Return type:
NDArray[floating]
- compute_yaw_radians() NDArray[floating][source]¶
Compute yaw angle. Uses the ZYX mobile robot convention.
- Returns:
Euler angle in radians.
- Return type:
NDArray[floating]
- classmethod identity(batch_axes: ~typing.Tuple[int, ...] = (), dtype: DTypeLike = <class 'numpy.float64'>) SO3[source]¶
Returns identity element.
- classmethod from_matrix(matrix: NDArray[floating]) SO3[source]¶
Get group member from matrix representation.
- Parameters:
matrix (NDArray[floating]) – Matrix representaiton.
- Returns:
Group member.
- Return type:
- as_matrix() NDArray[floating][source]¶
Get transformation as a matrix. Homogeneous for SE groups.
- Return type:
NDArray[floating]
- parameters() NDArray[floating][source]¶
Get underlying representation.
- Return type:
NDArray[floating]
- apply(target: NDArray[floating]) NDArray[floating][source]¶
Applies group action to a point.
- Parameters:
target (NDArray[floating]) – Point to transform.
- Returns:
Transformed point.
- Return type:
NDArray[floating]
- classmethod exp(tangent: NDArray[floating]) SO3[source]¶
Computes expm(wedge(tangent)).
- Parameters:
tangent (NDArray[floating]) – Tangent vector to take the exponential of.
- Returns:
Output.
- Return type:
- log() NDArray[floating][source]¶
Computes vee(logm(transformation matrix)).
- Returns:
Output. Shape should be (tangent_dim,).
- Return type:
NDArray[floating]
- adjoint() NDArray[floating][source]¶
Computes the adjoint, which transforms tangent vectors between tangent spaces.
More precisely, for a transform GroupType:
` GroupType @ exp(omega) = exp(Adj_T @ omega) @ GroupType `In robotics, typically used for transforming twists, wrenches, and Jacobians across different reference frames.
- Returns:
Output. Shape should be (tangent_dim, tangent_dim).
- Return type:
NDArray[floating]
- normalize() SO3[source]¶
Normalize/projects values and returns.
- Returns:
Normalized group member.
- Return type:
- classmethod __init_subclass__(matrix_dim: int = 0, parameters_dim: int = 0, tangent_dim: int = 0, space_dim: int = 0) None¶
Set class properties for subclasses. We default to dummy values.
- __matmul__(other: Self | NDArray[floating]) Self | NDArray[floating]¶
Overload for the @ operator.
Switches between the group action (.apply()) and multiplication (.multiply()) based on the type of other.
- get_batch_axes() Tuple[int, ...]¶
Return any leading batch axes in contained parameters. If an array of shape (100, 4) is placed in the wxyz field of an SO3 object, for example, this will return (100,).