diff --git a/source/isaaclab/isaaclab/sim/utils/stage.py b/source/isaaclab/isaaclab/sim/utils/stage.py index 2dcc7d85196..c2ef73586f8 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.metrics.assembler.core import get_metrics_assembler_interface from omni.usd.commands import DeletePrimsCommand from pxr import Sdf, Usd, UsdGeom, UsdUtils @@ -404,6 +403,16 @@ 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) + + # 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 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") + return prim + # logger.info("Loading Asset from path {} ".format(usd_path)) # Handle units sdf_layer = Sdf.Layer.FindOrOpen(usd_path) @@ -411,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