Skip to content

Commit 1b35411

Browse files
ooctipushujc7
authored andcommitted
Warp-first experimental envs implements lazy export + cfg implementation split (isaac-sim#5916)
- Adds Warp-first experimental environments and MDP terms under `isaaclab_experimental` and `isaaclab_tasks_experimental` (direct + manager-based cartpole/humanoid/ant/reach/locomotion), with Warp-kernel implementations of actions, observations, rewards, terminations, and events. - Adds lazy `__init__.py` + `.pyi` stubs (with explicit `__all__`) across the new/updated packages. - [ ] `./isaaclab.sh -p -m pytest source/isaaclab_tasks_experimental/test` - [ ] Train the experimental Warp cartpole/humanoid/ant configs on the Newton backend and confirm parity with the stable envs. - [ ] `./isaaclab.sh -p -m pytest source/isaaclab_physx/test/assets/test_newton_actuators_physx.py source/isaaclab_newton/test/assets/test_newton_actuators_newton.py` - [ ] Verify `randomize_rigid_body_scale` raises on Newton and warns (deprecated) on PhysX.
1 parent 463ae6e commit 1b35411

46 files changed

Lines changed: 557 additions & 331 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Internal: hoisted module-local backend imports (``pxr``/``sim_utils``) to module top in
2+
implementation files (``scene_data/scene_data_provider``, ``sim/schemas/schemas_actuators``,
3+
``envs/utils/camera_view``, ``terrains/utils``). No user-facing change.

source/isaaclab/isaaclab/envs/utils/camera_view.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
import torch
1515
import warp as wp
1616

17+
from pxr import UsdGeom
18+
1719
import isaaclab.sim as sim_utils
1820
from isaaclab.sensors.camera import Camera, CameraCfg
21+
from isaaclab.sim.views import FrameView
1922

2023
_GENERATED_CAMERA_NAME = "VisualizerCamera"
2124
VISUALIZER_TILED_CAMERA_MAX_TILES = 100
@@ -215,10 +218,6 @@ def prim_world_positions(
215218
Uses ``FrameView`` first so PhysX/Fabric-backed transforms are current; falls
216219
back to USD only if the backend view cannot be constructed.
217220
"""
218-
from pxr import UsdGeom
219-
220-
from isaaclab.sim.views import FrameView
221-
222221
xform_cache = UsdGeom.XformCache()
223222
positions = []
224223
try:

source/isaaclab/isaaclab/scene_data/scene_data_provider.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import numpy as np
1414
import warp as wp
1515

16+
from pxr import UsdGeom
17+
18+
import isaaclab.sim as sim_utils
19+
1620
from .scene_data_backend import SceneDataBackend, SceneDataFormat
1721

1822
if TYPE_CHECKING:
@@ -425,10 +429,6 @@ def _walk_camera_prims(stage: Usd.Stage | None) -> dict[str, Any] | None:
425429
if stage is None:
426430
return None
427431

428-
from pxr import UsdGeom
429-
430-
import isaaclab.sim as isaaclab_sim
431-
432432
shared_paths: list[str] = []
433433
instances: dict[str, list[tuple[int, str]]] = {}
434434
num_envs = -1
@@ -475,7 +475,7 @@ def _walk_camera_prims(stage: Usd.Stage | None) -> dict[str, Any] | None:
475475
prim = stage.GetPrimAtPath(prim_path)
476476
if not prim.IsValid():
477477
continue
478-
pos, ori = isaaclab_sim.resolve_prim_pose(prim)
478+
pos, ori = sim_utils.resolve_prim_pose(prim)
479479
per_world_pos[world_id] = [float(pos[0]), float(pos[1]), float(pos[2])]
480480
per_world_ori[world_id] = [float(ori[0]), float(ori[1]), float(ori[2]), float(ori[3])]
481481
positions.append(per_world_pos)

source/isaaclab/isaaclab/sim/schemas/schemas_actuators.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
import re
2525
from typing import Any
2626

27+
from pxr import Sdf, Usd
28+
29+
from isaaclab.actuators import ImplicitActuator
30+
from isaaclab.utils.string import resolve_matching_names
31+
2732
logger = logging.getLogger(__name__)
2833

2934

@@ -134,11 +139,6 @@ def _author_actuator_prims(
134139
actuator_cfgs: dict[str, Any],
135140
) -> None:
136141
"""Inner authoring routine; exposed separately for test fixtures."""
137-
from pxr import Sdf # noqa: PLC0415
138-
139-
from isaaclab.actuators import ImplicitActuator # noqa: PLC0415
140-
from isaaclab.utils.string import resolve_matching_names # noqa: PLC0415
141-
142142
art_prim = stage.GetPrimAtPath(articulation_prim_path)
143143
if not art_prim.IsValid():
144144
raise ValueError(f"Articulation prim not found: {articulation_prim_path}")
@@ -300,8 +300,6 @@ def _collect_joint_prims(art_prim: Any) -> dict[str, str]:
300300
Returns:
301301
Ordered mapping of joint name to full prim path.
302302
"""
303-
from pxr import Usd # noqa: PLC0415
304-
305303
_JOINT_TYPES = {"PhysicsRevoluteJoint", "PhysicsPrismaticJoint"}
306304

307305
joints: dict[str, str] = {}
@@ -324,8 +322,6 @@ def _remove_actuator_prims_for_joints(
324322
325323
Only prims under the *art_prim* subtree are considered.
326324
"""
327-
from pxr import Usd # noqa: PLC0415
328-
329325
to_deactivate: list = []
330326
for prim in Usd.PrimRange(art_prim):
331327
if prim.GetTypeName() != "NewtonActuator":

source/isaaclab/isaaclab/terrains/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import trimesh
1212
import warp as wp
1313

14+
from pxr import UsdGeom
15+
16+
import isaaclab.sim as sim_utils
1417
from isaaclab.utils.warp import raycast_mesh
1518

1619

@@ -78,11 +81,6 @@ def create_prim_from_mesh(prim_path: str, mesh: trimesh.Trimesh, **kwargs):
7881
visual_material: The visual material to apply. Defaults to None.
7982
physics_material: The physics material to apply. Defaults to None.
8083
"""
81-
# need to import these here to prevent isaacsim launching when importing this module
82-
from pxr import UsdGeom
83-
84-
import isaaclab.sim as sim_utils
85-
8684
# create parent prim
8785
sim_utils.create_prim(prim_path, "Xform")
8886
# create mesh prim
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Fixed
2+
^^^^^
3+
4+
* Fixed the experimental packages eagerly importing backend modules (``pxr``,
5+
``omni``, ``carb``, ``isaacsim``, ``scipy``) at import time, which crashed when
6+
a warp task's env config was loaded before ``SimulationApp`` was launched. The
7+
``managers``, ``envs``, ``envs.mdp`` and ``envs.mdp.actions`` packages now use
8+
``lazy_export`` with ``.pyi`` stubs, and the MDP term leaf modules guard runtime
9+
types (``Articulation``, ``InteractiveScene``, ``ContactSensor``, action terms)
10+
under ``TYPE_CHECKING`` with string ``class_type`` references.

source/isaaclab_experimental/isaaclab_experimental/envs/__init__.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@
4242
.. _`Task Design Workflows`: https://isaac-sim.github.io/IsaacLab/source/features/task_workflows.html
4343
"""
4444

45-
from .direct_rl_env_warp import DirectRLEnvWarp # noqa: F401
46-
from .interactive_scene_warp import InteractiveSceneWarp # noqa: F401
47-
from .manager_based_env_warp import ManagerBasedEnvWarp # noqa: F401
48-
from .manager_based_rl_env_warp import ManagerBasedRLEnvWarp # noqa: F401
49-
50-
__all__ = [
51-
"DirectRLEnvWarp",
52-
"InteractiveSceneWarp",
53-
"ManagerBasedEnvWarp",
54-
"ManagerBasedRLEnvWarp",
55-
]
45+
from isaaclab.utils.module import lazy_export
46+
47+
lazy_export()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
__all__ = [
7+
"mdp",
8+
"DirectRLEnvWarp",
9+
"InteractiveSceneWarp",
10+
"ManagerBasedEnvWarp",
11+
"ManagerBasedRLEnvWarp",
12+
]
13+
14+
from . import mdp
15+
from .direct_rl_env_warp import DirectRLEnvWarp
16+
from .interactive_scene_warp import InteractiveSceneWarp
17+
from .manager_based_env_warp import ManagerBasedEnvWarp
18+
from .manager_based_rl_env_warp import ManagerBasedRLEnvWarp

source/isaaclab_experimental/isaaclab_experimental/envs/mdp/__init__.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@
99
functions with Warp-first implementations from :mod:`isaaclab_experimental.envs.mdp.rewards`.
1010
"""
1111

12-
# Forward stable MDP terms (commands/observations/terminations/etc.) but *exclude* rewards and actions.
13-
# Rewards and actions are provided by this experimental package to keep Warp-first execution.
14-
from isaaclab.envs.mdp.commands import * # noqa: F401, F403
15-
from isaaclab.envs.mdp.curriculums import * # noqa: F401, F403
16-
from isaaclab.envs.mdp.events import * # noqa: F401, F403
17-
from isaaclab.envs.mdp.observations import * # noqa: F401, F403
18-
from isaaclab.envs.mdp.recorders import * # noqa: F401, F403
19-
from isaaclab.envs.mdp.terminations import * # noqa: F401, F403
12+
from isaaclab.utils.module import lazy_export
2013

21-
# Override terms with experimental implementations.
22-
from .actions import * # noqa: F401, F403
23-
from .events import * # noqa: F401, F403
24-
from .observations import * # noqa: F401, F403
25-
from .rewards import * # noqa: F401, F403
26-
from .terminations import * # noqa: F401, F403
14+
lazy_export()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
# Forward all stable MDP terms (commands/curriculums/events/observations/...) via a
7+
# lazy fallback, so unresolved names defer to the stable package without eagerly
8+
# importing its backend-dependent submodules.
9+
from isaaclab.envs.mdp import * # noqa: F401, F403
10+
11+
# Experimental Warp-first action terms. Listed by name (not ``*``) so the runtime
12+
# implementations in ``joint_actions`` stay lazy and only the pure-data config
13+
# classes are imported when an env config is constructed.
14+
from .actions import ( # noqa: F401
15+
JointAction,
16+
JointActionCfg,
17+
JointEffortAction,
18+
JointEffortActionCfg,
19+
JointPositionAction,
20+
JointPositionActionCfg,
21+
)
22+
23+
# Override stable terms with experimental Warp-first implementations. These leaf
24+
# modules are import-clean (no eager backend imports), so re-exporting them here
25+
# is safe.
26+
from .events import * # noqa: F401, F403
27+
from .observations import * # noqa: F401, F403
28+
from .rewards import * # noqa: F401, F403
29+
from .terminations import * # noqa: F401, F403

0 commit comments

Comments
 (0)