Skip to content

Commit 9740705

Browse files
kbayescopybara-github
authored andcommitted
Add cache functions to Python bindings.
PiperOrigin-RevId: 807813218 Change-Id: Ieab2843d92e79c07bc9f98196db51297a456dedb
1 parent f2fcd05 commit 9740705

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

python/mujoco/functions.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ PYBIND11_MODULE(_functions, pymodule) {
5252
// Virtual file system
5353
// Skipped entire section
5454

55+
// Asset cache
56+
Def<traits::mj_getCacheSize>(pymodule, [](void* cache) {
57+
return mj_getCacheSize(static_cast<mjCache*>(cache));
58+
});
59+
60+
Def<traits::mj_getCacheCapacity>(pymodule, [](void* cache) {
61+
return mj_getCacheCapacity(static_cast<mjCache*>(cache));
62+
});
63+
64+
Def<traits::mj_setCacheCapacity>(pymodule, [](void* cache, std::size_t size) {
65+
return mj_setCacheCapacity(static_cast<mjCache*>(cache), size);
66+
});
67+
68+
Def<traits::mj_getCache>(pymodule, []() {
69+
return static_cast<void*>(mj_getCache());
70+
});
71+
72+
Def<traits::mj_clearCache>(pymodule, [](void* cache) {
73+
return mj_clearCache(static_cast<mjCache*>(cache));
74+
});
75+
5576
// Parse and compile
5677
// Skipped: mj_loadXML (have MjModel.from_xml_string)
5778
DEF_WITH_OMITTED_PY_ARGS(traits::mj_saveLastXML, "error", "error_sz")(

python/mujoco/structs.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <Python.h>
1818

19+
#include <cstddef>
1920
#include <cstdint>
2021
#include <ios>
2122
#include <iostream>

0 commit comments

Comments
 (0)