Skip to content

Conversation

@pascal-roth
Copy link
Collaborator

@pascal-roth pascal-roth commented Nov 2, 2025

Description

DO NOT REVIEW - WILL BE SPLIT IN SMALLER PRs

Remove dependency on IsaacSim utils for integration of new simulation engines like newton. Main points will be dependency on SimulationContext and SimulationManager that should be removed in another PR.

Dependencies to be removed (TODO):

import isaacsim.core.utils.torch as torch_utils

is used in assembly_env.py, disassembly_env.py, factory_control.py factory_env.py, factory_utils.py, forge_env.py, forge_utils.py and locomotion_envs.py. Most of the functions also exist in our math_utils.py.

from isaacsim.core.prims import Articulation, RigidPrim, SingleGeometryPrim, SingleRigidPrim

is used in some of our tests.

import isaacsim.core.utils.numpy as backend_utils

used in prims.py.

Dependencies that can stay
Those extensions will only be used with kit / isaacsim, so we keep them in for now.

from isaacsim.core.version import get_version
from isaacsim.core.utils.extensions import enable_extension
from isaacsim.core.utils.carb import get_carb_setting, set_carb_setting
from isaacsim.core.utils.viewports import set_camera_view

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions bot added enhancement New feature or request isaac-lab Related to Isaac Lab team labels Nov 2, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR removes dependencies on IsaacSim utils by copying utility functions into isaaclab's own utils package. The changes systematically replace imports from isaacsim.core.utils.{prims,stage,semantics} with isaaclab.utils.{prims,stage,semantics} across 81 files.

Key changes:

  • Created new utility modules: prims.py, stage.py, semantics.py, seed.py
  • Added utility functions to string.py and type mappings to types.py
  • Updated all imports across assets, sensors, spawners, environments, and tests

Issues found:

  • Circular import between prims.py and semantics.py (works but fragile)
  • prims.py still depends on isaacsim.core.utils._isaac_utils._find_matching_prim_paths
  • seed.py missing newline at EOF and incomplete docstring

The overall approach is sound for decoupling from IsaacSim, but the circular import should be resolved and the remaining IsaacSim dependency addressed to fully achieve the stated goal.

Confidence Score: 4/5

  • This PR is safe to merge with minor concerns about code quality
  • The PR successfully migrates most IsaacSim utils dependencies to isaaclab's own utils package. However, there are three issues: (1) a circular import between prims.py and semantics.py that works but is fragile, (2) prims.py still depends on _find_matching_prim_paths from IsaacSim utils, partially defeating the purpose, and (3) minor style issues like missing newline and incomplete docstring in seed.py. The changes are systematic and well-structured, but these issues should be addressed for a complete decoupling.
  • Pay attention to source/isaaclab/isaaclab/utils/prims.py (circular import and remaining IsaacSim dependency) and source/isaaclab/isaaclab/utils/seed.py (formatting issues)

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/utils/prims.py 3/5 New file copying prim utilities from IsaacSim. Contains circular import with semantics.py and still depends on _find_matching_prim_paths from IsaacSim utils.
source/isaaclab/isaaclab/utils/stage.py 5/5 New file copying stage utilities from IsaacSim. Appears clean with no dependencies on IsaacSim utils.
source/isaaclab/isaaclab/utils/semantics.py 4/5 New file copying semantics utilities from IsaacSim. Contains circular import with prims.py.
source/isaaclab/isaaclab/utils/seed.py 4/5 New file with seed setting utility. Missing newline at EOF and incomplete docstring.
source/isaaclab/isaaclab/utils/string.py 5/5 Added new utility functions find_unique_string_name and find_root_prim_path_from_regex. Clean implementation.

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant Assets as isaaclab.assets
    participant Spawners as isaaclab.sim.spawners
    participant SimUtils as isaaclab.sim.utils
    participant Prims as isaaclab.utils.prims
    participant Stage as isaaclab.utils.stage
    participant Semantics as isaaclab.utils.semantics
    participant IsaacSim as isaacsim.core.utils._isaac_utils

    Note over App,IsaacSim: Before: Direct IsaacSim dependencies
    App->>Assets: Use assets
    Assets->>IsaacSim: import isaacsim.core.utils.prims
    
    Note over App,IsaacSim: After: Abstracted through isaaclab.utils
    App->>Assets: Use assets
    Assets->>Prims: import isaaclab.utils.prims
    Prims->>Semantics: import add_labels
    Semantics->>Prims: import prim_utils (circular!)
    Prims->>Stage: import get_current_stage
    Prims->>IsaacSim: import _find_matching_prim_paths (still depends!)
    
    App->>Spawners: Spawn objects
    Spawners->>Prims: Use prim utilities
    Spawners->>Stage: Use stage utilities
    
    App->>SimUtils: Simulation operations
    SimUtils->>Stage: Use stage utilities
Loading

81 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

# omniverse
from pxr import Sdf, Usd, UsdGeom, UsdPhysics

from isaaclab.utils.semantics import add_labels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: circular import between prims.py and semantics.py - prims.py imports add_labels from semantics.py (line 22), while semantics.py imports prim_utils from prims.py (line 27). This works in Python due to lazy evaluation, but it's fragile and could cause issues if the import order changes or if these modules are imported before they're fully initialized.

torch.backends.cudnn.benchmark = True
torch.backends.cudnn.deterministic = False

return seed No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: missing newline at end of file

Suggested change
return seed
return seed



def set_seed(seed: int, torch_deterministic: bool = False) -> int:
"""set seed across modules"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing docstring describing parameters and return value. Should document seed and torch_deterministic parameters.

import usdrt

# isaacsim
from isaacsim.core.utils._isaac_utils import _find_matching_prim_paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: still depends on isaacsim.core.utils._isaac_utils._find_matching_prim_paths. This partially defeats the purpose of removing IsaacSim utils dependencies. Consider implementing this function locally or finding an alternative.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR successfully removes most dependencies on isaacsim.core.utils by creating local implementations in isaaclab.utils. The refactoring covers three main areas:

Major Changes:

  • Created isaaclab.utils.stage with ~800 lines implementing stage management functions (previously in isaacsim.core.utils.stage and sim.utils)
  • Created isaaclab.utils.seed providing set_seed() to replace isaacsim.core.utils.torch.set_seed()
  • Created isaaclab.utils.prims with prim manipulation utilities (previously using isaacsim.core.utils.prims)
  • Updated 18 files across envs, spawners, sensors, and scene modules to use new local utilities

Key Improvements:

  • Better version compatibility handling for Isaac Sim < 5.0 vs >= 5.0
  • Thread-local stage context management in utils/stage.py
  • Consolidation of stage utilities from multiple locations into single module

Remaining Issues:

  • utils/prims.py still depends on isaacsim.core.utils._isaac_utils._find_matching_prim_paths (line 11) and isaacsim.core.prims.XFormPrim (lines 703, 720, 737)
  • Circular import between prims.py and semantics.py (works but fragile)
  • Missing docstring and EOF newline in seed.py

The PR makes substantial progress toward the stated goal, but doesn't fully eliminate IsaacSim utils dependencies in prims.py.

Confidence Score: 3/5

  • Safe to merge with known limitations - core functionality works but goal is partially achieved
  • Score reflects that while the refactoring is well-executed and most dependencies are removed, utils/prims.py still has critical dependencies on isaacsim.core.utils._isaac_utils._find_matching_prim_paths and isaacsim.core.prims.XFormPrim. These remaining dependencies partially defeat the PR's stated purpose of removing IsaacSim utils dependencies to support new simulation engines like Newton. The code quality is good and changes are backwards compatible, but the incomplete dependency removal is a significant concern relative to the PR's objectives.
  • source/isaaclab/isaaclab/utils/prims.py requires attention due to remaining IsaacSim dependencies that conflict with the PR's goal

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/utils/prims.py 3/5 Created new utils/prims.py but still depends on isaacsim.core.utils._isaac_utils._find_matching_prim_paths (line 11) and isaacsim.core.prims.XFormPrim (line 703, 720, 737), partially defeating the goal
source/isaaclab/isaaclab/utils/stage.py 4/5 Successfully implements stage utilities locally, provides good version compatibility checks for Isaac Sim < 5.0 and >= 5.0, includes proper thread-local stage context management
source/isaaclab/isaaclab/utils/seed.py 4/5 New set_seed function properly replaces isaacsim.core.utils.torch.set_seed, handles all seeding requirements for numpy, torch, warp. Missing newline at EOF and docstring
source/isaaclab/isaaclab/sim/utils.py 5/5 Removed 150 lines of stage management functions (now in utils/stage.py), cleaned up imports, maintains backwards compatibility for other utility functions
source/isaaclab/isaaclab/sim/simulation_context.py 5/5 Successfully replaced isaacsim.core.utils.stage with isaaclab.utils.stage, updated imports for stage utility functions

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant Env as Environment (direct_rl_env)
    participant Stage as isaaclab.utils.stage
    participant Prims as isaaclab.utils.prims
    participant Seed as isaaclab.utils.seed
    participant SimCtx as SimulationContext
    participant IsaacUtils as isaacsim.core.utils (OLD)
    participant IsaacPrims as isaacsim.core.prims (STILL USED)
    
    Note over App,IsaacPrims: Before: Dependencies on isaacsim.core.utils
    App->>Env: seed(42)
    Env->>IsaacUtils: set_seed() [REMOVED]
    
    App->>SimCtx: create stage
    SimCtx->>IsaacUtils: create_new_stage_in_memory() [REMOVED]
    SimCtx->>IsaacUtils: use_stage() [REMOVED]
    
    Note over App,IsaacPrims: After: New local utilities in isaaclab.utils
    App->>Env: seed(42)
    Env->>Seed: set_seed() [NEW]
    
    App->>SimCtx: create stage
    SimCtx->>Stage: create_new_stage_in_memory() [NEW]
    SimCtx->>Stage: use_stage() [NEW]
    SimCtx->>Stage: get_current_stage() [NEW]
    
    App->>Prims: create_prim()
    Prims->>IsaacPrims: XFormPrim() [STILL DEPENDS]
    Prims->>IsaacUtils: _find_matching_prim_paths() [STILL DEPENDS]
    
    Note over Prims,IsaacPrims: Partial dependency remains in prims.py
Loading

18 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile


import omni.usd
import usdrt
from isaacsim.core.utils._isaac_utils import _find_matching_prim_paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: still depends on isaacsim.core.utils._isaac_utils._find_matching_prim_paths. This partially defeats the purpose of removing IsaacSim utils dependencies. Consider implementing this function locally or finding an alternative approach.

Comment on lines 703 to 737
from isaacsim.core.prims import XFormPrim

# create prim in stage
prim = define_prim(prim_path=prim_path, prim_type=prim_type)
if not prim:
return None
# apply attributes into prim
if attributes is not None:
for k, v in attributes.items():
prim.GetAttribute(k).Set(v)
# add reference to USD file
if usd_path is not None:
add_reference_to_stage(usd_path=usd_path, prim_path=prim_path)
# add semantic label to prim
if semantic_label is not None:
add_labels(prim, labels=[semantic_label], instance_name=semantic_type)
# apply the transformations
from isaacsim.core.api.simulation_context.simulation_context import SimulationContext

if SimulationContext.instance() is None:
import isaacsim.core.utils.numpy as backend_utils

device = "cpu"
else:
backend_utils = SimulationContext.instance().backend_utils
device = SimulationContext.instance().device
if position is not None:
position = backend_utils.expand_dims(backend_utils.convert(position, device), 0)
if translation is not None:
translation = backend_utils.expand_dims(backend_utils.convert(translation, device), 0)
if orientation is not None:
orientation = backend_utils.expand_dims(backend_utils.convert(orientation, device), 0)
if scale is not None:
scale = backend_utils.expand_dims(backend_utils.convert(scale, device), 0)
XFormPrim(prim_path, positions=position, translations=translation, orientations=orientation, scales=scale)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: function still depends on isaacsim.core.prims.XFormPrim (lines 703, 720, 737) and isaacsim.core.api.simulation_context.SimulationContext (line 720). This creates a continued dependency on IsaacSim core utilities that conflicts with the PR's goal of removing such dependencies.

Comment on lines 15 to 22
from isaaclab.utils.semantics import add_labels
from isaaclab.utils.stage import add_reference_to_stage, get_current_stage, get_current_stage_id
from isaaclab.utils.types import SDF_type_to_Gf


def get_prim_at_path(prim_path: str, fabric: bool = False) -> Usd.Prim | usdrt.Usd._Usd.Prim:
"""Get the USD or Fabric Prim at a given path string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: circular import exists between prims.py and semantics.py. While this works due to lazy evaluation, it's fragile. The imports at the module level in semantics.py:9 and here create a circular dependency that could cause issues if import order changes.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR successfully removes most IsaacSim utility dependencies by copying utility functions from isaacsim.core.utils.prims, isaacsim.core.utils.stage, and related modules into IsaacLab's own utils package.

Key changes:

  • Created new utility modules: isaaclab.utils.prims, isaaclab.utils.stage, isaaclab.utils.semantics, isaaclab.utils.seed, isaaclab.utils.string, and isaaclab.utils.types
  • Replaced imports from isaacsim.core.utils.prims with isaaclab.utils.prims and sim_utils.find_matching_prim_paths throughout the codebase
  • Updated all test files to use the new IsaacLab utility imports
  • Removed test_find_matching_prim_paths test since the function is now part of IsaacLab

Known issues (acknowledged in PR description):

  • SimulationContext and SimulationManager dependencies remain (to be addressed in future PR)
  • Some functions still use IsaacSim core utilities internally (e.g., XFormPrim, backend_utils)
  • Extensions, version checks, and Carb settings utilities intentionally kept as they're kit/isaacsim-specific

The PR makes solid progress toward the goal of supporting alternative simulation engines like Newton by reducing IsaacSim dependencies.

Confidence Score: 4/5

  • Safe to merge with minor architectural concerns about remaining dependencies
  • The refactoring correctly migrates utility functions to IsaacLab's own codebase. The test file imports are properly updated, and the new functions maintain backward compatibility. Score reduced from 5 due to: (1) circular import pattern between prims.py and semantics.py, and (2) remaining IsaacSim dependencies in create_prim function that partially contradict the PR's stated goal.
  • source/isaaclab/isaaclab/utils/prims.py requires attention for circular imports and remaining IsaacSim dependencies in create_prim function

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/controllers/rmp_flow.py 4/5 Successfully replaced isaacsim.core.utils.prims.find_matching_prim_paths with sim_utils.find_matching_prim_paths. Still depends on SimulationContext and SingleArticulation from IsaacSim core, which aligns with PR's TODO list.
source/isaaclab/isaaclab/utils/prims.py 3/5 New file that copies prim utilities from IsaacSim. Contains dependencies on isaacsim.core.prims.XFormPrim, SimulationContext, and backend_utils in the create_prim function. Circular import exists between prims.py and semantics.py.

Sequence Diagram

sequenceDiagram
    participant User
    participant Controller as RmpFlowController
    participant SimUtils as sim_utils
    participant PrimUtils as isaaclab.utils.prims
    participant Stage as USD Stage
    
    User->>Controller: initialize(prim_paths_expr)
    Controller->>SimUtils: find_matching_prim_paths(prim_paths_expr)
    SimUtils->>Stage: Get matching prims
    Stage-->>SimUtils: Return prim list
    SimUtils-->>Controller: Return prim paths
    
    Note over Controller,PrimUtils: Previously used isaacsim.core.utils.prims
    Note over Controller,SimUtils: Now uses isaaclab.sim.utils
    
    User->>PrimUtils: create_prim(path, config)
    PrimUtils->>Stage: define_prim()
    Stage-->>PrimUtils: Return prim
    Note over PrimUtils: Still uses XFormPrim from isaacsim.core
    PrimUtils-->>User: Return created prim
Loading

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +14 to +15
import isaaclab.sim as sim_utils
from isaaclab.utils.semantics import add_labels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: circular import between prims.py and semantics.py - prims.py imports from semantics.py (line 15) while semantics.py imports from prims.py (semantics.py:9). works due to lazy evaluation but fragile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR makes progress toward removing IsaacSim utils dependencies by copying utility functions from isaacsim.core.utils into isaaclab.utils and updating imports across the codebase. Five new utility files were added: nucleus.py, prims.py, seed.py, semantics.py, and stage.py.

Key Changes:

  • Created abstraction layer in isaaclab.utils to reduce direct isaacsim.core.utils dependencies
  • Updated 84 files to use new isaaclab.utils imports instead of isaacsim.core.utils
  • Replaced isaacsim.core.utils.torch.set_seed() with new isaaclab.utils.seed.set_seed()
  • Moved stage and prim utility functions from IsaacSim to IsaacLab namespace

Critical Issue:
The create_prim() function in prims.py:676-713 still depends on isaacsim.core.prims.XFormPrim, SimulationContext, and backend_utils, which contradicts the PR's goal. This function is used throughout the codebase and represents incomplete dependency removal.

Additional Issues:

  • Circular import between prims.py and semantics.py
  • Missing docstring in seed.py
  • Missing newline at EOF in seed.py
  • stage.py still depends on SimulationManager from IsaacSim

The PR represents a good first step but does not fully achieve its stated goal of removing IsaacSim utils dependencies.

Confidence Score: 2/5

  • Not safe to merge - core functionality still depends on IsaacSim utils, contradicting PR goals
  • Score reflects that while the PR successfully moves many utility functions, the create_prim() function retains critical IsaacSim dependencies (XFormPrim, SimulationContext, backend_utils) that are used throughout the codebase. This defeats the primary purpose of the PR. The circular imports and missing documentation are secondary concerns but further reduce confidence.
  • source/isaaclab/isaaclab/utils/prims.py requires immediate attention - the create_prim() function at lines 676-713 must have its IsaacSim dependencies removed or the PR scope must be adjusted

Important Files Changed

File Analysis

Filename Score Overview
source/isaaclab/isaaclab/utils/prims.py 2/5 New utility file with critical issues: create_prim() function (lines 676-713) still depends on isaacsim.core.prims.XFormPrim, SimulationContext, and backend_utils, defeating the PR's goal of removing IsaacSim dependencies. Circular import with semantics.py.
source/isaaclab/isaaclab/utils/seed.py 4/5 New utility for seed setting functionality - missing docstring and newline at EOF. Functionality is correct but needs documentation.
source/isaaclab/isaaclab/utils/semantics.py 4/5 New utility for semantic labeling - circular import with prims.py (line 9 imports from prims, prims line 15 imports from semantics). Otherwise well-structured.
source/isaaclab/isaaclab/utils/stage.py 4/5 New utility for stage management - depends on isaacsim.core APIs (SimulationManager, SimulationContext) in attach_stage_to_usd_context(). Circular dependency with prims.py.

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant Utils as isaaclab.utils.*
    participant Sim as isaaclab.sim
    participant IsaacSim as isaacsim.core
    
    Note over App,IsaacSim: Before PR: Direct IsaacSim Dependencies
    App->>IsaacSim: import isaacsim.core.utils.prims
    App->>IsaacSim: import isaacsim.core.utils.stage
    App->>IsaacSim: import isaacsim.core.utils.torch
    IsaacSim-->>App: Direct coupling
    
    Note over App,IsaacSim: After PR: Abstracted Dependencies
    App->>Utils: import isaaclab.utils.prims
    App->>Utils: import isaaclab.utils.stage
    App->>Utils: import isaaclab.utils.seed
    Utils->>Sim: find_matching_prim_paths()
    Utils->>IsaacSim: create_prim() still uses XFormPrim
    Utils->>IsaacSim: create_prim() still uses SimulationContext
    Utils->>IsaacSim: create_prim() still uses backend_utils
    Note over Utils,IsaacSim: Some IsaacSim dependencies remain in utils layer
    IsaacSim-->>Utils: Partial decoupling
    Utils-->>App: Abstraction layer created
Loading

6 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +676 to +713
from isaacsim.core.prims import XFormPrim

# create prim in stage
prim = define_prim(prim_path=prim_path, prim_type=prim_type)
if not prim:
return None
# apply attributes into prim
if attributes is not None:
for k, v in attributes.items():
prim.GetAttribute(k).Set(v)
# add reference to USD file
if usd_path is not None:
add_reference_to_stage(usd_path=usd_path, prim_path=prim_path)
# add semantic label to prim
if semantic_label is not None:
add_labels(prim, labels=[semantic_label], instance_name=semantic_type)
# apply the transformations
from isaacsim.core.api.simulation_context.simulation_context import SimulationContext

if SimulationContext.instance() is None:
# FIXME: remove this, we should never even use backend utils especially not numpy ones
import isaacsim.core.utils.numpy as backend_utils

device = "cpu"
else:
backend_utils = SimulationContext.instance().backend_utils
device = SimulationContext.instance().device
if position is not None:
position = backend_utils.expand_dims(backend_utils.convert(position, device), 0)
if translation is not None:
translation = backend_utils.expand_dims(backend_utils.convert(translation, device), 0)
if orientation is not None:
orientation = backend_utils.expand_dims(backend_utils.convert(orientation, device), 0)
if scale is not None:
scale = backend_utils.expand_dims(backend_utils.convert(scale, device), 0)
XFormPrim(prim_path, positions=position, translations=translation, orientations=orientation, scales=scale)

return prim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: create_prim() still imports and depends on isaacsim.core.prims.XFormPrim (line 676), isaacsim.core.api.simulation_context.SimulationContext (line 693), and isaacsim.core.utils.numpy backend_utils (line 697). This directly conflicts with the PR's stated goal of removing IsaacSim utils dependencies. These dependencies should be removed or the PR description should acknowledge that create_prim() will maintain IsaacSim dependencies.

from pxr import Sdf, Usd, UsdGeom, UsdPhysics

import isaaclab.sim as sim_utils
from isaaclab.utils.semantics import add_labels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: circular import - prims.py imports add_labels from semantics.py while semantics.py:9 imports prim_utils from prims.py. works due to lazy evaluation but fragile and could break if import order changes

import warp as wp


def set_seed(seed: int, torch_deterministic: bool = False) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing docstring for parameters and return value

Suggested change
def set_seed(seed: int, torch_deterministic: bool = False) -> int:
def set_seed(seed: int, torch_deterministic: bool = False) -> int:
"""Set seed across modules.
Args:
seed: Random seed to use. If -1, generates a random seed (or uses 42 if torch_deterministic is True).
torch_deterministic: Whether to enable deterministic operations in PyTorch.
Returns:
The seed that was set.
"""

torch.backends.cudnn.benchmark = True
torch.backends.cudnn.deterministic = False

return seed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: missing newline at end of file

Suggested change
return seed
return seed

Comment on lines +45 to +107
def attach_stage_to_usd_context(attaching_early: bool = False):
"""Attaches the current USD stage in memory to the USD context.
This function should be called during or after scene is created and before stage is simulated or rendered.
Note:
If the stage is not in memory or rendering is not enabled, this function will return without attaching.
Args:
attaching_early: Whether to attach the stage to the usd context before stage is created. Defaults to False.
"""

from isaacsim.core.simulation_manager import SimulationManager

from isaaclab.sim.simulation_context import SimulationContext

# if Isaac Sim version is less than 5.0, stage in memory is not supported
isaac_sim_version = float(".".join(get_version()[2]))
if isaac_sim_version < 5:
return

# if stage is not in memory, we can return early
if not is_current_stage_in_memory():
return

# attach stage to physx
stage_id = get_current_stage_id()
physx_sim_interface = omni.physx.get_physx_simulation_interface()
physx_sim_interface.attach_stage(stage_id)

# this carb flag is equivalent to if rendering is enabled
carb_setting = carb.settings.get_settings()
is_rendering_enabled = get_carb_setting(carb_setting, "/physics/fabricUpdateTransformations")

# if rendering is not enabled, we don't need to attach it
if not is_rendering_enabled:
return

# early attach warning msg
if attaching_early:
omni.log.warn(
"Attaching stage in memory to USD context early to support an operation which doesn't support stage in"
" memory."
)

# skip this callback to avoid wiping the stage after attachment
SimulationContext.instance().skip_next_stage_open_callback()

# disable stage open callback to avoid clearing callbacks
SimulationManager.enable_stage_open_callback(False)

# enable physics fabric
SimulationContext.instance()._physics_context.enable_fabric(True)

# attach stage to usd context
omni.usd.get_context().attach_stage_with_callback(stage_id)

# attach stage to physx
physx_sim_interface = omni.physx.get_physx_simulation_interface()
physx_sim_interface.attach_stage(stage_id)

# re-enable stage open callback
SimulationManager.enable_stage_open_callback(True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: attach_stage_to_usd_context() depends on isaacsim.core.simulation_manager.SimulationManager (line 57) and isaaclab.sim.simulation_context.SimulationContext (line 59). while SimulationContext is from isaaclab, the function still requires IsaacSim's SimulationManager. consider documenting this as an acceptable dependency or finding alternative

@pascal-roth pascal-roth self-assigned this Nov 2, 2025
@Mayankm96
Copy link
Contributor

These two dependencies are pretty minimal. We can omit them to use the base kit functions directly.

from isaacsim.core.utils.extensions import enable_extension
from isaacsim.core.utils.carb import get_carb_setting, set_carb_setting

from isaacsim.core.prims import XFormPrim

import isaaclab.utils.math as math_utils
import isaaclab.utils.stage as stage_utils
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm we purposefully kept all the sim related utils to isaaclab.sim module. The idea was to keep all general ones in isaaclab.utils (such as math, IO, warp etc.) that shouldn't depend on Kit to run at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes a lot of sense, I move all of these utils to the sim folder. That will include

  • stage
  • prims
  • semantics
  • carb
  • extensions


import isaaclab.sim as sim_utils
from isaaclab.utils.semantics import add_labels
from isaaclab.utils.stage import add_reference_to_stage, get_current_stage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of removing these one-line wrapper over USD functions. Users should get the stage and do these steps on their own. These wrappers don't provide any benefit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could replace them in our codebase, for users it could make sense to include the utils with a depreciation warning or what do you think?

@pascal-roth
Copy link
Collaborator Author

split in smaller PRs

@pascal-roth pascal-roth closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants