mani_skill.utils.structs.pose#
Classes#
Wrapper around sapien.Pose that supports managing a batch of Poses and flexible creation of them from a variety of |
Functions#
|
|
|
Maps several formats to a sapien Pose |
|
Maps several formats of Pose representation to the appropriate tensor representation |
Module Contents#
- class mani_skill.utils.structs.pose.Pose[source]#
Wrapper around sapien.Pose that supports managing a batch of Poses and flexible creation of them from a variety of sources (list, numpy array, sapien.Pose). This pose object will also return information with a batch dimension, even if it is just holding a single position and quaternion.
As a result pose.p and pose.q will return shapes (N, 3) and (N, 4) respectively for N poses being stored. pose.raw_pose stores all the pose data as a single 2D array of shape (N, 7).
All sapien.Pose API are re-implemented in batch mode here to support GPU simulation. E.g. pose multiplication and inverse with
pose_1.inv() * pose_2, or creating transformation matrices withpose_1.to_transformation_matrix()are suppported they same way they are in sapien.Pose.Pose Creation#
To create a batched pose with a given position
pand/or quaternionq, you run:pose = Pose.create_from_pq(p=p, q=q)
pandqcan be a torch tensor, numpy array, and/or list, or None.If
porqhave only 1 value/not batched, then we automatically repeat the value to the batch size of the other given value. For example, ifphas a batch dimension of size > 1, andqhas a batch dimension of size 1 or is a flat list, then the code automatically repeats theqvalue to the batch size ofp. Likewise in the reverse direction the same repeating occurs.If
pandqhave the same batch size, they are stored as so.If
pandqhave no batch dimensions, one is automatically added (e.g.phaving shape (3,) now becomes (1, 3))If
pis None, it is auto filled with zeros.If
qis None, it is auto filled with the [1, 0, 0, 0] quaternion.If you have a sapien.Pose, another Pose object, or a raw pose tensor of shape (N, 7) or (7,) called
x, you can create this Pose object with:pose = Pose.create(x)
If you want a sapien.Pose object instead of this batched Pose, you can do
pose.spto get the sapien.Pose version (which is not batched). Note that this is only permitted if this Pose has a batch size of 1.Pose Indexing#
You can index into a Pose object like numpy/torch arrays to get a new Pose object with the indexed data.
For example if
posehas a batch size of 4, thenpose[0]will be a Pose object with batch size of 1, andpose[1:3]will be a Pose object with batch size of 2.- __mul__(arg0)[source]#
Multiply two poses. Supports multiplying singular poses like sapien.Pose or Pose object with batch size of 1 with Pose objects with batch size > 1.
- classmethod create(pose, device=None)[source]#
Creates a Pose object from a given
pose, which can be a torch tensor, sapien.Pose, list of sapien.Pose, or Pose
- classmethod create_from_pq(p=None, q=None, device=None)[source]#
Creates a Pose object from a given position
pand/or quaternionq- Parameters:
p (Optional[torch.Tensor]) –
q (Optional[torch.Tensor]) –
device (Optional[mani_skill.utils.structs.types.Device]) –
- to(device)[source]#
Move the Pose object to a different device
- Parameters:
device (mani_skill.utils.structs.types.Device) –
- to_transformation_matrix()[source]#
Returns the (N, 4, 4) shaped transformation matrix equivalent to this pose
- mani_skill.utils.structs.pose.to_batched_tensor(x, device=None)[source]#
- Parameters:
x (Union[list, mani_skill.utils.structs.types.Array]) –
device (Optional[mani_skill.utils.structs.types.Device]) –
- mani_skill.utils.structs.pose.to_sapien_pose(pose)[source]#
Maps several formats to a sapien Pose
- Parameters:
pose (Union[torch.Tensor, sapien.Pose, Pose]) –
- Return type:
sapien.Pose
- mani_skill.utils.structs.pose.vectorize_pose(pose, device=None)[source]#
Maps several formats of Pose representation to the appropriate tensor representation
- Parameters:
pose (Union[sapien.Pose, Pose, mani_skill.utils.structs.types.Array]) –
device (Optional[mani_skill.utils.structs.types.Device]) –
- Return type:
torch.Tensor