mani_skill.utils.sapien_utils module#
Utilities that work with the simulation / SAPIEN
Functions
- mani_skill.utils.sapien_utils.check_actor_static(actor: Actor, lin_thresh=0.001, ang_thresh=0.01)[source]#
- mani_skill.utils.sapien_utils.check_joint_stuck(articulation: PhysxArticulation, active_joint_idx: int, pos_diff_threshold: float = 0.001, vel_threshold: float = 0.0001)[source]#
- mani_skill.utils.sapien_utils.check_urdf_config(urdf_config: dict)[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: List[Tuple[PhysxContact, bool]])[source]#
- mani_skill.utils.sapien_utils.get_articulation_padded_state(articulation: PhysxArticulation, max_dof: int)[source]#
- mani_skill.utils.sapien_utils.get_cpu_actor_contacts(contacts: List[PhysxContact], actor: Entity) List[Tuple[PhysxContact, bool]][source]#
- mani_skill.utils.sapien_utils.get_cpu_actors_contacts(contacts: List[PhysxContact], actors: List[Entity]) Dict[Entity, List[Tuple[PhysxContact, bool]]][source]#
This function is used to avoid double for-loop when using get_actor_contacts with multiple actors
- mani_skill.utils.sapien_utils.get_multiple_pairwise_contacts(contacts: List[PhysxContact], actor0: Entity, actor1_list: List[Entity]) Dict[Entity, List[Tuple[PhysxContact, bool]]][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
- mani_skill.utils.sapien_utils.get_obj_by_name(objs: List[T], name: str, 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: List[T], target_type: T, is_unique=True)[source]#
- mani_skill.utils.sapien_utils.get_objs_by_names(objs: List[T], names: List[str]) List[T][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.
- 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: List[PhysxContact], actor0: Entity, actor1: Entity)[source]#
- mani_skill.utils.sapien_utils.get_pairwise_contacts(contacts: List[PhysxContact], actor0: Entity, actor1: Entity) List[Tuple[PhysxContact, bool]][source]#
Given a list of contacts, return the list of contacts involving the two actors
- mani_skill.utils.sapien_utils.is_state_dict_consistent(state_dict: 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
- mani_skill.utils.sapien_utils.look_at(eye, target, up=(0, 0, 1), device=None) Pose[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: dict) Dict[source]#
Parse config from dict for SAPIEN URDF loader.
- Parameters:
config_dict (dict) – a dict containing link physical properties.
scene (ManiSkillScene) – the simulation scene
- Returns:
urdf config passed to sapien.URDFLoader.load.
- Return type:
Dict
- mani_skill.utils.sapien_utils.sapien_pose_to_opencv_extrinsic(sapien_pose_matrix: ndarray) ndarray[source]#