mani_skill.envs.scene#
The ManiSkillScene class manages most of the underlying data for a ManiSkill environment. It is created each time an environment is instantiated or reconfigured and can be accessed via env.scene where env is your created environment object.
- class mani_skill.envs.scene.ManiSkillScene(sub_scenes: List[Scene] | None = None, sim_config: SimConfig = SimConfig(spacing=5, sim_freq=100, control_freq=20, gpu_memory_config=GPUMemoryConfig(temp_buffer_capacity=16777216, max_rigid_contact_count=524288, max_rigid_patch_count=262144, heap_capacity=67108864, found_lost_pairs_capacity=33554432, found_lost_aggregate_pairs_capacity=1024, total_aggregate_pairs_capacity=1024), scene_config=SceneConfig(gravity=array([0., 0., -9.81]), bounce_threshold=2.0, sleep_threshold=0.005, contact_offset=0.02, rest_offset=0, solver_position_iterations=15, solver_velocity_iterations=1, enable_pcm=True, enable_tgs=True, enable_ccd=False, enable_enhanced_determinism=False, enable_friction_every_iteration=True, cpu_workers=0), default_materials_config=DefaultMaterialsConfig(static_friction=0.3, dynamic_friction=0.3, restitution=0)), debug_mode: bool = True, device: str | device | None = None, parallel_in_single_scene: bool = False, backend: BackendInfo | None = None)[source]#
Bases:
objectClass that manages a list of sub-scenes (sapien.Scene). In CPU simulation there should only be one sub-scene. In GPU simulation, there can be many sub-scenes, and this wrapper ensures that use calls to many of the original sapien.Scene API are applied to all sub-scenes. This includes calls to change object poses, velocities, drive targets etc.
This wrapper also helps manage GPU states if GPU simulation is used
- actor_views: Dict[str, Actor]#
views of actors in any sub-scenes created by using Actor.merge and queryable as if it were a single Actor
- add_area_light_for_ray_tracing(pose: Pose, color, half_width: float, half_height: float, scene_idxs=None)[source]#
- add_camera(name, pose, width, height, near, far, fovy: float | List | None = None, intrinsic: Tensor | ndarray | Sequence | None = None, mount: Actor | Link | None = None) RenderCamera[source]#
Add’s a (mounted) camera to the scene
- add_directional_light(direction, color, shadow=False, position=[0, 0, 0], shadow_scale=10.0, shadow_near=-10.0, shadow_far=10.0, shadow_map_size=2048, scene_idxs: List[int] | None = None)[source]#
- add_point_light(position, color, shadow=False, shadow_near=0.1, shadow_far=10.0, shadow_map_size=2048, scene_idxs: List[int] | None = None)[source]#
- add_spot_light(position, direction, inner_fov: float, outer_fov: float, color, shadow=False, shadow_near=0.1, shadow_far=10.0, shadow_map_size=2048, scene_idxs: List[int] | None = None)[source]#
- add_to_state_dict_registry(object: Actor | Articulation)[source]#
- property ambient_light#
- articulation_views: Dict[str, Articulation]#
views of articulations in any sub-scenes created by using Articulation.merge and queryable as if it were a single Articulation
- create_actor_builder()[source]#
Creates an ActorBuilder object that can be used to build actors in this scene
- create_articulation_builder()[source]#
Creates an ArticulationBuilder object that can be used to build articulations in this scene
- create_drive(body0: Actor | Link, pose0: Pose | Pose, body1: Actor | Link, pose1: Pose | Pose)[source]#
- create_mjcf_loader()[source]#
Creates a MJCFLoader object that can be used to load MJCF files into this scene
- create_urdf_loader()[source]#
Creates a URDFLoader object that can be used to load URDF files into this scene
- get_all_actors()[source]#
Returns list of all sapien.Entity objects that have rigid dynamic and static components across all sub scenes
- get_all_articulations()[source]#
Returns list of all physx articulation objects across all sub scenes
- get_pairwise_contact_forces(obj1: Actor | Link, obj2: Actor | Link)[source]#
Get the force vectors between two actors/links. Returns force vector of shape (N, 3) where N is the number of environments and 3 is the dimension of the force vector itself, representing x, y, and z direction of force.
- Parameters:
obj1 – Actor | Link
obj2 – Actor | Link
- get_pairwise_contact_impulses(obj1: Actor | Link, obj2: Actor | Link)[source]#
Get the impulse vectors between two actors/links. Returns impulse vector of shape (N, 3) where N is the number of environments and 3 is the dimension of the impulse vector itself, representing x, y, and z direction of impulse.
Note that dividing the impulse value by self.px.timestep yields the pairwise contact force in Newtons. The equivalent API for that is self.get_pairwise_contact_force(obj1, obj2). It is generally recommended to use the force values since they are independent of the timestep (dt = 1 / sim_freq) of the simulation.
- Parameters:
obj1 – Actor | Link
obj2 – Actor | Link
- get_sensor_images(obs: Dict[str, Any]) Dict[str, Dict[str, Tensor]][source]#
Get raw sensor data as images for visualization purposes.
- get_sim_state() Tensor[source]#
Get simulation state. Returns a dictionary with two nested dictionaries “actors” and “articulations”. In the nested dictionaries they map the actor/articulation name to a vector of shape (N, D) for N parallel environments and D dimensions of padded state per environment.
Note that static actor data are not included. It is expected that an environment reconstructs itself in a deterministic manner such that the same static actors always have the same states
- gpu_sim_enabled#
whether the sub scenes are using the GPU or CPU backend
- property num_envs#
- pairwise_contact_queries: Dict[str, PhysxGpuContactPairImpulseQuery]#
dictionary mapping pairwise contact query keys to GPU contact queries. Used in GPU simulation only to cache queries as query creation will pause any GPU sim computation
- parallel_in_single_scene: bool#
Whether rendering all parallel scenes in the viewer/gui is enabled
- remove_articulation(articulation: Articulation)[source]#
Removes an articulation from the scene. Only works in CPU simulation.
- remove_from_state_dict_registry(object: Actor | Articulation)[source]#
- property scene_offsets#
torch tensor of shape (num_envs, 3) representing the offset of each scene in the world frame
- property scene_offsets_np#
numpy array of shape (num_envs, 3) representing the offset of each scene in the world frame
- state_dict_registry: StateDictRegistry#
state dict registry that map actor/articulation names to Actor/Articulation struct references. Only these structs are used for the environment state
- property timestep#
The current simulation timestep
- update_render(update_sensors: bool = True, update_human_render_cameras: bool = True)[source]#
Updates the renderer based on the current simulation state. Note that on the first call if a sensor/human render camera is required to be updated, GPU memory will be allocated for the sensor/human render camera respectively.
- Parameters:
update_sensors (bool) – Whether to update the sensors.
update_human_render_cameras (bool) – Whether to update the human render cameras.
- class mani_skill.envs.scene.StateDictRegistry(actors: Dict[str, mani_skill.utils.structs.actor.Actor], articulations: Dict[str, mani_skill.utils.structs.articulation.Articulation])[source]#
Bases:
object- articulations: Dict[str, Articulation]#