I am currently writing an extension, that assembles a robot (robot + gripper + gripper fingers etc.) based on a configuration file.
The objects are defined as Xform Prims and are oriented and positioned using the following functions:
obj = world.scene.add(XFormPrim(scene_path, name = object_name))
obj.set_world_pose(new_pos, new_ori)
obj.set_default_state(nem_pos, new_ori)
I then connect the appropriate objects using fixed joints (not the objects directly, but the apropriate prims of the objects, for example the tool0 xform of the UR robot, with the main body of the gripper):
But when the robot is loaded, the object orientations and positions initially do not match with the orientations and positions, specified in the code (although they still match directly after creating the joints). When I then start the simulation and stop it, the objects snap back to the positions and orientations specified in the code. When I then run the simulation, the objects change again. You can see the described behavior in this video:
The fixed joint is completely inactive while the timeline is stopped. You can move around the attached bodies relative to each other, and there will be no problem. Then when you click PLAY, the bodies will snap back together to satisfy the constraint.
The behavior of pressing STOP is for the asset to go back to the position that is written into its USD file (the position it would be loaded with). You tried to override the default position to be something else with obj.set_default_state() . That default state you are setting is only going to be used if you use world.reset() to control the timeline . It won’t be used if the STOP button is pressed.
If this is in an extension workflow, you can add a callback function for if the STOP timeline event happens and set the pose there.
That makes sense. But what I don’t understand, is why the object positions and/or orientations change at all.
I position the objects with the before mentioned functions and when I afterwards check the current position with the following code, they are at the specified position:
After that, I create the fixed joints and don’t move the objects afterward or anything like that.
What I would expect for the fixed joints is to hold the relative positions that the objects had, right before I created the fixed joints. But instead, the position is different.
Do I have to initialize the joints differently or position the objects in a different way?