mani_skill.utils.structs.articulation#
Classes#
Wrapper around physx.PhysxArticulation objects |
Module Contents#
- class mani_skill.utils.structs.articulation.Articulation[source]#
Bases:
mani_skill.utils.structs.BaseStruct[sapien.physx.PhysxArticulation]Wrapper around physx.PhysxArticulation objects
- classmethod create_from_physx_articulations(physx_articulations, scene, scene_idxs, _merged=False, _process_links=True)[source]#
Create a managed articulation object given a list of physx articulations. Note that this function requires all given articulations to be the same articulations. To create an object to manage different articulations use the .merge function.
- Parameters:
physx_articulations (list[sapien.physx.PhysxArticulation]) –
scene (mani_skill.envs.scene.ManiSkillScene) –
scene_idxs (torch.Tensor) –
_merged (bool) –
_process_links (bool) –
- Return type:
- get_collision_meshes(to_world_frame=True, first_only=False)[source]#
Returns the collision mesh of each managed articulation object. Note results of this are not cached or optimized at the moment so this function can be slow if called too often
- Parameters:
to_world_frame (bool) – Whether to transform the collision mesh pose to the world frame
first_only (bool) – Whether to return the collision mesh of just the first articulation managed by this object. If True, this also returns a single Trimesh.Mesh object instead of a list. This can be useful for efficiency reasons if you know ahead of time all of the managed actors have the same collision mesh
- Return type:
Union[list[trimesh.Trimesh], trimesh.Trimesh]
- get_first_collision_mesh(to_world_frame=True)[source]#
Returns the collision mesh of the first managed articulation object. Note results of this are not cached or optimized at the moment so this function can be slow if called too often. Some articulations have no collision meshes, in which case this function returns None
- Parameters:
to_world_frame (bool) – Whether to transform the collision mesh pose to the world frame
- Return type:
Union[trimesh.Trimesh, None]
- get_first_visual_mesh(to_world_frame=True)[source]#
Returns the visual mesh of the first managed articulation object. Note results of this are not cached or optimized at the moment so this function can be slow if called too often
- Parameters:
to_world_frame (bool) –
- Return type:
trimesh.Trimesh
- get_joint_target_indices(joint_indices)[source]#
Gets the meshgrid indexes for indexing px.cuda_articulation_target_* values given a 1D list of joint indexes or a 1D list of ArticulationJoint objects.
Internally the given input is made to a tuple for a cache key and is used to cache results for fast lookup in the future, particularly for large-scale GPU simulations.
- Parameters:
joint_indices (Union[mani_skill.utils.structs.types.Array, list[int], list[mani_skill.utils.structs.ArticulationJoint]]) –
- get_link_incoming_joint_forces()[source]#
Returns the incoming joint forces, referred to as spatial forces, for each link, with shape (N, M, 6), where N is the number of environments and M is the number of links.
Spatial forces are complex to describe and we recommend you see the physx documentation for how they are computed: https://nvidia-omniverse.github.io/PhysX/physx/5.6.0/docs/Articulations.html#link-incoming-joint-force
The mth spatial force refers to the mth link, and to find a particular link you can find the Link object first then use it’s index attribute.
link = articulation.links_map[link_name] link_index = link.index link_incoming_joint_force = articulation.get_link_incoming_joint_forces()[:, link_index]
- get_net_contact_forces(link_names)[source]#
Get net contact forces for several links together. This should be faster compared to using link.get_net_contact_forces on each link.
Returns force vector of shape (N, len(link_names), 3) where N is the number of environments
- Parameters:
link_names (Union[list[str], Tuple[str]]) –
- get_net_contact_impulses(link_names)[source]#
Get net contact impulses for several links together. This should be faster compared to using link.get_net_contact_impulses on each link.
Returns impulse vector of shape (N, len(link_names), 3) where N is the number of environments
- Parameters:
link_names (Union[list[str], Tuple[str]]) –
- get_visual_meshes(to_world_frame=True, first_only=False)[source]#
Returns the visual mesh of each managed articulation object. Note results of this are not cached or optimized at the moment so this function can be slow if called too often
- Parameters:
to_world_frame (bool) –
first_only (bool) –
- Return type:
list[trimesh.Trimesh]
- classmethod merge(articulations, name=None, merge_links=False)[source]#
Merge a list of articulations into a single articulation for easy access of data across multiple possibly different articulations.
- Parameters:
articulations (list[Articulation]) – A list of articulations objects to merge.
name (str) – The name of the merged articulation.
merge_links (bool) – Whether to merge the links of the articulations. This is by default False as often times you merge articulations that have different number of links. Set this true if you want to try and merge articulations that have the same number of links.
- set_joint_drive_targets(targets, joints=None, joint_indices=None)[source]#
Set drive targets on active joints given joints. For GPU simulation only joint_indices argument is supported, which should be a 1D list of the active joint indices in the articulation.
joints argument will always be used when possible and is the recommended approach. On CPU simulation the joints argument is required, joint_indices is not supported.
- Parameters:
targets (mani_skill.utils.structs.types.Array) –
joints (Optional[list[mani_skill.utils.structs.ArticulationJoint]]) –
joint_indices (Optional[torch.Tensor]) –
- set_joint_drive_velocity_targets(targets, joints=None, joint_indices=None)[source]#
Set drive velocity targets on active joints given joints. For GPU simulation only joint_indices argument is supported, which should be a 1D list of the active joint indices in the articulation.
joints argument will always be used when possible and is the recommended approach. On CPU simulation the joints argument is required, joint_indices is not supported.
- Parameters:
targets (mani_skill.utils.structs.types.Array) –
joints (Optional[list[mani_skill.utils.structs.ArticulationJoint]]) –
joint_indices (Optional[torch.Tensor]) –
- set_root_angular_velocity(velocity)[source]#
- Parameters:
velocity (mani_skill.utils.structs.types.Array) –
- Return type:
None
- set_root_linear_velocity(velocity)[source]#
- Parameters:
velocity (mani_skill.utils.structs.types.Array) –
- Return type:
None
- set_state(state, env_idx=None)[source]#
- Parameters:
state (mani_skill.utils.structs.types.Array) –
env_idx (torch.Tensor) –
- _cached_joint_target_indices: dict[int, torch.Tensor][source]#
Map from a set of joints of this articulation and the indexing torch tensor to use for setting drive targets in GPU sims.
- property _data_index[source]#
Returns a tensor of the indices of the articulation in the GPU simulation for the physx_cuda backend.
- _net_contact_force_queries: dict[Tuple, sapien.physx.PhysxGpuContactBodyImpulseQuery][source]#
Maps a tuple of link names to pre-saved net contact force queries
- active_joints: list[mani_skill.utils.structs.ArticulationJoint][source]#
list of active Joint objects, referencing elements in self.joints
- active_joints_map: dict[str, mani_skill.utils.structs.ArticulationJoint][source]#
Maps active joint name to the Joint object, referencing elements in self.joints
- property drive_targets[source]#
The current drive targets of the active joints. Also known as the target joint positions. Returns a tensor of shape (N, M) where N is the number of environments and M is the number of active joints.
- property drive_velocities[source]#
The current drive velocity targets of the active joints. Also known as the target joint velocities. Returns a tensor of shape (N, M) where N is the number of environments and M is the number of active joints.
- property fixed_root_link[source]#
Returns a boolean tensor of whether the root link is fixed for each parallel articulation
- initial_pose: mani_skill.utils.structs.Pose = None[source]#
The initial pose of this articulation
- joints: list[mani_skill.utils.structs.ArticulationJoint][source]#
list of Joint objects
- joints_map: dict[str, mani_skill.utils.structs.ArticulationJoint][source]#
Maps joint name to the Joint object
- links: list[mani_skill.utils.structs.Link][source]#
list of Link objects
- links_map: dict[str, mani_skill.utils.structs.Link][source]#
Maps link name to the Link object
- property max_dof: int[source]#
the max DOF out of all managed objects. This is used to padd attributes like qpos
- Return type:
int
- merged: bool = False[source]#
whether or not this articulation object is a merged articulation where it is managing many articulations with different dofs.
There are a number of caveats when it comes to merged articulations. While merging articulations means you can easily fetch padded qpos, qvel, etc. type data, a number of attributes and functions will make little sense and you should avoid using them unless you are an advanced user. In particular, the list of Links, Joints, their corresponding maps, net contact forces of multiple links, no longer make “sense”
- property pose: mani_skill.utils.structs.Pose[source]#
- Return type:
- root: mani_skill.utils.structs.Link[source]#
The root Link object