-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Removes dependency on isaacsim utils #3914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.pyand type mappings totypes.py - Updated all imports across assets, sensors, spawners, environments, and tests
Issues found:
- Circular import between
prims.pyandsemantics.py(works but fragile) prims.pystill depends onisaacsim.core.utils._isaac_utils._find_matching_prim_pathsseed.pymissing 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_pathsfrom 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) andsource/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
81 files reviewed, 4 comments
| # omniverse | ||
| from pxr import Sdf, Usd, UsdGeom, UsdPhysics | ||
|
|
||
| from isaaclab.utils.semantics import add_labels |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| return seed | |
| return seed |
|
|
||
|
|
||
| def set_seed(seed: int, torch_deterministic: bool = False) -> int: | ||
| """set seed across modules""" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.stagewith ~800 lines implementing stage management functions (previously inisaacsim.core.utils.stageandsim.utils) - Created
isaaclab.utils.seedprovidingset_seed()to replaceisaacsim.core.utils.torch.set_seed() - Created
isaaclab.utils.primswith prim manipulation utilities (previously usingisaacsim.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.pystill depends onisaacsim.core.utils._isaac_utils._find_matching_prim_paths(line 11) andisaacsim.core.prims.XFormPrim(lines 703, 720, 737)- Circular import between
prims.pyandsemantics.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.pystill has critical dependencies onisaacsim.core.utils._isaac_utils._find_matching_prim_pathsandisaacsim.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.pyrequires 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
18 files reviewed, 3 comments
|
|
||
| import omni.usd | ||
| import usdrt | ||
| from isaacsim.core.utils._isaac_utils import _find_matching_prim_paths |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
| 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 | ||
There was a problem hiding this comment.
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.
There was a problem hiding this 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, andisaaclab.utils.types - Replaced imports from
isaacsim.core.utils.primswithisaaclab.utils.primsandsim_utils.find_matching_prim_pathsthroughout the codebase - Updated all test files to use the new IsaacLab utility imports
- Removed
test_find_matching_prim_pathstest since the function is now part of IsaacLab
Known issues (acknowledged in PR description):
SimulationContextandSimulationManagerdependencies 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
5 files reviewed, 1 comment
| import isaaclab.sim as sim_utils | ||
| from isaaclab.utils.semantics import add_labels |
There was a problem hiding this comment.
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
There was a problem hiding this 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.utilsto reduce directisaacsim.core.utilsdependencies - Updated 84 files to use new
isaaclab.utilsimports instead ofisaacsim.core.utils - Replaced
isaacsim.core.utils.torch.set_seed()with newisaaclab.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.pyandsemantics.py - Missing docstring in
seed.py - Missing newline at EOF in
seed.py stage.pystill depends onSimulationManagerfrom 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.pyrequires immediate attention - thecreate_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
6 files reviewed, 5 comments
| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
| 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 |
There was a problem hiding this comment.
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
| return seed | |
| return seed | |
| 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) |
There was a problem hiding this comment.
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
|
These two dependencies are pretty minimal. We can omit them to use the base kit functions directly. |
| from isaacsim.core.prims import XFormPrim | ||
|
|
||
| import isaaclab.utils.math as math_utils | ||
| import isaaclab.utils.stage as stage_utils |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
|
split in smaller PRs |
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 onSimulationContextandSimulationManagerthat should be removed in another PR.Dependencies to be removed (TODO):
is used in
assembly_env.py,disassembly_env.py,factory_control.pyfactory_env.py,factory_utils.py,forge_env.py,forge_utils.pyandlocomotion_envs.py. Most of the functions also exist in ourmath_utils.py.is used in some of our tests.
used in
prims.py.Dependencies that can stay
Those extensions will only be used with kit / isaacsim, so we keep them in for now.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there