mani_skill.utils.sapien_utils#
Utilities that work with the simulation / SAPIEN
Attributes#
Functions#
|
|
|
|
|
|
|
Check whether the urdf config is valid for SAPIEN. |
|
|
|
Creates a viewer with the given camera config |
|
|
|
|
|
|
|
|
|
This function is used to avoid double for-loop when using get_actor_contacts with multiple actors |
|
Given a list of contacts, return the dict of contacts involving the one actor and actors |
|
Get a object given the name. |
|
|
|
Get a list of objects given a list of names from a larger list of objects (objs). The returned list is in the order of the names given |
|
|
|
Given a list of contacts, return the list of contacts involving the two actors |
|
|
|
Checks if the given state dictionary (generated via env.get_state_dict()) is consistent where each actor/articulation has the same batch dimension |
|
Get the camera pose in SAPIEN by the Look-At method. |
|
Parse config from dict for SAPIEN URDF loader. |
|
|
|
|
|
Module Contents#
- mani_skill.utils.sapien_utils.apply_urdf_config(loader, urdf_config)[source]#
- Parameters:
loader (sapien.wrapper.urdf_loader.URDFLoader) –
urdf_config (dict) –
- mani_skill.utils.sapien_utils.check_actor_static(actor, lin_thresh=0.001, ang_thresh=0.01)[source]#
- Parameters:
actor (mani_skill.utils.structs.actor.Actor) –
- mani_skill.utils.sapien_utils.check_joint_stuck(articulation, active_joint_idx, pos_diff_threshold=0.001, vel_threshold=0.0001)[source]#
- Parameters:
articulation (sapien.physx.PhysxArticulation) –
active_joint_idx (int) –
pos_diff_threshold (float) –
vel_threshold (float) –
- mani_skill.utils.sapien_utils.check_urdf_config(urdf_config)[source]#
Check whether the urdf config is valid for SAPIEN.
- Parameters:
urdf_config (dict) – dict passed to sapien.URDFLoader.load.
- mani_skill.utils.sapien_utils.compute_total_impulse(contact_infos)[source]#
- Parameters:
contact_infos (list[Tuple[sapien.physx.PhysxContact, bool]]) –
- mani_skill.utils.sapien_utils.create_viewer(viewer_camera_config)[source]#
Creates a viewer with the given camera config
- Parameters:
viewer_camera_config (mani_skill.sensors.camera.CameraConfig) –
- mani_skill.utils.sapien_utils.get_articulation_padded_state(articulation, max_dof)[source]#
- Parameters:
articulation (sapien.physx.PhysxArticulation) –
max_dof (int) –
- mani_skill.utils.sapien_utils.get_articulation_state(articulation)[source]#
- Parameters:
articulation (sapien.physx.PhysxArticulation) –
- mani_skill.utils.sapien_utils.get_cpu_actor_contacts(contacts, actor)[source]#
- Parameters:
contacts (list[sapien.physx.PhysxContact]) –
actor (sapien.Entity) –
- Return type:
list[Tuple[sapien.physx.PhysxContact, bool]]
- mani_skill.utils.sapien_utils.get_cpu_actors_contacts(contacts, actors)[source]#
This function is used to avoid double for-loop when using get_actor_contacts with multiple actors
- Parameters:
contacts (list[sapien.physx.PhysxContact]) –
actors (list[sapien.Entity]) –
- Return type:
dict[sapien.Entity, list[Tuple[sapien.physx.PhysxContact, bool]]]
- mani_skill.utils.sapien_utils.get_multiple_pairwise_contacts(contacts, actor0, actor1_list)[source]#
Given a list of contacts, return the dict of contacts involving the one actor and actors This function is used to avoid double for-loop when using get_pairwise_contacts with multiple actors
- Parameters:
contacts (list[sapien.physx.PhysxContact]) –
actor0 (sapien.Entity) –
actor1_list (list[sapien.Entity]) –
- Return type:
dict[sapien.Entity, list[Tuple[sapien.physx.PhysxContact, bool]]]
- mani_skill.utils.sapien_utils.get_obj_by_name(objs, name, is_unique=True)[source]#
Get a object given the name.
- Parameters:
objs (list[T]) – objs to query. Expect these objects to have a get_name function. These may be sapien.Entity, physx.PhysxArticulationLink etc.
name (str) – name for query.
is_unique (bool, optional) – whether the name should be unique. Defaults to True.
- Raises:
RuntimeError – The name is not unique when @is_unique is True.
- Returns:
matched T or Ts. None if no matches.
- Return type:
T or list[T]
- mani_skill.utils.sapien_utils.get_obj_by_type(objs, target_type, is_unique=True)[source]#
- Parameters:
objs (list[T]) –
target_type (T) –
- mani_skill.utils.sapien_utils.get_objs_by_names(objs, names)[source]#
Get a list of objects given a list of names from a larger list of objects (objs). The returned list is in the order of the names given
- Parameters:
objs (list[T]) – objs to query. Expect these objects to have a get_name function. These may be sapien.Entity, physx.PhysxArticulationLink etc.
name (str) – names to query.
names (list[str]) –
- Returns:
matched T or Ts. None if no matches.
- Return type:
T or list[T]
- mani_skill.utils.sapien_utils.get_pairwise_contact_impulse(contacts, actor0, actor1)[source]#
- Parameters:
contacts (list[sapien.physx.PhysxContact]) –
actor0 (sapien.Entity) –
actor1 (sapien.Entity) –
- mani_skill.utils.sapien_utils.get_pairwise_contacts(contacts, actor0, actor1)[source]#
Given a list of contacts, return the list of contacts involving the two actors
- Parameters:
contacts (list[sapien.physx.PhysxContact]) –
actor0 (sapien.Entity) –
actor1 (sapien.Entity) –
- Return type:
list[Tuple[sapien.physx.PhysxContact, bool]]
- mani_skill.utils.sapien_utils.is_state_dict_consistent(state_dict)[source]#
Checks if the given state dictionary (generated via env.get_state_dict()) is consistent where each actor/articulation has the same batch dimension
- Parameters:
state_dict (dict) –
- mani_skill.utils.sapien_utils.look_at(eye, target, up=(0, 0, 1), device=None)[source]#
Get the camera pose in SAPIEN by the Look-At method.
Note
https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/lookat-function The SAPIEN camera follows the convention: (forward, right, up) = (x, -y, z) while the OpenGL camera follows (forward, right, up) = (-z, x, y) Note that the camera coordinate system (OpenGL) is left-hand.
- Parameters:
eye – camera location
target – looking-at location
up – a general direction of “up” from the camera.
device – device to put the pose on.
- Returns:
camera pose
- Return type:
- mani_skill.utils.sapien_utils.parse_urdf_config(config_dict)[source]#
Parse config from dict for SAPIEN URDF loader.
- Parameters:
config_dict (dict) – a dict containing link physical properties.
- Returns:
urdf config passed to sapien.URDFLoader.load.
- Return type:
dict
- mani_skill.utils.sapien_utils.sapien_pose_to_opencv_extrinsic(sapien_pose_matrix)[source]#
- Parameters:
sapien_pose_matrix (numpy.ndarray) –
- Return type:
numpy.ndarray
- mani_skill.utils.sapien_utils.set_articulation_render_material(articulation, **kwargs)[source]#
- Parameters:
articulation (sapien.physx.PhysxArticulation) –