From 07f781b22d91e8ac77c1cf9b11ec57cc71baa637 Mon Sep 17 00:00:00 2001 From: Pascal Roth Date: Wed, 17 Dec 2025 11:25:11 +0100 Subject: [PATCH 1/3] fix backward compatibility --- source/isaaclab/isaaclab/sim/utils/stage.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/isaaclab/isaaclab/sim/utils/stage.py b/source/isaaclab/isaaclab/sim/utils/stage.py index 2dcc7d85196..490104cdd8c 100644 --- a/source/isaaclab/isaaclab/sim/utils/stage.py +++ b/source/isaaclab/isaaclab/sim/utils/stage.py @@ -15,10 +15,16 @@ import omni.kit.app from isaacsim.core.utils import stage as sim_stage from isaacsim.core.version import get_version -from omni.metrics.assembler.core import get_metrics_assembler_interface + from omni.usd.commands import DeletePrimsCommand from pxr import Sdf, Usd, UsdGeom, UsdUtils +# omni.metrics is only available in Isaac Sim 5.0 and above +if float(".".join(get_version()[2])) < 5: + get_metrics_assembler_interface = None +else: + from omni.metrics.assembler.core import get_metrics_assembler_interface + # import logger logger = logging.getLogger(__name__) _context = threading.local() # thread-local storage to handle nested contexts and concurrent access @@ -404,6 +410,14 @@ def add_reference_to_stage(usd_path: str, prim_path: str, prim_type: str = "Xfor prim = stage.GetPrimAtPath(prim_path) if not prim.IsValid(): prim = stage.DefinePrim(prim_path, prim_type) + + # Compatibility with Isaac Sim 4.5 where omni.metrics is not available + if get_metrics_assembler_interface is None: + success_bool = prim.GetReferences().AddReference(usd_path) + if not success_bool: + raise FileNotFoundError(f"The usd file at path {usd_path} provided wasn't found") + return prim + # logger.info("Loading Asset from path {} ".format(usd_path)) # Handle units sdf_layer = Sdf.Layer.FindOrOpen(usd_path) From 69caa9a3cfa1e501df4c164f01502037d25c2f6e Mon Sep 17 00:00:00 2001 From: Pascal Roth Date: Wed, 17 Dec 2025 12:15:10 +0100 Subject: [PATCH 2/3] formatter --- source/isaaclab/isaaclab/sim/utils/stage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/isaaclab/isaaclab/sim/utils/stage.py b/source/isaaclab/isaaclab/sim/utils/stage.py index 490104cdd8c..5ec19f01458 100644 --- a/source/isaaclab/isaaclab/sim/utils/stage.py +++ b/source/isaaclab/isaaclab/sim/utils/stage.py @@ -15,7 +15,6 @@ import omni.kit.app from isaacsim.core.utils import stage as sim_stage from isaacsim.core.version import get_version - from omni.usd.commands import DeletePrimsCommand from pxr import Sdf, Usd, UsdGeom, UsdUtils @@ -410,7 +409,7 @@ def add_reference_to_stage(usd_path: str, prim_path: str, prim_type: str = "Xfor prim = stage.GetPrimAtPath(prim_path) if not prim.IsValid(): prim = stage.DefinePrim(prim_path, prim_type) - + # Compatibility with Isaac Sim 4.5 where omni.metrics is not available if get_metrics_assembler_interface is None: success_bool = prim.GetReferences().AddReference(usd_path) From 3eafcffb70a86b58d9126f7252395b4e5f1bc124 Mon Sep 17 00:00:00 2001 From: Pascal Roth Date: Thu, 18 Dec 2025 10:00:21 +0100 Subject: [PATCH 3/3] fix --- source/isaaclab/isaaclab/sim/utils/stage.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/isaaclab/isaaclab/sim/utils/stage.py b/source/isaaclab/isaaclab/sim/utils/stage.py index 5ec19f01458..c2ef73586f8 100644 --- a/source/isaaclab/isaaclab/sim/utils/stage.py +++ b/source/isaaclab/isaaclab/sim/utils/stage.py @@ -18,12 +18,6 @@ from omni.usd.commands import DeletePrimsCommand from pxr import Sdf, Usd, UsdGeom, UsdUtils -# omni.metrics is only available in Isaac Sim 5.0 and above -if float(".".join(get_version()[2])) < 5: - get_metrics_assembler_interface = None -else: - from omni.metrics.assembler.core import get_metrics_assembler_interface - # import logger logger = logging.getLogger(__name__) _context = threading.local() # thread-local storage to handle nested contexts and concurrent access @@ -410,8 +404,10 @@ def add_reference_to_stage(usd_path: str, prim_path: str, prim_type: str = "Xfor if not prim.IsValid(): prim = stage.DefinePrim(prim_path, prim_type) + # get isaac sim version + isaac_sim_version = float(".".join(get_version()[2])) # Compatibility with Isaac Sim 4.5 where omni.metrics is not available - if get_metrics_assembler_interface is None: + if isaac_sim_version < 5: success_bool = prim.GetReferences().AddReference(usd_path) if not success_bool: raise FileNotFoundError(f"The usd file at path {usd_path} provided wasn't found") @@ -424,6 +420,8 @@ def add_reference_to_stage(usd_path: str, prim_path: str, prim_type: str = "Xfor pass # logger.info(f"Could not get Sdf layer for {usd_path}") else: + from omni.metrics.assembler.core import get_metrics_assembler_interface + stage_id = UsdUtils.StageCache.Get().GetId(stage).ToLongInt() ret_val = get_metrics_assembler_interface().check_layers( stage.GetRootLayer().identifier, sdf_layer.identifier, stage_id