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:
Omar Rayyan
2026-07-08 10:30:15 -07:00
committed by Copybara-Service
parent 18147c50c8
commit 040872fd65
3 changed files with 22 additions and 6 deletions
+11 -3
View File
@@ -241,13 +241,21 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) {
} else if (extension == ".xml") {
mnew = mj_loadXML(filename, nullptr, loadError, kErrorLength);
} 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) {
mju::strcpy_arr(loadError, "could not parse model");
if (!loadError[0]) {
mju::strcpy_arr(loadError, "could not parse model");
}
} else {
mnew = mj_compile(spec, nullptr);
mnew = mj_compile(spec, &vfs);
if (!mnew) {
mju::strcpy_arr(loadError, mjs_getError(spec));
}
mj_deleteSpec(spec);
}
mj_deleteVFS(&vfs);
}
// remove trailing newline character from loadError