pymomentum.skel_state
Handling of skeleton states, including converting to and from transform matrices.
A skeleton state is an (n x 8) tensor representing an array of transforms, where each transform is represented as a translation, rotation, and (uniform) scale. The 8 components are: (tx, ty, tz, rx, ry, rz, rw, s).
Skeleton states are used extensively in momentum to represent transforms from joint-local space to world space, hence the name. They are convenient because it is easy to separate out the different components of the transform; a matrix representation would require using the polar decomposition to split scale from rotation.
- pymomentum.skel_state.blend(skeleton_states: torch.Tensor, weights: torch.Tensor | None = None) torch.Tensor
Blend k skeleton states with the passed-in weights.
- Parameters:
skeleton_states – (nBatch x k x 8) tensor containing skeleton states (tx, ty, tz, rx, ry, rz, rw, s)..
weights – Optional (nBatch x k) tensor.
- Returns:
(nBatch x 4) blended quaternion.
- pymomentum.skel_state.from_matrix(skeleton_state: torch.Tensor) torch.Tensor
Convert 4x4 matrices to skeleton states. The matrix represents the transform from a local joint space to the world space.
- Parameters:
matrix – (nBatch x nJoints x 4 x 4) tensor with the transforms.
- Returns:
A (nBatch x nJoints x 8) tensor containing the skeleton states.
- pymomentum.skel_state.from_quaternion(skeleton_state: torch.Tensor) torch.Tensor
Convert quaternions to a skeleton state.
- Parameters:
q – (nBatch x 4) tensor with the quaternion rotations in the form ((x, y, z), w).
- Returns:
A (nBatch x 8) tensor containing skeleton states (tx, ty, tz, rx, ry, rz, rw, s).
- pymomentum.skel_state.from_scale(skeleton_state: torch.Tensor) torch.Tensor
Convert scales to a skeleton state.
- Parameters:
q – (nBatch x 1) tensor with uniform scales.
- Returns:
A (nBatch x 8) tensor containing skeleton states (tx, ty, tz, rx, ry, rz, rw, s).
- pymomentum.skel_state.from_translation(skeleton_state: torch.Tensor) torch.Tensor
Convert translations to a skeleton state.
- Parameters:
q – (nBatch x 3) tensor with the translations (x, y, z).
- Returns:
A (nBatch x 8) tensor containing skeleton states (tx, ty, tz, rx, ry, rz, rw, s).
- pymomentum.skel_state.identity() torch.Tensor
Returns a skeleton state representing the identity transform.
- pymomentum.skel_state.inverse(skeleton_states: torch.Tensor) torch.Tensor
Compute the inverse of a skeleton state.
- Parameters:
skeleton_states – (nBatch x nJoints x 8) tensor with the skeleton states.
- Returns:
A (nBatch x nJoints x 8) tensor containing the (x, y, z, rx, ry, rz, rw, s) skeleton states corresponding to the inverse transform.
- pymomentum.skel_state.multiply(s1: torch.Tensor, s2: torch.Tensor) torch.Tensor
Multiply two skeleton states.
- Parameters:
s1 – (nBatch x nJoints x 8) tensor with the skeleton states.
s2 – (nBatch x nJoints x 8) tensor with the skeleton states.
- Returns:
A (nBatch x nJoints x 8) tensor containing the (x, y, z, rx, ry, rz, rw, s) skeleton states corresponding to the product.
- pymomentum.skel_state.split(skeleton_state: torch.Tensor) tuple[torch.Tensor, torch.Tensor, torch.Tensor]
Splits a skeleton state into translation, rotation, and scale components.
- Parameters:
skeleton_state – (nBatch x 8)-dimension tensor with skeletons states.
- Returns:
A tuple of tensors (translation, rotation, scale).
- pymomentum.skel_state.to_matrix(skeleton_state: torch.Tensor) torch.Tensor
Convert skeleton state to a tensor of 4x4 matrices. The matrix represents the transform from a local joint space to the world space.
- Parameters:
skeletonState – (nBatch x nJoints x 8) tensor with the skeleton state.
- Returns:
A (nBatch x nJoints x 4 x 4) tensor containing 4x4 matrix transforms.
- pymomentum.skel_state.transform_points(skeleton_states: torch.Tensor, points: torch.Tensor) torch.Tensor
Transform 3d points by the transform represented by the skeleton state.
- Parameters:
skeleton_states – (nBatch x nJoints x 8) tensor with the skeleton states.
points – (nBatch x nJoints x 3) tensor with the points.
- Returns:
A (nBatch x nJoints x 3) tensor containing the points transformed by the skeleton states.