Thanks @AlesBorovicka ! Yes you got it.
(just a note incase others see this, I just had to change cur_pos + Gf.Vec3d, as .Get() returns a Vec3d and there currently doesnt seem to be a type set for adding 3f and 3d).
I have been able to step the simulations in python, so that has worked well. I think the added diagram/explanation for how the physics loop and these functions all work together.
I wasn’t really aiming for all USD methods, if there was a more directly approach to apply to the objects transformation I would be happy to do that (it just seems from the docs that USD is the way?).
Regarding the physics steps, you mention physics receives the change notification from the changed USD transform, so is it correct that the state of all objects are always updated instantly (sequentially)? Referencing a pybullet situation recently, there were some discussions on people wanting to run through a bunch of kinematic solutions for a robot arm, find the possible valid states (no collisions), then set torque control to use in the next physics simulation loop. The issue here being that setting the transformations was not updating the collisions, so you couldn’t → move_body-> check for collision → step simulation. There was a PR that solved it by adding an explicit update to the collision detection that wouldn’t step the simulator.
So regarding your point 3, is it update_transformations
is necessary for USD to learn about the physics simulation, but the physics always knows what is going on for USD?
I hope you can appreciate the confusion I had on the set_or_add
function name and function description. Looking at the function itself, it still seems to me as set_or_replace
. (comments added from me)
if xformOp.Get() is None: # check if there is no xform
xformOp.Set(Gf.Vec3f(translate)) # if there is no xform, SET it
else: # if there is already an xform
typeName = type(xformOp.Get())
xformOp.Set(typeName(translate)) # replace it, by setting a new one
return xformOp
Without knowing all the other aspects you just explained, (and even after), it doesn’t seem to ever add. It just does one of two things; if its empty, it sets it, using a function called Set(), and if its not empty, it overrides and replaces the existing one, using the same function Set().
The first line that goes above this if statement is
xformOp = _get_or_create_xform_op(xformable, "xformOp:translate", UsdGeom.XformOp.TypeTranslate)
And this seems to be what you are saying is added? It seems like get_or_create
is a clear name, its either getting it, or creating (adding) xform to the usd? Then the next step is to set or replace the translation component.