Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion source/isaaclab/isaaclab/sim/simulation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from isaacsim.core.api.simulation_context import SimulationContext as _SimulationContext
from isaacsim.core.simulation_manager import SimulationManager
from isaacsim.core.utils.viewports import set_camera_view
from pxr import Gf, PhysxSchema, Sdf, Usd, UsdPhysics
from pxr import Gf, PhysxSchema, Sdf, Usd, UsdPhysics, UsdUtils

import isaaclab.sim as sim_utils
from isaaclab.utils.logger import configure_logging
Expand Down Expand Up @@ -146,6 +146,11 @@ def __init__(self, cfg: SimulationCfg | None = None):
self._initial_stage = sim_utils.create_new_stage_in_memory()
else:
self._initial_stage = omni.usd.get_context().get_stage()
# cache stage if it is not already cached
stage_cache = UsdUtils.StageCache.Get()
stage_id = stage_cache.GetId(self._initial_stage).ToLongInt()
if stage_id < 0:
stage_cache.Insert(self._initial_stage)

# acquire settings interface
self.carb_settings = carb.settings.get_settings()
Expand Down
2 changes: 2 additions & 0 deletions source/isaaclab/isaaclab/sim/utils/prims.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def delete_prim(prim_path: str | Sequence[str], stage: Usd.Stage | None = None)
prim_path = [prim_path]
# get stage handle
stage = get_current_stage() if stage is None else stage
# FIXME: We should not need to cache the stage here. It should
# happen at the creation of the stage.
# the prim command looks for the stage ID in the stage cache
# so we need to ensure the stage is cached
stage_cache = UsdUtils.StageCache.Get()
Expand Down
25 changes: 24 additions & 1 deletion source/isaaclab/test/sim/test_simulation_stage_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,35 @@ def test_stage_in_memory_with_shapes(sim):
sim_utils.ConeCfg(
radius=0.3,
height=0.6,
visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0)),
physics_material=sim_utils.RigidBodyMaterialCfg(
friction_combine_mode="multiply",
restitution_combine_mode="multiply",
static_friction=1.0,
dynamic_friction=1.0,
),
),
sim_utils.CuboidCfg(
sim_utils.MeshCuboidCfg(
size=(0.3, 0.3, 0.3),
visual_material=sim_utils.MdlFileCfg(
mdl_path=f"{ISAACLAB_NUCLEUS_DIR}/Materials/TilesMarbleSpiderWhiteBrickBondHoned/TilesMarbleSpiderWhiteBrickBondHoned.mdl",
project_uvw=True,
texture_scale=(0.25, 0.25),
),
),
sim_utils.SphereCfg(
radius=0.3,
visual_material=sim_utils.MdlFileCfg(
mdl_path=f"{ISAACLAB_NUCLEUS_DIR}/Materials/TilesMarbleSpiderWhiteBrickBondHoned/TilesMarbleSpiderWhiteBrickBondHoned.mdl",
project_uvw=True,
texture_scale=(0.25, 0.25),
),
physics_material=sim_utils.RigidBodyMaterialCfg(
friction_combine_mode="multiply",
restitution_combine_mode="multiply",
static_friction=1.0,
dynamic_friction=1.0,
),
),
],
random_choice=True,
Expand Down