Improve error messages in LoadMujocoModel
PiperOrigin-RevId: 817565307 Change-Id: I367298cdf77d26b6f8deb5c6a0d5c3cab1e4d065
This commit is contained in:
committed by
Copybara-Service
parent
38af2e2d00
commit
59a5a7bf5f
@@ -43,20 +43,24 @@ mjModel* LoadMujocoModel(const std::string& model_file, const mjVFS* vfs) {
|
||||
} else if (model_file.ends_with(".mjb")) {
|
||||
model = mj_loadModel(model_file.c_str(), 0);
|
||||
if (!model) {
|
||||
mju_error("Could not load binary model");
|
||||
mju_error("LoadMujocoModel mj_loadModel could not load file '%s'",
|
||||
model_file.c_str());
|
||||
}
|
||||
} else if (model_file.ends_with(".xml")) {
|
||||
char error[1000] = "";
|
||||
model = mj_loadXML(model_file.c_str(), vfs, error, sizeof(error));
|
||||
if (!model) {
|
||||
mju_error("Load model error: %s", error);
|
||||
mju_error("LoadMujocoModel mj_loadXML failed with '%s' for file '%s'",
|
||||
error, model_file.c_str());
|
||||
}
|
||||
} else {
|
||||
char error[1000] = "";
|
||||
auto spec =
|
||||
mj_parseXMLString(model_file.c_str(), nullptr, error, sizeof(error));
|
||||
if (!spec) {
|
||||
mju_error("Load model error: %s", error);
|
||||
mju_error(
|
||||
"LoadMujocoModel mj_parseXMLString failed with '%s' for file '%s'",
|
||||
error, model_file.c_str());
|
||||
}
|
||||
model = mj_compile(spec, 0);
|
||||
mj_deleteSpec(spec);
|
||||
|
||||
Reference in New Issue
Block a user