mujoco-python-viewer icon indicating copy to clipboard operation
mujoco-python-viewer copied to clipboard

Frame rate?

Open nsk126 opened this issue 2 years ago • 1 comments

Is there any way to set the Framerate(FPS) of the simulation or limit the render speed?

nsk126 avatar Jun 22 '23 01:06 nsk126

I believe a logic like this could work

import time
import mujoco
fps = 50

for _ in range(10000):
    if viewer.is_alive:
        last_t = time.time()
        mujoco.mj_step(model, data)
        viewer.render()
        dt = time.time() - last_t

        while dt < (1 / fps):
            time.sleep(0.001)
            dt = time.time() - last_t
    else:
        break

simon-bachhuber avatar Dec 07 '24 15:12 simon-bachhuber