Unclear Unit update_simulation elapsed time

Hi everyone,

are these parameters in seconds or in milliseconds? Its not clear for me.


these are in seconds, will update the doc, good point.

Btw if you are looking for a way how to completely control physics simulation stepping independently you can use physx_simulation_interface instead, the full loop would look like this:

        cache = UsdUtils.StageCache.Get()
        stage_id = cache.GetId(stage).ToLongInt()

        for i in range(num_steps):
            get_physx_simulation_interface().simulate(1.0/60.0, i * dt)


Thanks for reporting.

1 Like


Thank you for the clarification.

I do indeed need a way to control the physics steps.

Do I always have to call the attach_stage and detach_stage methods? What happens without them?

And do I need to configure the PhysicsScene component in a certain way for this to work?

The attach_stage function will parse USD and add objects into PhysX so that you can simulate. Same happens when you press play.
Detach_stage will then release objects from physx, so once done simulating you should release those objects.

Using the above gives you full control over simulation so you have to make sure things are loaded into physics.


I tried the code you provided, but with a physical step size of 0.002 seconds. The fetch_result() method takes about 16 ms in this case. Are these normal times? My scene is not really big and I am a bit concerned about the 16 ms time to fetch the results, which is basically a blocking call.

Thats quite large number indeed, but there are many things that can be slow by default. The default settings are the slowest but should work in all cases.
So there are in general two things that slow down the simulation significantly:

  1. GPU resources and in general GPU simulation. This is enabled by default, however if you scene is heavy with graphics, we wont have much resources for the simulation. Also for example rigid bodies can be simulated on the CPU and are in general faster there to some tip point. GPU simulation does have some fixed cost and if you simulate just say few hundreds of rigid bodies, usually CPU simulation offers better performance. You can enable CPU simulation by disabling the GPU dynamics on a physics scene and set the boardphase type to MBP.
  2. USD writes, the USD write for the simulation results - new position, velocities is very slow and the reaction to the writes - USD notice handling is even slower. So if you simulate just say 100 bodies the write time is already few ms. This can be avoided by using omni.physx.fabric extension, that avoids writing to USD and writes to Fabric instead. But this is tricky, the simulation will output data into Fabric, rendering will work fine, but if you try to query the USD prim position those data will not be up to date. Here I dont know what you need to do with the simulation results but you can try to enable omni.physx.fabric to see how the time in fetch results changes.


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