Isaac Sim 5.0.0, Windows 11.
I keep getting the warning to upgrade to the upgrade_prim_semantics_to_labels(prim) function and add_labels function.
[Warning] [isaacsim.core.utils.semantics] Function 'add_update_semantics' uses the deprecated SemanticsAPI. Consider upgrading the semantics with `upgrade_prim_semantics_to_labels(prim)` first and then using `add_labels` instead.
The code below works for the “Parent name” loop. But when it gets to the “Sub Part” loop, I encounter an error on the add_labels function:
Exception has occurred: ErrorException
Error in 'pxrInternal_v0_24__pxrReserved__::UsdStage::_SetValueImpl' at line 6703 in file C:\g\169973693\USD\pxr\usd\usd\stage.cpp : 'Empty typeName for </Object_2/applexzy/sp_bruise_001.semantics:labels:class>'
File "C:\IsaacSim\isaac-sim-standalone-5.0.0-windows-x86_64\extscache\omni.replicator.core-1.12.16+107.3.1.wx64.r.cp311\omni\replicator\core\scripts\functional\modify.py", line 631, in add_semantics labelsAttr.Set(semantic_value) File "C:\IsaacSim\isaac-sim-standalone-5.0.0-windows-x86_64\extscache\omni.replicator.core-1.12.16+107.3.1.wx64.r.cp311\omni\replicator\core\scripts\functional\modify.py", line 680, in semantics add_semantics(prim, semantic_type, semantic_value, mode.lower()) File "C:\IsaacSim\isaac-sim-standalone-5.0.0-windows-x86_64\exts\isaacsim.core.utils\isaacsim\core\utils\semantics.py", line 231, in add_labels F.modify.semantics(prim, {instance_name: labels}, mode=mode) File "C:\Users\t\Python\IsaacSim\a01\create_stage_25.py", line 439, in generate_objects add_labels(child_prim, labels=[sp_name], instance_name="class") File "C:\Users\t\Python\IsaacSim\a01\create_stage_25.py", line 662, in <module> constrained_objects_and_limits = generate_objects(stage) ^^^^^^^^^^^^^^^^^^^^^^^ pxr.Tf.ErrorException: Error in 'pxrInternal_v0_24__pxrReserved__::UsdStage::_SetValueImpl' at line 6703 in file C:\g\169973693\USD\pxr\usd\usd\stage.cpp : 'Empty typeName for </Object_2/applexzy/sp_bruise_001.semantics:labels:class>
Code:
obj_path = f"/Object_{i}"
obj_prim = stage.DefinePrim(obj_path, "Xform")
xform_api = UsdGeom.XformCommonAPI(obj_prim)
#xform_api.RotationOrderZYX()
xform_api.SetTranslate((x, y, z))
xform_api.SetRotate(gf_rot_XYZ)
# Add the object and ensure the object prim is a rigid body
obj_prim.GetPayloads().AddPayload(usd_file)
collision_api = UsdPhysics.CollisionAPI.Apply(obj_prim)
mesh_collision_api = UsdPhysics.MeshCollisionAPI.Apply(obj_prim)
mesh_collision_api.GetApproximationAttr().Set(UsdPhysics.Tokens.convexDecomposition)
#Define semantics
#Parent name
for child_prim in Usd.PrimRange(obj_prim):
if UsdGeom.Mesh(child_prim):
child_name = str(child_prim.GetName())
if not child_name.startswith("sp_"):
part_name = child_name
#add_update_semantics(obj_prim, part_name)
#semantic_api = Semantics.SemanticsAPI.Get(obj_prim, "Semantics")
upgrade_prim_semantics_to_labels(obj_prim, include_descendants=False)
add_labels(obj_prim, labels=[part_name], instance_name="class")
break
#Sub Part names
for child_prim in Usd.PrimRange(obj_prim):
if UsdGeom.Mesh(child_prim):
child_name = str(child_prim.GetName())
if child_name.startswith("sp_"):
sp_name = child_name.rstrip(digits + "_")
sp_name = sp_name.replace('sp_', '-')
sp_name = part_name + sp_name
#add_update_semantics(child_prim, sp_name)
#semantic_api = Semantics.SemanticsAPI.Get(child_prim, "Semantics")
upgrade_prim_semantics_to_labels(child_prim, include_descendants=False)
add_labels(child_prim, labels=[sp_name], instance_name="class")
obj_prim is structured like this
Object_## XForm //Want semantics 'class' to parent object
applexyz XForm
apple Mesh
sp_bruise_001 Mesh //Want semantics 'class' to this too
Really have no idea whats going on.
I read somewhere I could add labels to the USD file when I’m converting from obj → USD. if thats an option, that could work. But I’d like that to be option 2.