Skip to content

Commit

Permalink
adds test for files as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayankm96 committed Oct 9, 2024
1 parent 2e6c299 commit df51fb2
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion source/extensions/omni.isaac.lab/test/sim/test_spawn_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from omni.isaac.core.simulation_context import SimulationContext

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.utils.assets import ISAACLAB_NUCLEUS_DIR


class TestSpawningWrappers(unittest.TestCase):
Expand All @@ -44,7 +45,7 @@ def tearDown(self) -> None:
self.sim.clear_instance()

"""
Tests.
Tests - Multiple assets.
"""

def test_spawn_multiple_shapes_with_global_settings(self):
Expand Down Expand Up @@ -144,6 +145,47 @@ def test_spawn_multiple_shapes_with_individual_settings(self):
prim = prim_utils.get_prim_at_path(prim_path)
self.assertTrue(prim.GetAttribute("physics:mass").Get() in mass_variations)

"""
Tests - Multiple USDs.
"""

def test_spawn_multiple_files_with_global_settings(self):
"""Test spawning of files randomly with global articulation settings."""
# Define prim parents
num_clones = 10
for i in range(num_clones):
prim_utils.create_prim(f"/World/env_{i}", "Xform", translation=(i, i, 0))

# Spawn shapes
cfg = sim_utils.MultiUsdFileCfg(
usd_path=[
f"{ISAACLAB_NUCLEUS_DIR}/Robots/ANYbotics/ANYmal-C/anymal_c.usd",
f"{ISAACLAB_NUCLEUS_DIR}/Robots/ANYbotics/ANYmal-D/anymal_d.usd",
],
random_choice=True,
rigid_props=sim_utils.RigidBodyPropertiesCfg(
disable_gravity=False,
retain_accelerations=False,
linear_damping=0.0,
angular_damping=0.0,
max_linear_velocity=1000.0,
max_angular_velocity=1000.0,
max_depenetration_velocity=1.0,
),
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
enabled_self_collisions=True, solver_position_iteration_count=4, solver_velocity_iteration_count=0
),
activate_contact_sensors=True,
)
prim = cfg.func("/World/env_.*/Robot", cfg)

# Check validity
self.assertTrue(prim.IsValid())
self.assertEqual(prim_utils.get_prim_path(prim), "/World/env_0/Robot")
# Find matching prims
prim_paths = prim_utils.find_matching_prim_paths("/World/env_*/Robot")
self.assertEqual(len(prim_paths), num_clones)


if __name__ == "__main__":
run_tests()

0 comments on commit df51fb2

Please sign in to comment.