I’m trying to simulate a robot arm assembling objects. When two components are placed in the correct position, I would like them to be “glued” together i.e. form a rigid body joint. I can make a rigid body joint through the GUI pre-simulation, but how can I do this programmatically to happen under set circumstances? Thank you
yes, you can use python to do so.
The simplest way to achieve this is to use the same code as GUI, meaning using utils function like this:
from omni.physx.scripts import utils prim = utils.createJoint(stage, joint_type, from_prim, to_prim)
Alternatively you can use even UsdPhysics code that would create the joint, However here you need to make sure you create the local poses so that they do match for the fixed joint. You can check the createJoint function implementation to see the UsdPhysics code.
Great! This worked. Now how can I remove a joint with code?
As a broader question, where can I find the code behind GUI tools?
Most of the physics GUI calls physics commands that can be found in omni.physx.commands extension. But the commands usually just call a helper python function that can be usually found in omni.physx extension.
In the end even this python helper functions call just USD functions.
So for example how to remove a joint? Joint is a just a UsdPrim, so you can call stage.RemovePrim(path).