Skip to content

Commit 52e373f

Browse files
committed
Select supported backends in core smoke tests
1 parent 69da8d4 commit 52e373f

4 files changed

Lines changed: 45 additions & 24 deletions

File tree

source/isaaclab_tasks/test/core/test_environment_determinism.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
import isaaclab_tasks # noqa: F401
2525
from isaaclab_tasks.utils.hydra import resolve_presets
26-
from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry
27-
28-
# Bit-wise determinism is a physics-backend property, so keep these checks on
29-
# Isaac Sim PhysX rather than following a task's evolving default. Newton
30-
# MJWarp is not yet run-to-run deterministic on CUDA for the locomotion tasks.
31-
_PINNED_PHYSICS_PRESET = "isaacsim_physx"
26+
from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry, parse_env_cfg
3227

3328

3429
@pytest.fixture(scope="module", autouse=True)
@@ -63,7 +58,7 @@ def test_manipulation_env_determinism(task_name, device):
6358
@pytest.mark.parametrize("device", ["cuda", "cpu"])
6459
def test_locomotion_env_determinism(task_name, device):
6560
"""Check deterministic environment creation for locomotion."""
66-
_test_environment_determinism(task_name, device)
61+
_test_environment_determinism(task_name, device, physics_preset_name="physx")
6762

6863

6964
@pytest.mark.parametrize(
@@ -105,7 +100,7 @@ def _test_environment_determinism(
105100
device: str,
106101
*,
107102
num_steps: int = 100,
108-
physics_preset_name: str = _PINNED_PHYSICS_PRESET,
103+
physics_preset_name: str | None = None,
109104
deterministic_mode: str | None = None,
110105
):
111106
"""Check deterministic environment creation."""
@@ -143,18 +138,21 @@ def _obtain_transition_tuples(
143138
device: str,
144139
num_steps: int,
145140
*,
146-
physics_preset_name: str,
141+
physics_preset_name: str | None = None,
147142
deterministic_mode: str | None = None,
148143
) -> tuple[dict, torch.Tensor]:
149144
"""Run random actions and obtain transition tuples after fixed number of steps."""
150145
# create a new stage
151146
sim_utils.create_new_stage()
152147
try:
153-
# Parse configuration with an explicit physics backend.
154-
env_cfg = load_cfg_from_registry(task_name, "env_cfg_entry_point")
155-
env_cfg = resolve_presets(env_cfg, selected=(physics_preset_name,))
156-
env_cfg.sim.device = device
157-
env_cfg.scene.num_envs = num_envs
148+
# Parse configuration.
149+
if physics_preset_name is None:
150+
env_cfg = parse_env_cfg(task_name, device=device, num_envs=num_envs)
151+
else:
152+
env_cfg = load_cfg_from_registry(task_name, "env_cfg_entry_point")
153+
env_cfg = resolve_presets(env_cfg, selected=(physics_preset_name,))
154+
env_cfg.sim.device = device
155+
env_cfg.scene.num_envs = num_envs
158156
if deterministic_mode is not None:
159157
assert isinstance(env_cfg.sim.physics, NewtonCfg)
160158
env_cfg.sim.physics.deterministic_mode = deterministic_mode

source/isaaclab_tasks/test/core/test_environments.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,45 @@
1616

1717
import pytest
1818

19+
from isaaclab.physics import PhysicsCfg
20+
1921
import isaaclab_tasks # noqa: F401
22+
from isaaclab_tasks.utils.hydra import collect_presets
23+
from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry
2024

2125
# Local imports should be imported last
2226
from env_test_utils import _run_environments, setup_environment # isort: skip
2327

2428

25-
@pytest.mark.parametrize("physics_preset_name", ["newton_mjwarp", "physx", "isaacsim_physx"])
29+
_PHYSICS_PRESET_NAMES = ("newton_mjwarp", "physx", "isaacsim_physx")
30+
31+
32+
def _core_physics_params() -> list:
33+
"""Return core task/backend pairs for explicitly supported physics presets."""
34+
params = []
35+
for task_param in setup_environment(multi_agent=False, tier="core"):
36+
task_name = getattr(task_param, "values", (task_param,))[0]
37+
marks = getattr(task_param, "marks", ())
38+
env_cfg = load_cfg_from_registry(task_name, "env_cfg_entry_point")
39+
physics_preset_groups = collect_presets(env_cfg).values()
40+
for physics_preset_name in _PHYSICS_PRESET_NAMES:
41+
if any(
42+
physics_preset_name in preset_group and isinstance(preset_group[physics_preset_name], PhysicsCfg)
43+
for preset_group in physics_preset_groups
44+
):
45+
params.append(
46+
pytest.param(
47+
task_name,
48+
physics_preset_name,
49+
id=f"{task_name}-{physics_preset_name}",
50+
marks=marks,
51+
)
52+
)
53+
return params
54+
55+
56+
@pytest.mark.parametrize("task_name, physics_preset_name", _core_physics_params())
2657
@pytest.mark.parametrize("num_envs, device", [(2, "cuda"), (1, "cuda")])
27-
@pytest.mark.parametrize(
28-
"task_name",
29-
setup_environment(
30-
multi_agent=False,
31-
tier="core",
32-
),
33-
)
3458
@pytest.mark.isaacsim_ci
3559
def test_environments(task_name, physics_preset_name, num_envs, device):
3660
# run environments without stage in memory

source/isaaclab_visualizers/changelog.d/default-newton-locomotion.skip

Whitespace-only changes.

source/isaaclab_visualizers/test/visualizer_integration_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,7 @@ def _make_anymal_d_env(visualizer_kind: str | tuple[str, ...], backend_kind: str
15851585
from isaaclab.envs import ManagerBasedRLEnv
15861586

15871587
env_cfg = copy.deepcopy(AnymalDFlatEnvCfg())
1588-
preset_key = "newton_mjwarp" if backend_kind == "newton" else "default"
1589-
env_cfg.sim.physics = getattr(env_cfg.sim.physics, preset_key)
1588+
env_cfg = _apply_env_cfg_preset(env_cfg, "newton_mjwarp" if backend_kind == "newton" else "physx")
15901589
env_cfg.scene.num_envs = (
15911590
_ANYMAL_D_TILED_CAMERA_INTEGRATION_NUM_ENVS if tiled_camera else _ANYMAL_D_INTEGRATION_NUM_ENVS
15921591
)

0 commit comments

Comments
 (0)