Introduce explicit VFS in Python MjVfs
This change introduces MjVFS, an explicit object to mirror the C mjVFS. This is meant to replace the MjSpec.assets dict. This latter while convenient guides users towards harmful authoring patterns with respect to data duplication and spec attachment workflows. Making VFS management explicit should encourage better memory usage and allow us to make better compile time optimizations. From this change, `spec.assets` is deprecated. However we will temporarily support backwards compatibility due to the wide spread usage. An error will be thrown if calling code tries to use a spec that uses both the assets dict and the new MjVfs. PiperOrigin-RevId: 908772050 Change-Id: I77c6d0369307fc300c954768fed17401261e18da
This commit is contained in:
committed by
Copybara-Service
parent
910b3336ed
commit
723b8b1ea6
@@ -44,6 +44,9 @@
|
||||
namespace py = ::pybind11;
|
||||
|
||||
namespace mujoco::python {
|
||||
|
||||
class MjVfs;
|
||||
|
||||
namespace _impl {
|
||||
|
||||
struct VfsAsset {
|
||||
@@ -501,17 +504,20 @@ class MjWrapper<raw::MjModel> : public WrapperBase<raw::MjModel> {
|
||||
static MjWrapper LoadXMLFile(
|
||||
const std::string& filename,
|
||||
const std::optional<
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets);
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets,
|
||||
MjVfs* vfs = nullptr);
|
||||
|
||||
static MjWrapper LoadBinaryFile(
|
||||
const std::string& filename,
|
||||
const std::optional<
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets);
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets,
|
||||
MjVfs* vfs = nullptr);
|
||||
|
||||
static MjWrapper LoadXML(
|
||||
const std::string& xml,
|
||||
const std::optional<
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets);
|
||||
std::unordered_map<std::string, pybind11::bytes>>& assets,
|
||||
MjVfs* vfs = nullptr);
|
||||
|
||||
static MjWrapper WrapRawModel(raw::MjModel* m);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user