Skip to content

Commit 91288ba

Browse files
committed
Defer clone backend stage configuration
1 parent 186c248 commit 91288ba

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

source/isaaclab_ov/isaaclab_ov/cloner/replicate.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import numpy as np
1414

15-
from pxr import Gf, Sdf, Usd, UsdGeom
15+
from pxr import Gf, Usd, UsdGeom
1616

1717
from isaaclab import cloner
1818
from isaaclab.physics import PhysicsManager
@@ -116,9 +116,6 @@ def __init__(self, sim_context: SimulationContext):
116116
"""
117117
self._sim = sim_context
118118
self.stage = sim_context.stage
119-
physics_scene_prim = self.stage.GetPrimAtPath("/physicsScene")
120-
if physics_scene_prim.IsValid():
121-
physics_scene_prim.CreateAttribute("physxScene:envIdInBoundsBitCount", Sdf.ValueTypeNames.Int).Set(4)
122119

123120
def replicate(self, plan: ClonePlan) -> None:
124121
"""Publish clone operations from this context's plan rows.

source/isaaclab_ov/isaaclab_ov/physics/ovphysx_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import numpy as np
2525
import warp as wp
2626

27-
from pxr import UsdPhysics
27+
from pxr import Sdf, UsdPhysics
2828

2929
from isaaclab.physics import PhysicsEvent, PhysicsManager
3030
from isaaclab.scene_data import SceneDataBackend, SceneDataFormat
@@ -946,6 +946,8 @@ def _warmup_and_load(cls) -> None:
946946

947947
scene_prim = sim.stage.GetPrimAtPath(sim.cfg.physics_prim_path)
948948
if scene_prim.IsValid():
949+
if cls._active_clone_recipes:
950+
scene_prim.CreateAttribute("physxScene:envIdInBoundsBitCount", Sdf.ValueTypeNames.Int).Set(4)
949951
cls._configure_physx_scene_prim(scene_prim, PhysicsManager._cfg, ovphysx_device)
950952

951953
# Flatten the current USD stage to USDA text so OVStage can populate it
@@ -1107,8 +1109,6 @@ def _configure_physx_scene_prim(scene_prim, cfg, device: str) -> None:
11071109
values. The GPU buffer-capacity values are only consulted when ``device == "gpu"``.
11081110
device: Resolved physics device — one of ``"cpu"`` or ``"gpu"``.
11091111
"""
1110-
from pxr import Sdf
1111-
11121112
schemas = Sdf.TokenListOp()
11131113
current = scene_prim.GetMetadata("apiSchemas") or Sdf.TokenListOp()
11141114
items = list(current.prependedItems) if current.prependedItems else []

source/isaaclab_physx/isaaclab_physx/cloner/replicate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def __init__(self, stage: Usd.Stage):
3434
cache = UsdUtils.StageCache.Get()
3535
cached_id = cache.GetId(stage)
3636
self._stage_id = cached_id.ToLongInt() if cached_id.IsValid() else cache.Insert(stage).ToLongInt()
37-
physics_scene_prim = self.stage.GetPrimAtPath("/physicsScene")
38-
if physics_scene_prim.IsValid():
39-
physics_scene_prim.CreateAttribute("physxScene:envIdInBoundsBitCount", Sdf.ValueTypeNames.Int).Set(4)
4037

4138
def replicate(self, plan: ClonePlan) -> None:
4239
"""Register the PhysX replicator for this context's plan rows.
@@ -102,6 +99,10 @@ def _replicate_mapping(
10299
if all(len(envs) == 1 and src == destination.format(envs[0]) for src, destination, envs in physx_queue):
103100
return
104101

102+
physics_scene_prim = self.stage.GetPrimAtPath("/physicsScene")
103+
if physics_scene_prim.IsValid():
104+
physics_scene_prim.CreateAttribute("physxScene:envIdInBoundsBitCount", Sdf.ValueTypeNames.Int).Set(4)
105+
105106
current_worlds: list[int] = []
106107
current_template: str = ""
107108
prefixes = [cloner.path.split(destination)[0] for destination in destinations]

0 commit comments

Comments
 (0)