# Step Physics Manually In a C++ Extension

**URL:** <https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996>\
**Category:** Core Platform\
**Tags:** physx, physics\
**Created:** [October 17, 2025, 5:10am UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996 "2025-10-17T05:10:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.gcooper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m.gcooper](https://forums.developer.nvidia.com/u/m.gcooper)\
**Post date:** [October 17, 2025, 5:10am UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/1 "2025-10-17T05:10:28Z")

</div>

I am attempting to create an application that loads in a stage with a drone and publishes out simulated IMU data at 500Hz to another program. The requirements for this application are as follows:

- The publishing of IMU data must occur at 500 Hz with the simulation time synchronized to the wall clock time.
- At each physics step, the code must run fast enough to perform aerodynamic computations that generate forces/moments for each propeller.

Due to these requirements, I am writing the extension in C++ so it should hopefully be fast enough to run at 500Hz.

I tried setting the physics scene to have 500 time steps per second and then set the time codes per second to 50 with 10 ticks per frame. What I noticed looking at the wall clock time was that the 10 physics steps per frame occurred very fast one after the other, then there was a delay before the next frame started. Therefore, I decided to try to step the physics manually on a separate task/fibre. The problem is there only seems to be documentation on how to do this in [Python](https://docs.omniverse.nvidia.com/kit/docs/omni_physics/106.5/dev_guide/simulation_control/simulation_control.html#simulation-stepping):

```python
    # Simulate, by provided delta and current time, the current time is used to update for example kinematic bodies with time sampled data
    # The provided delta time is passed directly to PhysX SDK no substepping happens
    # Note that this is not a blocking call, separate thread will get executed
    get_physx_simulation_interface().simulate(1/60.0, 40 * 1/60 + i * 1/60)

    # Fetch results will wait for simulation to finish
    get_physx_simulation_interface().fetch_results()

```

In C++, I can’t find any include directories such as \<omni/physx/…\>. Is there a Physx C++ api available that can be used in kit app extensions? Am I approaching this problem the correct way? Any help is appreciated, thanks.

---

<div class="post-metadata">

**Author:** ![Richard3D](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/richard3d/32/207062_2.png) [@Richard3D](https://forums.developer.nvidia.com/u/Richard3D)\
**Post date:** [October 17, 2025, 3:21pm UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/2 "2025-10-17T15:21:45Z")

</div>

Hi and thanks for the question. Yes this is pretty advanced. Let me ask a physics expert. Have you tried to write this python? How do you know Python would be too slow?

---

<div class="post-metadata">

**Author:** ![m.gcooper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m.gcooper](https://forums.developer.nvidia.com/u/m.gcooper)\
**Post date:** [October 19, 2025, 11:31am UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/3 "2025-10-19T11:31:16Z")

</div>

Hi, thanks I appreciate you looking into this for me. Originally, yes, I attempted to make this all in python. I set up the physics scene and created a callback on the physics step. At each step I would simulate the propeller dynamics, and also simulate GPS, IMU, barometer, and magnetometer sensor measurements. Each of these sensor measurements would be published using the Python ZMQ library to a separate application that would subscribe to these messages. I found that the max speed I was getting trying to do all of this in one physics time step was approximately 100Hz. That is why I am currently attempting to recreate what I did in Python in C++ to see if I can get some speed improvements.

---

<div class="post-metadata">

**Author:** ![Richard3D](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/richard3d/32/207062_2.png) [@Richard3D](https://forums.developer.nvidia.com/u/Richard3D)\
**Post date:** [October 20, 2025, 5:01pm UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/4 "2025-10-20T17:01:02Z")

</div>

But is that not a limit of your processor, not the code?

---

<div class="post-metadata">

**Author:** ![m.gcooper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m.gcooper](https://forums.developer.nvidia.com/u/m.gcooper)\
**Post date:** [October 20, 2025, 11:21pm UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/5 "2025-10-20T23:21:41Z")

</div>

Yes, I assume it is a limit of my processor. Our current drone simulator is written in the Julia language and performs the same calculations which can run on my machine at 1000Hz. In Python using Omniverse, I couldn’t get close to these speeds. I wanted to try coding the physics callback in C++ as I understand Python can be quite slow (in comparison with C++) when its within a high rate loop.

I was wondering if a C++ version would be possible to create or if the API does not yet allow it? Specifically, I cannot seem to find the \<omni/physx/…\> libraries.

---

<div class="post-metadata">

**Author:** ![AlesBorovicka](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/alesborovicka/32/21824_2.png) [@AlesBorovicka](https://forums.developer.nvidia.com/u/AlesBorovicka)\
**Post date:** [October 21, 2025, 4:11pm UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/6 "2025-10-21T16:11:30Z")

</div>

Hi,

Yes, its possible to step simulation through C++, but before we get to that, couple of questions.

Based on your description the simulation stepping seems to be not a problem, but the bottleneck might the fetch\_results which does get data from PhysX and pushes those to USD by default. This is very slow on even medium scenes. Its recommended to enable [omni.physx.fabric](https://docs.omniverse.nvidia.com/kit/docs/omni_physics/latest/dev_guide/simulation_control/simulation_control.html#fabric) to push the simulation output into Fabric, then you can get the data even in Python with a code like this:

> **[Simulation Output - Simulation Control — Omni Physics](https://docs.omniverse.nvidia.com/kit/docs/omni_physics/latest/dev_guide/simulation_control/simulation_control.html#simulation-output)**
>
> When a simulation is started, Omni PhysX will go through the following sequence of events:

Now to the C++, its possible to write an extension in C++ that uses the C++ interfaces, those are not part of kit and are available in an additional package that you have to fetch, you can take a look at the open sourced IsaacSim source code how one can fetch the package and use the headers. See: [IsaacSim/deps/omni-physics.packman.xml at main · isaac-sim/IsaacSim · GitHub](https://github.com/isaac-sim/IsaacSim/blob/main/deps/omni-physics.packman.xml#L8)

To understand more what the interfaces provide you can check the headers documentation or see how they are used in the unit tests as omni physx is fully open sourced now.

See: [PhysX/omni/extensions/runtime/tests/test.unit/physics/TestScene.cpp at main · NVIDIA-Omniverse/PhysX · GitHub](https://github.com/NVIDIA-Omniverse/PhysX/blob/main/omni/extensions/runtime/tests/test.unit/physics/TestScene.cpp#L191)

Regards,

Ales

---

<div class="post-metadata">

**Author:** ![m.gcooper](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@m.gcooper](https://forums.developer.nvidia.com/u/m.gcooper)\
**Post date:** [October 21, 2025, 11:01pm UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/7 "2025-10-21T23:01:54Z")

</div>

Wow this is great, thanks! I will investigate enabling fabric first; then if I’m still running into performance issues I’ll try and pull in the physx dependencies like you mentioned IsaacSim does.

Thanks again!

---

<div class="post-metadata">

**Author:** ![Richard3D](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/richard3d/32/207062_2.png) [@Richard3D](https://forums.developer.nvidia.com/u/Richard3D)\
**Post date:** [October 22, 2025, 3:05am UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/8 "2025-10-22T03:05:20Z")

</div>

Great, I am glad you have the information you need.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [November 5, 2025, 3:05am UTC](https://forums.developer.nvidia.com/t/step-physics-manually-in-a-c-extension/347996/9 "2025-11-05T03:05:26Z")

</div>

Closed on November 5, 2025, 3:05am UTC

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