Add error handling to mj_recompile.
This CL adds error handling to the mj_recompile function. If the recompile fails, the function will return -1 and set the error message in the spec. The Python wrapper for mj_recompile will catch the error and raise a ValueError exception. PiperOrigin-RevId: 666784579 Change-Id: I225eca1769ea839c782be3c03fc4ff1ea5885a48
This commit is contained in:
committed by
Copybara-Service
parent
088079eff0
commit
505d01a1c1
@@ -456,7 +456,9 @@ py::tuple RecompileSpec(raw::MjSpec* spec, const MjModelWrapper& old_m,
|
||||
raw::MjModel* m = static_cast<raw::MjModel*>(mju_malloc(sizeof(mjModel)));
|
||||
m->buffer = nullptr;
|
||||
raw::MjData* d = mj_copyData(nullptr, old_m.get(), old_d.get());
|
||||
mj_recompile(spec, nullptr, m, d);
|
||||
if (mj_recompile(spec, nullptr, m, d)) {
|
||||
throw py::value_error(mjs_getError(spec));
|
||||
}
|
||||
|
||||
py::object m_pyobj = py::cast((MjModelWrapper(m)));
|
||||
py::object d_pyobj =
|
||||
|
||||
Reference in New Issue
Block a user