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
+11
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user