Skip to content

Commit 2980f4a

Browse files
committed
fix test stage in memory
1 parent f5107ff commit 2980f4a

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

source/isaaclab/test/sim/test_stage_in_memory.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,12 @@ def test_stage_in_memory_with_shapes(sim):
5454
if isaac_sim_version < 5:
5555
pytest.skip("Stage in memory is not supported in this version of Isaac Sim")
5656

57-
# define parameters
58-
num_clones = 10
59-
6057
# grab stage in memory and set as current stage via the with statement
6158
stage_in_memory = sim.get_initial_stage()
6259
with sim_utils.use_stage(stage_in_memory):
6360
# create cloned cone stage
64-
for i in range(num_clones):
65-
prim_utils.create_prim(f"/World/env_{i}", "Xform", translation=(i, i, 0))
66-
61+
prim_utils.create_prim("/World/Cone", "Xform")
62+
num_shape_prototypes = 3
6763
cfg = sim_utils.MultiAssetSpawnerCfg(
6864
assets_cfg=[
6965
sim_utils.ConeCfg(
@@ -84,21 +80,21 @@ def test_stage_in_memory_with_shapes(sim):
8480
mass_props=sim_utils.MassPropertiesCfg(mass=1.0),
8581
collision_props=sim_utils.CollisionPropertiesCfg(),
8682
)
87-
prim_path_regex = "/World/env_.*/Cone"
83+
prim_path_regex = "/World/Cone/asset_.*"
8884
cfg.func(prim_path_regex, cfg)
8985

9086
# verify stage is in memory
9187
assert sim_utils.is_current_stage_in_memory()
9288

9389
# verify prims exist in stage in memory
9490
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
95-
assert len(prims) == num_clones
91+
assert len(prims) == num_shape_prototypes
9692

9793
# verify prims do not exist in context stage
9894
context_stage = omni.usd.get_context().get_stage()
9995
with sim_utils.use_stage(context_stage):
10096
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
101-
assert len(prims) != num_clones
97+
assert len(prims) != num_shape_prototypes
10298

10399
# attach stage to context
104100
sim_utils.attach_stage_to_usd_context()
@@ -108,7 +104,7 @@ def test_stage_in_memory_with_shapes(sim):
108104

109105
# verify prims now exist in context stage
110106
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
111-
assert len(prims) == num_clones
107+
assert len(prims) == num_shape_prototypes
112108

113109

114110
def test_stage_in_memory_with_usds(sim):
@@ -120,7 +116,7 @@ def test_stage_in_memory_with_usds(sim):
120116
pytest.skip("Stage in memory is not supported in this version of Isaac Sim")
121117

122118
# define parameters
123-
num_clones = 10
119+
num_robot_prototypes = 2
124120
usd_paths = [
125121
f"{ISAACLAB_NUCLEUS_DIR}/Robots/ANYbotics/ANYmal-C/anymal_c.usd",
126122
f"{ISAACLAB_NUCLEUS_DIR}/Robots/ANYbotics/ANYmal-D/anymal_d.usd",
@@ -129,9 +125,8 @@ def test_stage_in_memory_with_usds(sim):
129125
# grab stage in memory and set as current stage via the with statement
130126
stage_in_memory = sim.get_initial_stage()
131127
with sim_utils.use_stage(stage_in_memory):
132-
# create cloned robot stage
133-
for i in range(num_clones):
134-
prim_utils.create_prim(f"/World/env_{i}", "Xform", translation=(i, i, 0))
128+
# create robot stage
129+
prim_utils.create_prim("/World/Robot", "Xform")
135130

136131
cfg = sim_utils.MultiUsdFileCfg(
137132
usd_path=usd_paths,
@@ -150,21 +145,21 @@ def test_stage_in_memory_with_usds(sim):
150145
),
151146
activate_contact_sensors=True,
152147
)
153-
prim_path_regex = "/World/env_.*/Robot"
148+
prim_path_regex = "/World/Robot/asset_.*"
154149
cfg.func(prim_path_regex, cfg)
155150

156151
# verify stage is in memory
157152
assert sim_utils.is_current_stage_in_memory()
158153

159154
# verify prims exist in stage in memory
160155
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
161-
assert len(prims) == num_clones
156+
assert len(prims) == num_robot_prototypes
162157

163158
# verify prims do not exist in context stage
164159
context_stage = omni.usd.get_context().get_stage()
165160
with sim_utils.use_stage(context_stage):
166161
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
167-
assert len(prims) != num_clones
162+
assert len(prims) != num_robot_prototypes
168163

169164
# attach stage to context
170165
sim_utils.attach_stage_to_usd_context()
@@ -174,7 +169,7 @@ def test_stage_in_memory_with_usds(sim):
174169

175170
# verify prims now exist in context stage
176171
prims = prim_utils.find_matching_prim_paths(prim_path_regex)
177-
assert len(prims) == num_clones
172+
assert len(prims) == num_robot_prototypes
178173

179174

180175
def test_stage_in_memory_with_clone_in_fabric(sim):

0 commit comments

Comments
 (0)