Skip to main content
A rigid transform that maps coordinates in source_frame into target_frame. Direction: a transform is the pose of the source frame, measured in the target frame. Name it <source>_wrt_<target>: camera_wrt_base is Transform(..., source_frame="camera", target_frame="base"), the transform that Camera.getExtrinsics() returns as a 4x4 matrix. Its translation is the camera origin in base coordinates, and its rotation is the camera axes relative to the base axes. Math: a point p in the source frame maps to p' = R p + t in the target frame, where R is rotation and t is translation; with the 4x4 matrix M = to_matrix(), p' = M p. A Pose’s orientation q becomes q_T * q. inverse() has rotation R^-1 and translation -R^-1 t, and swaps the frames. transform.T is the transpose of the 4x4 matrix, as in NumPy, for points stored as rows: points @ transform.T. The transpose is not the inverse; use inverse(). Order: A @ B composes in matrix order, so B applies first; read a chain from right to left. At each @, the right side must map into the frame that the left side maps from: A.source_frame == B.target_frame. Frame checks: T @ pose needs pose.frame_id == T.source_frame and returns a Pose with frame_id == T.target_frame. A @ B needs A.source_frame == B.target_frame. from_pose needs the pose in target_frame. A mismatch raises FrameMismatchError, a ValueError whose message names both frames. A Pose without a frame_id is taken to be in the source frame and is not checked. Frames are names that the caller supplies; nothing is inferred.

Fields

Position
The origin of the source frame in the target frame (meters).
Orientation
The orientation of the source frame in the target frame.
str
The frame that the transform maps from.
str
The frame that the transform maps to.

Constructor

Signature
Initialize a Transform from its translation, rotation and frames.
required
The origin of the source frame in the target frame (meters).
required
The orientation of the source frame in the target frame.
required
The frame that the transform maps from.
required
The frame that the transform maps to.

Properties

np.ndarray
The transpose of the 4x4 matrix, to_matrix().T, as in NumPy.Use it for points stored as rows: points @ transform.T maps an (N, 4) array of homogeneous points. It is not the inverse; use inverse.

Methods

apply()

Signature
Map a Pose from source_frame into target_frame; the same as self @ pose. A pose without a frame is taken to be in source_frame. The input pose does not change.
required
The pose to map.
Returns: Pose: The pose in target_frame, with frame_id set to target_frame. Raises: FrameMismatchError: If the pose has a frame and it is not source_frame.

compose()

Signature
Apply other first, then this transform; the same as self @ other.
required
A transform whose target frame is this transform’s source frame.
Returns: Transform: The transform from other.source_frame into self.target_frame. Raises: FrameMismatchError: If other.target_frame is not self.source_frame.

from_dict()

Signature
Deserialize from {"translation", "rotation", "source_frame", "target_frame"}

from_matrix()

Signature
Build a transform from a 4x4 homogeneous matrix.
required
4x4 rigid transform; the bottom row must be [0, 0, 0, 1].
required
The frame that the matrix maps from.
required
The frame that the matrix maps to.
Returns: Transform: The transform with the matrix’s rotation and translation. Raises: ValueError: If the matrix is not 4x4, its bottom row is wrong, or its rotation part is not a rotation.

from_pose()

Signature
Build the transform of a frame whose origin and orientation are pose.
required
The pose of the source frame in the target frame.
required
The frame located at pose.
required
The frame that pose is in.
Returns: Transform: The transform from source_frame into target_frame. Raises: FrameMismatchError: If the pose has a frame and it is not target_frame.

identity()

Signature
The transform that maps frame onto itself and changes no coordinates.
required
The source and target frame.
Returns: Transform: The identity transform in frame.

inverse()

Signature
The transform in the opposite direction, from target_frame into source_frame. Returns: Transform: The inverse transform, with the frames swapped.

to_dict()

Signature
Serialize for JSON transfer: {"translation", "rotation", "source_frame", "target_frame"}

to_matrix()

Signature
Convert to a 4x4 homogeneous matrix. Returns: np.ndarray: 4x4 matrix that maps source-frame coordinates into the target frame.

Example