Cannot write to joint attribute using Python

I am trying to set up a joint programmatically. Steps to reproduce:

  1. Open a blank scene in Isaac Sim 2022.2.0.
  2. Open the Script Editor
  3. Run the following script
from pxr import Gf, UsdGeom, UsdPhysics
import omni

stage = omni.usd.get_context().get_stage()

body0 = UsdGeom.Xform.Define(stage, "/World/Body0")
body0.AddTranslateOp().Set(Gf.Vec3d(1, 2, 3))
body1 = UsdGeom.Xform.Define(stage, "/World/Body1")
body1.AddTranslateOp().Set(Gf.Vec3d(4, 5, 6))
joint = UsdPhysics.RevoluteJoint.Define(stage, "/World/Joint")
joint.GetBody0Rel().AddTarget("/World/Body0")
joint.GetBody1Rel().AddTarget("/World/Body1")
joint.GetLocalPos0Attr().Set(Gf.Vec3d(0, 0, 0))
joint.GetLocalPos1Attr().Set(Gf.Vec3d(0, 0, 0))

Expected result: The local positions should be reset to (0, 0, 0)
Actual result: The positons are set to (3, 3, 3) and (-3, -3, -3). It seems the last two statements had no effect.


Thanks for any help!

Hi,
could it be that you are trying to pass in Gf.Vec3d, should be Gf.Vec3f.
Regards,
Ales

I changed the last two lines and replaced Gf.Vec3d by Gf.Vec3f, but that does not change anything in the result.

This is really strange… I hope to find a workaround.

What I found though is that I can change that properties when I open another python tab and enter this:

But this does not help, because I need to create and change the joint from within the same script.

Edit: It also works when I run these commands from the original Python tab. It seems something important is happening after the script exits.

I did identified the issue, will fix it for the next release, sorry about the trouble.

Regards,
Ales

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.