From 9740705510a9010767dbbb9587a192e6ec7a02c8 Mon Sep 17 00:00:00 2001 From: Kyle Bayes Date: Tue, 16 Sep 2025 13:02:05 -0700 Subject: [PATCH] Add cache functions to Python bindings. PiperOrigin-RevId: 807813218 Change-Id: Ieab2843d92e79c07bc9f98196db51297a456dedb --- python/mujoco/functions.cc | 21 +++++++++++++++++++++ python/mujoco/structs.cc | 1 + 2 files changed, 22 insertions(+) diff --git a/python/mujoco/functions.cc b/python/mujoco/functions.cc index 14b9fc15..767ed879 100644 --- a/python/mujoco/functions.cc +++ b/python/mujoco/functions.cc @@ -52,6 +52,27 @@ PYBIND11_MODULE(_functions, pymodule) { // Virtual file system // Skipped entire section + // Asset cache + Def(pymodule, [](void* cache) { + return mj_getCacheSize(static_cast(cache)); + }); + + Def(pymodule, [](void* cache) { + return mj_getCacheCapacity(static_cast(cache)); + }); + + Def(pymodule, [](void* cache, std::size_t size) { + return mj_setCacheCapacity(static_cast(cache), size); + }); + + Def(pymodule, []() { + return static_cast(mj_getCache()); + }); + + Def(pymodule, [](void* cache) { + return mj_clearCache(static_cast(cache)); + }); + // Parse and compile // Skipped: mj_loadXML (have MjModel.from_xml_string) DEF_WITH_OMITTED_PY_ARGS(traits::mj_saveLastXML, "error", "error_sz")( diff --git a/python/mujoco/structs.cc b/python/mujoco/structs.cc index 918a6e7c..6f157d02 100644 --- a/python/mujoco/structs.cc +++ b/python/mujoco/structs.cc @@ -16,6 +16,7 @@ #include +#include #include #include #include