mani_skill.envs.scene#
Attributes#
Classes#
Class that manages a list of sub-scenes (sapien.Scene). In CPU simulation there should only be one sub-scene. |
|
Module Contents#
- class mani_skill.envs.scene.ManiSkillScene(sub_scenes=None, sim_config=SimConfig(), debug_mode=True, device=None, parallel_in_single_scene=False, backend=None)[source]#
Class 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
- Parameters:
sub_scenes (Optional[list[sapien.Scene]]) –
sim_config (mani_skill.utils.structs.types.SimConfig) –
debug_mode (bool) –
device (mani_skill.utils.structs.types.Device) –
parallel_in_single_scene (bool) –
backend (mani_skill.envs.utils.system.backend.BackendInfo) –
- _gpu_fetch_all()[source]#
Queries simulation for all relevant GPU data. Note that this has some overhead. Should only be called at most once per simulation step as this automatically queries all data for all objects built in the scene.
- _gpu_setup_sensors(sensors)[source]#
- Parameters:
sensors (dict[str, mani_skill.sensors.base_sensor.BaseSensor]) –
- _sapien_31_add_camera(name, pose, width, height, near, far, fovy=None, intrinsic=None, mount=None)[source]#
internal helper function to add (mounted) cameras
- Parameters:
fovy (Union[float, list, None]) –
intrinsic (Union[mani_skill.utils.structs.types.Array, None]) –
mount (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link, None]) –
- Return type:
- _sapien_31_gpu_setup_sensors(sensors)[source]#
- Parameters:
sensors (dict[str, mani_skill.sensors.base_sensor.BaseSensor]) –
- _sapien_31_setup_gpu_rendering()[source]#
Prepares the scene for GPU parallelized rendering to enable taking e.g. RGB images
- _sapien_31_update_render(update_sensors=True, update_human_render_cameras=True)[source]#
- Parameters:
update_sensors (bool) –
update_human_render_cameras (bool) –
- _sapien_add_camera(name, pose, width, height, near, far, fovy=None, intrinsic=None, mount=None)[source]#
internal helper function to add (mounted) cameras
- Parameters:
fovy (Union[float, list, None]) –
intrinsic (Union[mani_skill.utils.structs.types.Array, None]) –
mount (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link, None]) –
- Return type:
- _sapien_gpu_setup_sensors(sensors)[source]#
- Parameters:
sensors (dict[str, mani_skill.sensors.base_sensor.BaseSensor]) –
- _sapien_setup_gpu_rendering()[source]#
Prepares the scene for GPU parallelized rendering to enable taking e.g. RGB images
- _sapien_update_render(update_sensors=True, update_human_render_cameras=True)[source]#
- Parameters:
update_sensors (bool) –
update_human_render_cameras (bool) –
- _setup(enable_gpu)[source]#
Start the CPU/GPU simulation and allocate all buffers and initialize objects
- Parameters:
enable_gpu (bool) –
- add_area_light_for_ray_tracing(pose, color, half_width, half_height, scene_idxs=None)[source]#
- Parameters:
pose (sapien.Pose) –
half_width (float) –
half_height (float) –
- add_camera(name, pose, width, height, near, far, fovy=None, intrinsic=None, mount=None)[source]#
Add’s a (mounted) camera to the scene
- Parameters:
fovy (Union[float, list, None]) –
intrinsic (Union[mani_skill.utils.structs.types.Array, None]) –
mount (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link, None]) –
- Return type:
- 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=None)[source]#
- Parameters:
scene_idxs (Optional[list[int]]) –
- add_point_light(position, color, shadow=False, shadow_near=0.1, shadow_far=10.0, shadow_map_size=2048, scene_idxs=None)[source]#
- Parameters:
scene_idxs (Optional[list[int]]) –
- add_spot_light(position, direction, inner_fov, outer_fov, color, shadow=False, shadow_near=0.1, shadow_far=10.0, shadow_map_size=2048, scene_idxs=None)[source]#
- Parameters:
inner_fov (float) –
outer_fov (float) –
scene_idxs (Optional[list[int]]) –
- add_to_state_dict_registry(object)[source]#
- Parameters:
object (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.articulation.Articulation]) –
- can_render()[source]#
Whether or not this Scene object permits rendering, depending on the rendering device selected
- 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, pose0, body1, pose1)[source]#
- Parameters:
body0 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) –
pose0 (Union[sapien.Pose, mani_skill.utils.structs.pose.Pose]) –
body1 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) –
pose1 (Union[sapien.Pose, mani_skill.utils.structs.pose.Pose]) –
- 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_human_render_camera_images(camera_name=None)[source]#
- Parameters:
camera_name (str) –
- Return type:
dict[str, torch.Tensor]
- get_pairwise_contact_forces(obj1, obj2)[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 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) – Actor | Link
obj2 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) – Actor | Link
- get_pairwise_contact_impulses(obj1, obj2)[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 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) – Actor | Link
obj2 (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.link.Link]) – Actor | Link
- get_sensor_images(obs)[source]#
Get raw sensor data as images for visualization purposes.
- Parameters:
obs (dict[str, Any]) –
- Return type:
dict[str, dict[str, torch.Tensor]]
- get_sim_state()[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
- Return type:
torch.Tensor
- remove_actor(actor)[source]#
Removes an actor from the scene. Only works in CPU simulation.
- Parameters:
actor (mani_skill.utils.structs.actor.Actor) –
- remove_articulation(articulation)[source]#
Removes an articulation from the scene. Only works in CPU simulation.
- Parameters:
articulation (mani_skill.utils.structs.articulation.Articulation) –
- remove_from_state_dict_registry(object)[source]#
- Parameters:
object (Union[mani_skill.utils.structs.actor.Actor, mani_skill.utils.structs.articulation.Articulation]) –
- update_render(update_sensors=True, update_human_render_cameras=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.
- _needs_fetch = False[source]#
Used internally to raise some errors ahead of time of when there may be undefined behaviors
- _pairwise_contact_query_unique_hashes: dict[str, int][source]#
maps keys in self.pairwise_contact_queries to unique hashes dependent on the actual objects involved in the query. This is used to determine automatically when to rebuild contact queries as keys for self.pairwise_contact_queries are kept non-unique between episode resets in order to be easily rebuilt and deallocate old queries. This essentially acts as a way to invalidate the cached queries.
- _reset_mask[source]#
Used internally by various objects like Actor, Link, and Controllers to auto mask out sub-scenes so they do not get modified during partial env resets
- actor_views: dict[str, mani_skill.utils.structs.actor.Actor][source]#
views of actors in any sub-scenes created by using Actor.merge and queryable as if it were a single Actor
- actors: dict[str, mani_skill.utils.structs.actor.Actor][source]#
- articulation_views: dict[str, mani_skill.utils.structs.articulation.Articulation][source]#
views of articulations in any sub-scenes created by using Articulation.merge and queryable as if it were a single Articulation
- articulations: dict[str, mani_skill.utils.structs.articulation.Articulation][source]#
- human_render_cameras: dict[str, mani_skill.sensors.camera.Camera][source]#
- pairwise_contact_queries: dict[str, sapien.physx.PhysxGpuContactPairImpulseQuery][source]#
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 = False[source]#
Whether rendering all parallel scenes in the viewer/gui is enabled
- property scene_offsets[source]#
torch tensor of shape (num_envs, 3) representing the offset of each scene in the world frame
- property scene_offsets_np[source]#
numpy array of shape (num_envs, 3) representing the offset of each scene in the world frame
- sensors: dict[str, mani_skill.sensors.base_sensor.BaseSensor][source]#
- state_dict_registry: StateDictRegistry[source]#
state dict registry that map actor/articulation names to Actor/Articulation struct references. Only these structs are used for the environment state
- class mani_skill.envs.scene.StateDictRegistry[source]#
- actors: dict[str, mani_skill.utils.structs.actor.Actor][source]#
- articulations: dict[str, mani_skill.utils.structs.articulation.Articulation][source]#