File size: 2,225 Bytes
406662d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# ignore private usage of variables warning
# pyright: reportPrivateUsage=none
"""Launch Isaac Sim Simulator first."""
from isaaclab.app import AppLauncher
# launch the simulator
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
# Define a fixture to replace setUpClass
import pytest
from isaaclab.assets import AssetBase, AssetBaseCfg
from isaaclab.sim import build_simulation_context
import isaaclab_assets as lab_assets # noqa: F401
@pytest.fixture(scope="module")
def registered_entities():
# load all registered entities configurations from the module
registered_entities: dict[str, AssetBaseCfg] = {}
# inspect all classes from the module
for obj_name in dir(lab_assets):
obj = getattr(lab_assets, obj_name)
# store all registered entities configurations
if isinstance(obj, AssetBaseCfg):
registered_entities[obj_name] = obj
# print all existing entities names
print(">>> All registered entities:", list(registered_entities.keys()))
return registered_entities
# Add parameterization for the device
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
def test_asset_configs(registered_entities, device):
"""Check all registered asset configurations."""
# iterate over all registered assets
for asset_name, entity_cfg in registered_entities.items():
# Use pytest's subtests
with build_simulation_context(device=device, auto_add_lighting=True) as sim:
sim._app_control_on_stop_handle = None
# print the asset name
print(f">>> Testing entity {asset_name} on device {device}")
# name the prim path
entity_cfg.prim_path = "/World/asset"
# create the asset / sensors
entity: AssetBase = entity_cfg.class_type(entity_cfg) # type: ignore
# play the sim
sim.reset()
# check asset is initialized successfully
assert entity.is_initialized
|