# Speed up the simulation without affecting the physics

**URL:** <https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502>\
**Category:** Isaac Sim\
**Tags:** physx\
**Created:** [December 24, 2020, 5:06pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502 "2020-12-24T17:06:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yusuke\_urakami](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yusuke\_urakami](https://forums.developer.nvidia.com/u/yusuke_urakami)\
**Post date:** [December 24, 2020, 5:06pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/1 "2020-12-24T17:06:17Z")

</div>

Basically I am looking for the parameter which is equivalent to Unity’s “time scale”, the parameter that I can speed up the simulation without affecting the physics. I know I can make the simulation faster by changing the time step bigger (“update per second” smaller), but that will actually make the simulation unstable (etc. unstable collision detection).

Is there any way to execute more step in the simulation in short time without making the physics worse??

---

<div class="post-metadata">

**Author:** ![toni.sm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/toni.sm/32/27559_2.png) [@toni.sm](https://forums.developer.nvidia.com/u/toni.sm)\
**Post date:** [December 25, 2020, 10:51pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/2 "2020-12-25T22:51:03Z")

</div>

Hi,

According to the docstrings of the `update` method (line 170 of `/isaac-sim/_build/linux-x86_64/release/exts/omni.isaac.synthetic_utils/omni/isaac/synthetic_utils/scripts/omnikit.py`) you can decouple the physics step size from rendering using the **/physics/timeStepsPerSecond** and **/physics/maxNumSteps** parameters.

`/isaac-sim/_build/linux-x86_64/release/exts/omni.isaac.synthetic_utils/omni/isaac/synthetic_utils/scripts/omnikit.py`

```auto
def update(self, dt=0.0, physics_dt=None, physics_substeps=None):
    """Render one frame. Optionally specify dt in seconds, specify None to use wallclock. 
    Specify physics_dt and physics_substeps to decouple the physics step size from rendering

    For example: to render with a dt of 1/30 and simulate physics at 1/120 use:
        - dt = 1/30.0
        - physics_dt = 1/120.0
        - physics_substeps = 4

    Args:
        dt (float): The step size used for the overall update, set to None to use wallclock
        physics_dt (float, optional): If specified use this value for physics step
        physics_substeps (int, optional): Maximum number of physics substeps to perform
    """
    # dont update if exit was called
    if self._exiting:
        return
    if physics_substeps is not None and physics_substeps > 0:
        self.kit_settings.set("/physics/maxNumSteps", int(physics_substeps))
    if dt is not None:
        if self.kit_settings and dt > 0.0:
            if physics_dt is None or physics_dt <= 0.0:
                self.kit_settings.set("/physics/timeStepsPerSecond", float(1.0 / dt))
            else:
                self.kit_settings.set("/physics/timeStepsPerSecond", float(1.0 / physics_dt))
        self.app.update(dt)
    else:
        time_now = time.time()
        dt = time_now - self.last_update_t
        self.last_update_t = time_now
        if self.kit_settings and dt > 0.0:
            if physics_dt is None or physics_dt <= 0.0:
                self.kit_settings.set("/physics/timeStepsPerSecond", float(1.0 / dt))
            else:
                self.kit_settings.set("/physics/timeStepsPerSecond", float(1.0 / physics_dt))
        self.app.update(dt)

```

Also, you can configure your simulation in the Simulator section from the **Physics \> Settings** window.

 ![simulator](https://global.discourse-cdn.com/nvidia/original/3X/e/4/e41c6167d0f60fd7512414d390e6015cd7a19480.png)

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [January 21, 2021, 6:05pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/3 "2021-01-21T18:05:03Z")

</div>

The parameter `"/physics/timeStepsPerSecond"` tells the simulator what is the physics time stepping.

Isaac sim is set to run real-time, and automatically compute how many simulation steps to run per rendering, constrained by the `Max num steps` (`/physics/maxNumSteps`) setting.

Below is a script to force execute physics time-steps decoupled from rendering or timeline buttons. Bear in mind that the stepping loop is a locking function, and UI will freeze for the duration of the loop. There is a known bug currently being worked on on this approach where the simulation may freeze if a contact report happens during one of the steps.

```
from pxr import Usd, UsdGeom
import omni.usd
from omni.physx import acquire_physx_interface

stage = omni.usd.get_context().get_stage()
print(stage)

physx = acquire_physx_interface()

dt = 1/60.0
physx.reset_simulation()
physx.start_simulation()
# Simulate 20 steps, increase start_time if the desired initial step time is not at zero
start_time = 0.0
for i in range(20):
    physx.update_simulation(dt, start_time+ i*dt)
    physx.update_transformations(False, True)

# To stop the simulation and reset the scene:
def stop():
    physx.reset_simulation()
    physx.update_transformations(False, True)

```

---

<div class="post-metadata">

**Author:** ![alphaleiw](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alphaleiw](https://forums.developer.nvidia.com/u/alphaleiw)\
**Post date:** [January 27, 2021, 4:15pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/4 "2021-01-27T16:15:45Z")

</div>

Thanks for the reply. I have tried changing the `/physics/timeStepsPerSecond` but it seems to only change the frame rate that physics updates instead of how fast the system runs. Is there a way to make isaac sim runs faster/slower than realtime?

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [January 27, 2021, 6:49pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/5 "2021-01-27T18:49:13Z")

</div>

Yes – Using the script in the previous reply should show you how to step the physics scene decoupled from rendering,

The only issue in using this script with the released version is if you have any object with the `ContactReportAPI` enabled, it will freeze the simulation. This issue has already been fixed for upcoming releases.

---

<div class="post-metadata">

**Author:** ![alphaleiw](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@alphaleiw](https://forums.developer.nvidia.com/u/alphaleiw)\
**Post date:** [January 28, 2021, 4:14pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/6 "2021-01-28T16:14:30Z")

</div>

thanks, I have been trying your script in extension, but it does not seem to work. To be specific, currently, I am running a robotics application as an extension using isaac-sim, but we want to be able to test it at a faster speed. I am able to make the simulation run slower by changing the `/physics/timeStepsPerSecond` and `/physics/maxNumSteps, but there is no minNumSteps. I think the better question is how to adjust how many simulation steps per rendering when running an extension?

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [February 9, 2021, 8:22pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/7 "2021-02-09T20:22:21Z")

</div>

How are you trying to run the script? What is the error you are getting? A video or some other sort of information to help us understand what’s happening would greatly assist us to provide you with the correct next steps.

You may want to decouple physics from rendering on your extension, and on the editor update callback, call the equivalent of:

```
for i in range(n_steps):
    physx.update_simulation(dt, start_time+ i*dt)
    physx.update_transformations(False, True)

```

for as many time-steps as you want to perform on each rendering. Make sure to not click on the UI Play if you are updating the physics with your own steps, as it would recapture the physics scene and you’d need to reload the stage to be able to control through with the scripted update.

as a side note: Please be sure that the settings in the physics panel are as such:

- Enable Update to USD
- Enable Update Velocities to USD
- Enable Use Fast Cache
- Enable Reset Simulation On Stop.

---

<div class="post-metadata">

**Author:** ![SnehalJauhri](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/snehaljauhri/32/116591_2.png) [@SnehalJauhri](https://forums.developer.nvidia.com/u/SnehalJauhri)\
**Post date:** [August 9, 2021, 5:28pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/8 "2021-08-09T17:28:24Z")

</div>

I have the same issue and was still confused.  
What I have done now is use:

while kit.app.is\_running():  
kit.update(1.0, 1.0 / 60.0)

This seems to run everything very quickly while still simulating physics reasonably accurately. But I don’t understand it. Now the physics is updated using dt = 1/60, while the overall system is updated with a dt = 1 second i.e. is rendering immediately what has happened 1 second into the future? Is that right?

What I really want is a deterministic simulation time update i.e. run the simulation at 10xwallClockTime. How do I do this?

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [August 11, 2021, 7:36pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/9 "2021-08-11T19:36:46Z")

</div>

if you want to run the simulation at _precisely_ 10x wall Clock time, you’d need some sort of timed loop (e.g it enters the loop every 1/600s)

This can only be achieved if the full simulation takes less time to solve than `sim_step/10` (i.e. you can simulate a physics step ten times faster than the period simulated - For a simulation running on 1/60s you’d need the physics step to be simulated at most at 1/600s)

assuming you are able to run your simulation at 1/(10\*60)s, you’d need your loop to be something like this

```auto
period = 1/600.0
while True:
    start_time = time.time()
    do_stuff() # a function where you call the physx update simulation and everything you need to do
    end_time = time.time()
    threading.sleep(period - (end_time -start_time)) # Sleep this loop for the period minus the time it took to execute the code

```

Bear in mind that Ubuntu is not an RTOS, so it will sleep the thread for the requested time at best effort (it will try to stay on time, but no guarantees it will sleep precisely for the given time requested)

---

<div class="post-metadata">

**Author:** ![SnehalJauhri](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/snehaljauhri/32/116591_2.png) [@SnehalJauhri](https://forums.developer.nvidia.com/u/SnehalJauhri)\
**Post date:** [August 12, 2021, 2:59pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/10 "2021-08-12T14:59:25Z")

</div>

Cool. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![user56551](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user56551](https://forums.developer.nvidia.com/u/user56551)\
**Post date:** [March 5, 2022, 5:29pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/11 "2022-03-05T17:29:53Z")

</div>

Hi @rgasoto , Could you provide some insight/commentary on the difference between the solution specified in this post [Get simulation time - #2 by Hammad\_M](https://forums.developer.nvidia.com/t/get-simulation-time/195907/2) and the approach you offer here? For example, what are the differences in physics calculations with the two methods, does one approach have better control over ensuring stable physics?

As an example case for collisions, would reducing the timestep with one method or the other change the collision dynamics.

Thanks

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [March 6, 2022, 5:08pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/12 "2022-03-06T17:08:53Z")

</div>

Hi!  
It’s essentially the same method, one being called through the Isaac sim UI, the other directly through the code API.

The choice of time steps per second does have an impact on the simulation stability, as it allows for more iterations between collisions and more accurately capturing objects interpenetration and their resulting repulsion forces, therefore having a more precise impulse response. For example, if you have a small object running at a high speed, in order to capture its collision against some other object (let’s say equally small), you would need a sufficiently small time step to capture when the objects collide, instead of just passing through one another.

Does that make sense for you?

---

<div class="post-metadata">

**Author:** ![user56551](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user56551](https://forums.developer.nvidia.com/u/user56551)\
**Post date:** [March 7, 2022, 2:10pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/13 "2022-03-07T14:10:20Z")

</div>

> [@rgasoto](#):
>
> `physx.update_simulation(dt, start_time+ i*dt)`

Hi @rgasoto , sorry I wasn’t clear. I was referring to the code examples (not the UI part). Like the difference between the `step` and `update_simulation` methods.

[https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.core/docs/index.html#module-omni.isaac.core.simulation\_context](https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.core/docs/index.html#module-omni.isaac.core.simulation_context)

But assuming all the methods calling an update are the same, I am wondering if there are other settings that are impacted. I know the simulation accuracy should be ‘better’ with smaller timesteps, but are _all_ settings scaled as well? For example (but not limited to), “sleep threshold” or “elasticity damping”.

Thanks!

---

<div class="post-metadata">

**Author:** ![weidingerc](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@weidingerc](https://forums.developer.nvidia.com/u/weidingerc)\
**Post date:** [November 4, 2022, 9:52am UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/14 "2022-11-04T09:52:52Z")

</div>

I would like to try the scripts provided, but I don’t know where to put this python script, so that it gets executed. Until now I have only been using the “Action Graph Editor”.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![paros97](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@paros97](https://forums.developer.nvidia.com/u/paros97)\
**Post date:** [August 15, 2023, 7:55am UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/15 "2023-08-15T07:55:39Z")

</div>

Hi @rgasoto, I’m trying to implement your way to step physics independently from rendering, but I’m not able to make it work. Indeed the physics stepping is still following the dt indicated by the variable timeStepsPerSecond of the physicsScene and not the one given to update\_simulation function. My loop is as follows.

```auto
dt = 1.0 / 400.0
count = 0
time = 0.0

while self._sim_app.is_running():
    self._physx.update_simulation(dt, time)
    self._physx.update_transformations(False, True)
    count = count + 1
    time = time + dt
  
    if count == 40 :
        self._world.render()
        count = 0

```

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![rthaker](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rthaker/32/171374_2.png) [@rthaker](https://forums.developer.nvidia.com/u/rthaker)\
**Post date:** [August 21, 2023, 7:17pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/16 "2023-08-21T19:17:33Z")

</div>

Hi @paros97 - The `update_simulation` function in the `omni.physx` module is used to step the physics simulation by a certain amount of time. The `timeStepsPerSecond` parameter in the physics scene determines the fixed time step used by the physics simulation, but it does not control the actual simulation time. The simulation time is controlled by the `dt` argument passed to `update_simulation`.

In your code, you’re correctly calling `update_simulation` with a `dt` of `1.0 / 400.0`, which should step the simulation by 1/400th of a second each time it’s called. However, you’re also calling `update_transformations` immediately after `update_simulation`, which updates the transformations of all physics actors to match the current simulation state. This could be causing the physics simulation to appear as if it’s stepping at the same rate as the rendering.

To step the physics simulation independently from the rendering, you should only call `update_transformations` when you’re ready to render a new frame. In your case, this would be inside the `if count == 40` block. Here’s how you could modify your code:

```auto
dt = 1.0 / 400.0
count = 0
time = 0.0

while self._sim_app.is_running():
    self._physx.update_simulation(dt, time)
    count = count + 1
    time = time + dt

    if count == 40:
        self._physx.update_transformations(False, True)
        self._world.render()
        count = 0

```

This way, the physics simulation will be stepped 40 times for each rendered frame, effectively running the physics simulation at a higher rate than the rendering.

---

<div class="post-metadata">

**Author:** ![paros97](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@paros97](https://forums.developer.nvidia.com/u/paros97)\
**Post date:** [August 22, 2023, 10:07am UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/17 "2023-08-22T10:07:59Z")

</div>

Hi @rthaker, thank you for the reply.

So if I understood correctly, `dt` can be `timeStepsPerSecond` or one of its multiples, right?

Moving the `update_transform` function does improve the real-time factor. However I need to publish some transforms via ROS at each physics step, that’s why previously I put `update_transform` after `update_simulation`.  
I did some experiments and I discovered that one transform is updated at each physics step even without `update_transform`. It is the transform from world Xform to the one which contains an imu sensor. Instead, all the other transforms are not updated. Do you know the reason why that transform is still being updated? Can I extend this behavior to the other Xforms which need to be published at each physics step?

---

<div class="post-metadata">

**Author:** ![rgasoto](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/rgasoto/32/21824_2.png) [@rgasoto](https://forums.developer.nvidia.com/u/rgasoto)\
**Post date:** [September 8, 2023, 6:14pm UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/18 "2023-09-08T18:14:43Z")

</div>

> So if I understood correctly, `dt` can be `timeStepsPerSecond` or one of its multiples, right?

`dt` is `1/timeStepsPerSecond`, so if you have 60 timesteps per second, your dt would be 0.016667.

The physics objects get automatically updated without update\_transform when querying them. but any frame that is not directly bound to a physics rigid body needs the additional evaluation step. This is done due to performance reasons to maintain optimal perf. Since you need these additional frame of references, I’d move the updateTransformations to calc at every step with physics.

---

<div class="post-metadata">

**Author:** ![paros97](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@paros97](https://forums.developer.nvidia.com/u/paros97)\
**Post date:** [September 9, 2023, 11:04am UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/19 "2023-09-09T11:04:35Z")

</div>

Hi @rgasoto, thank you for the clarification.

So there is no way to speed up the simulation if I need to update the transform of a few frames at each physics step? I’m running Isaac Sim on an RTX4090 and its load is only 50% during the simulation.

---

<div class="post-metadata">

**Author:** ![zhouzhida\_1997](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@zhouzhida\_1997](https://forums.developer.nvidia.com/u/zhouzhida_1997)\
**Post date:** [November 30, 2023, 3:22am UTC](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502/20 "2023-11-30T03:22:06Z")

</div>

> [@toni.sm](#):
>
> Physics \> Settings

Can someone help me to find out where **Physics \> Settings** window in the latest Isaac Sim 2023.1 version?  
Was **Physics \> Settings** window deprecated in the current version? Whether **timeStepsPerSecond** and **maxNumSteps** were merged into other setting item?

[Next page](https://forums.developer.nvidia.com/t/speed-up-the-simulation-without-affecting-the-physics/164502.md?page=2)
