Add option to only sync the state to improve sync performance in passive mode.

By default this option is off, which preserves the current behavior of syncing all of `mjModel` and `mjData`.

PiperOrigin-RevId: 776498017
Change-Id: I02127c9397efbabebb89b0e0d139b00b6e665d35
This commit is contained in:
Matija Kecman
2025-06-27 02:48:58 -07:00
committed by Copybara-Service
parent 8f6a13aa8f
commit 09f7154e57
6 changed files with 50 additions and 29 deletions
+1
View File
@@ -336,6 +336,7 @@ PYBIND11_MODULE(_simulate, pymodule) {
CallIfNotNull(&mujoco::Simulate::LoadMessageClear),
py::call_guard<py::gil_scoped_release>())
.def("sync", CallIfNotNull(&mujoco::Simulate::Sync),
py::arg("state_only") = false,
py::call_guard<py::gil_scoped_release>())
.def("add_to_history", CallIfNotNull(&mujoco::Simulate::AddToHistory),
py::call_guard<py::gil_scoped_release>())
+2 -2
View File
@@ -230,10 +230,10 @@ class Handle:
return sim.lock()
return contextlib.nullcontext()
def sync(self):
def sync(self, state_only: bool = False):
sim = self._get_sim()
if sim is not None:
sim.sync() # locks internally
sim.sync(state_only) # locks internally
def update_hfield(self, hfieldid: int):
sim = self._get_sim()