"""Isolated: does _activate_item's write actually stick, and is physics playing?""" import sys REPO = "/home/dasha/robozon-sorter" if REPO not in sys.path: sys.path.insert(0, REPO) for _m in [k for k in list(sys.modules) if k.startswith("robozon_sorter")]: del sys.modules[_m] import importlib importlib.invalidate_caches() import omni.usd, omni.timeline from pxr import Gf, UsdGeom, UsdPhysics, PhysxSchema import isaacsim.core.experimental.utils.app as app_utils from isaacsim.core.experimental.prims import RigidPrim from robozon_sorter import config as C stage = omni.usd.get_context().get_stage() tl = omni.timeline.get_timeline_interface() print("timeline playing (before):", tl.is_playing()) name = "bottle" prim = stage.GetPrimAtPath(f"/World/Items/{name}") print("prim valid:", prim.IsValid()) if not prim.IsValid(): UsdGeom.Xform.Define(stage, "/World/Items") prim = UsdGeom.Xform.Define(stage, f"/World/Items/{name}").GetPrim() prim.GetReferences().AddReference(str(C.ROOT / "assets" / "items" / f"{name}.usd")) xf = UsdGeom.Xformable(prim) xf.ClearXformOpOrder() xf.AddTranslateOp(precision=UsdGeom.XformOp.PrecisionDouble).Set(Gf.Vec3d(9.0, 5.0, 0.4)) UsdGeom.Imageable(prim).MakeInvisible() print("xform ops before activate:", [str(op.GetOpType()) for op in UsdGeom.Xformable(prim).GetOrderedXformOps()]) try: for op in UsdGeom.Xformable(prim).GetOrderedXformOps(): if op.GetOpType() == UsdGeom.XformOp.TypeTranslate: op.Set(Gf.Vec3d(C.SPAWN_X, 0.0, C.BELT_Z + 0.05)) print("translate write: OK") break UsdPhysics.RigidBodyAPI.Apply(prim) UsdPhysics.MassAPI.Apply(prim).CreateMassAttr().Set(0.6) px = PhysxSchema.PhysxRigidBodyAPI.Apply(prim) px.CreateEnableCCDAttr().Set(True) UsdGeom.Imageable(prim).MakeVisible() print("physics API apply: OK") except BaseException as exc: print("EXCEPTION during activate:", type(exc).__name__, exc) # read back the AUTHORED attribute directly (not RigidPrim/Fabric) attr = prim.GetAttribute("xformOp:translate") print("authored translate now:", attr.Get() if attr else "NO ATTR") rp = RigidPrim(paths=[f"/World/Items/{name}"]) print("RigidPrim world pose now:", rp.get_world_poses()[0].numpy()[0]) print("timeline playing (still):", tl.is_playing()) app_utils.play(commit=True) print("timeline playing (after play() call):", tl.is_playing()) await app_utils.update_app_async(steps=30) print("RigidPrim world pose after 30 steps of play:", rp.get_world_poses()[0].numpy()[0]) app_utils.stop()