From ac74c7265723eba319c03ca852a065b99cff23c2 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Wed, 27 Sep 2023 13:45:25 -0700 Subject: [PATCH] Fix issue where unpausing the simulation (especially under slowdown) causes a jump in simulation time, in both native `simulate` and Python viewer. PiperOrigin-RevId: 568948943 Change-Id: I2f401508555e272f348e97627aeb85cb3e9cf017 --- python/mujoco/viewer.py | 1 + simulate/main.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/python/mujoco/viewer.py b/python/mujoco/viewer.py index 9784691f..67d65e89 100644 --- a/python/mujoco/viewer.py +++ b/python/mujoco/viewer.py @@ -298,6 +298,7 @@ def _physics_loop(simulate: _Simulate, loader: Optional[_InternalLoaderType]): # Run mj_forward, to update rendering and joint sliders. mujoco.mj_forward(m, d) + synccpu = time.time() def _launch_internal( diff --git a/simulate/main.cc b/simulate/main.cc index 55c09dee..509f4187 100644 --- a/simulate/main.cc +++ b/simulate/main.cc @@ -392,6 +392,7 @@ void PhysicsLoop(mj::Simulate& sim) { else { // run mj_forward, to update rendering and joint sliders mj_forward(m, d); + syncCPU = mj::Simulate::Clock::now(); } } } // release std::lock_guard