Automatically compile mjSpec in to_xml().
Also, move mj_compile from MjModelWrapper to MjSpec. PiperOrigin-RevId: 737640210 Change-Id: I93d2a31c33eb359452b0d966a29939183b4c5198
This commit is contained in:
committed by
Copybara-Service
parent
35774706ee
commit
da04688071
@@ -408,12 +408,7 @@ MjModelWrapper MjModelWrapper::LoadXML(
|
||||
return MjModelWrapper(model);
|
||||
}
|
||||
|
||||
MjModelWrapper MjModelWrapper::CompileSpec(raw::MjSpec* spec,
|
||||
const mjVFS* vfs) {
|
||||
auto m = mj_compile(spec, vfs);
|
||||
if (!m || mjs_isWarning(spec)) {
|
||||
throw py::value_error(mjs_getError(spec));
|
||||
}
|
||||
MjModelWrapper MjModelWrapper::WrapRawModel(raw::MjModel* m) {
|
||||
return MjModelWrapper(m);
|
||||
}
|
||||
|
||||
@@ -1616,18 +1611,9 @@ PYBIND11_MODULE(_structs, m) {
|
||||
py::arg("xml"), py::arg_v("assets", py::none()),
|
||||
py::doc(
|
||||
R"(Loads an MjModel from an XML string and an optional assets dictionary.)"));
|
||||
mjModel.def_static(
|
||||
"_from_spec_ptr", [](uintptr_t addr) {
|
||||
return MjModelWrapper::CompileSpec(
|
||||
reinterpret_cast<raw::MjSpec*>(addr),
|
||||
nullptr);
|
||||
});
|
||||
mjModel.def_static(
|
||||
"_from_spec_ptr", [](uintptr_t addr, uintptr_t vfs) {
|
||||
return MjModelWrapper::CompileSpec(
|
||||
reinterpret_cast<raw::MjSpec*>(addr),
|
||||
reinterpret_cast<mjVFS*>(vfs));
|
||||
});
|
||||
mjModel.def_static("_from_model_ptr", [](uintptr_t addr) {
|
||||
return MjModelWrapper::WrapRawModel(reinterpret_cast<raw::MjModel*>(addr));
|
||||
});
|
||||
mjModel.def_static(
|
||||
"from_xml_path", &MjModelWrapper::LoadXMLFile,
|
||||
py::arg("filename"), py::arg_v("assets", py::none()),
|
||||
|
||||
Reference in New Issue
Block a user