Copybara import of the project:
-- a5221e754c88580d103bfc7bfaf1ed32927ca499 by omar rayyan <olr7742@nyu.edu>: Fix .mjz loading in simulate COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3384 from omarrayyann:fix-mjz-simulate a5221e754c88580d103bfc7bfaf1ed32927ca499 PiperOrigin-RevId: 944573851 Change-Id: Ifba77ee9f9b97a7d8c0b0a47ac82d390a273672b
This commit is contained in:
committed by
Copybara-Service
parent
18147c50c8
commit
040872fd65
@@ -17,6 +17,9 @@ General
|
|||||||
- The :el:`attach` element now supports self-attachment (attaching elements of the current model to itself) by omitting
|
- The :el:`attach` element now supports self-attachment (attaching elements of the current model to itself) by omitting
|
||||||
the :at:`model` attribute. It also supports attaching a frame via the new :at:`frame` attribute, which is mutually
|
the :at:`model` attribute. It also supports attaching a frame via the new :at:`frame` attribute, which is mutually
|
||||||
exclusive with :at:`body`.
|
exclusive with :at:`body`.
|
||||||
|
- Fixed loading of ``.mjz`` archives in :ref:`simulate<saSimulate>`: the archive was unmounted before model compilation,
|
||||||
|
so assets contained in it failed to load. Failures in the ``mjz`` decoder now emit a warning with the underlying
|
||||||
|
error instead of the generic "could not decode content" message.
|
||||||
|
|
||||||
.. admonition:: Breaking API changes
|
.. admonition:: Breaking API changes
|
||||||
:class: attention
|
:class: attention
|
||||||
|
|||||||
+11
-3
@@ -241,13 +241,21 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) {
|
|||||||
} else if (extension == ".xml") {
|
} else if (extension == ".xml") {
|
||||||
mnew = mj_loadXML(filename, nullptr, loadError, kErrorLength);
|
mnew = mj_loadXML(filename, nullptr, loadError, kErrorLength);
|
||||||
} else {
|
} else {
|
||||||
mjSpec* spec = mj_parse(filename, nullptr, nullptr, loadError, kErrorLength);
|
mjVFS vfs;
|
||||||
|
mj_defaultVFS(&vfs);
|
||||||
|
mjSpec* spec = mj_parse(filename, nullptr, &vfs, loadError, kErrorLength);
|
||||||
if (!spec) {
|
if (!spec) {
|
||||||
mju::strcpy_arr(loadError, "could not parse model");
|
if (!loadError[0]) {
|
||||||
|
mju::strcpy_arr(loadError, "could not parse model");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mnew = mj_compile(spec, nullptr);
|
mnew = mj_compile(spec, &vfs);
|
||||||
|
if (!mnew) {
|
||||||
|
mju::strcpy_arr(loadError, mjs_getError(spec));
|
||||||
|
}
|
||||||
mj_deleteSpec(spec);
|
mj_deleteSpec(spec);
|
||||||
}
|
}
|
||||||
|
mj_deleteVFS(&vfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing newline character from loadError
|
// remove trailing newline character from loadError
|
||||||
|
|||||||
@@ -233,9 +233,14 @@ mjPLUGIN_LIB_INIT(mjz_decoder) {
|
|||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
char error[1024];
|
char error[1024] = "";
|
||||||
return ParseZipBuffer(buffer, size, resource->name, const_cast<mjVFS*>(vfs),
|
mjSpec* spec = ParseZipBuffer(buffer, size, resource->name,
|
||||||
error, sizeof(error));
|
const_cast<mjVFS*>(vfs), error,
|
||||||
|
sizeof(error));
|
||||||
|
if (!spec && error[0]) {
|
||||||
|
mju_warning("%s", error);
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
};
|
};
|
||||||
mjp_registerDecoder(&decoder);
|
mjp_registerDecoder(&decoder);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user