Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion source/isaaclab/isaaclab/sim/utils/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -404,13 +403,25 @@ 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)
if not sdf_layer:
pass
# logger.info(f"Could not get Sdf layer for {usd_path}")
else:
from omni.metrics.assembler.core import get_metrics_assembler_interface
Copy link
Contributor

Choose a reason for hiding this comment

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

But this still doesn't work for isaac sim version less than 4.5, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

'omni.metrics' is not available in IsaacSim 4.5, that's why we check before to see if our Isaac version is smaller than 5.0, then we never run the code that wants to import it. We don't maintain compatibility with smaller 4.5 but why should it not work for these versions?


stage_id = UsdUtils.StageCache.Get().GetId(stage).ToLongInt()
ret_val = get_metrics_assembler_interface().check_layers(
stage.GetRootLayer().identifier, sdf_layer.identifier, stage_id
Expand Down
Loading