Overview
Provides the NamedPose class for representing named rigid body transformations between labeled coordinate frames, backed by Se2 or Se3 Lie group representations.
Description
The pose.py module in the Kornia geometry library defines the NamedPose class, which wraps an Se2 or Se3 Lie group transformation with named source and destination frame labels. This enables safe composition of transforms between frames by verifying that the destination frame of one pose matches the source frame of the other before multiplication. The class supports construction from rotation and translation components (So2/So3/Quaternion/Tensor + translation), from a 3x3 or 4x4 homogeneous matrix, pose inversion (which swaps the frame labels), pose composition via the * operator, and point transformation from source to destination frame. Frame names default to unique UUIDs if not explicitly provided.
Usage
Import the NamedPose class when building multi-frame pose graphs (e.g., for robotics, SLAM, or multi-camera systems) where you need type-safe composition of transformations between named coordinate frames with automatic frame consistency checking.
Code Reference
Source Location
Signature
def check_matrix_shape(matrix: torch.Tensor, matrix_type: str = "R") -> None
class NamedPose:
def __init__(
self,
dst_from_src: Se2 | Se3,
frame_src: str | None = None,
frame_dst: str | None = None,
) -> None
def __mul__(self, other: NamedPose) -> NamedPose
@property
def pose(self) -> Se2 | Se3
@property
def rotation(self) -> So3 | So2
@property
def translation(self) -> torch.Tensor
@property
def frame_src(self) -> str
@property
def frame_dst(self) -> str
@classmethod
def from_rt(
cls,
rotation: So3 | So2 | torch.Tensor | Quaternion,
translation: torch.Tensor,
frame_src: str | None = None,
frame_dst: str | None = None,
) -> NamedPose | None
@classmethod
def from_matrix(
cls,
matrix: torch.Tensor,
frame_src: str | None = None,
frame_dst: str | None = None,
) -> NamedPose | None
def inverse(self) -> NamedPose
def transform_points(self, points_in_src: torch.Tensor) -> torch.Tensor
Import
from kornia.geometry.pose import NamedPose
I/O Contract
Inputs (NamedPose.__init__)
| Name |
Type |
Required |
Description
|
| dst_from_src |
Se2 or Se3 |
Yes |
Rigid body transformation from source frame to destination frame
|
| frame_src |
str or None |
No |
Name of the source coordinate frame. Default: auto-generated UUID
|
| frame_dst |
str or None |
No |
Name of the destination coordinate frame. Default: auto-generated UUID
|
Outputs (NamedPose.transform_points)
| Name |
Type |
Description
|
| points_in_dst |
torch.Tensor |
Points transformed from source frame to destination frame
|
Inputs (NamedPose.from_rt)
| Name |
Type |
Required |
Description
|
| rotation |
So3, So2, torch.Tensor, or Quaternion |
Yes |
Rotation component of the pose
|
| translation |
torch.Tensor |
Yes |
Translation component of the pose
|
| frame_src |
str or None |
No |
Source frame name
|
| frame_dst |
str or None |
No |
Destination frame name
|
Outputs (NamedPose.from_rt)
| Name |
Type |
Description
|
| pose |
NamedPose or None |
Constructed NamedPose, or None if matrix dimension is unsupported
|
Usage Examples
import torch
from kornia.geometry.liegroup import Se3, So3
from kornia.geometry.pose import NamedPose
# Create an identity pose between two frames
b_from_a = NamedPose(Se3.identity(), frame_src="frame_a", frame_dst="frame_b")
# Create from rotation and translation
rot = So3.identity()
trans = torch.tensor([1., 2., 3.])
b_from_a = NamedPose.from_rt(rot, trans, frame_src="frame_a", frame_dst="frame_b")
# Create from a 4x4 matrix
mat = Se3.identity().matrix()
b_from_a = NamedPose.from_matrix(mat, frame_src="frame_a", frame_dst="frame_b")
# Compose two poses (frame consistency is checked)
c_from_b = NamedPose(Se3.identity(), frame_src="frame_b", frame_dst="frame_c")
c_from_a = c_from_b * b_from_a
# c_from_a: frame_a -> frame_c
# Invert a pose
a_from_b = b_from_a.inverse()
# a_from_b: frame_b -> frame_a
# Transform points from source to destination
points_a = torch.tensor([1., 2., 3.])
points_b = b_from_a.transform_points(points_a)
Related Pages