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
@@ -47,7 +47,9 @@ mj_compile
|
||||
|
||||
.. mujoco-include:: mj_compile
|
||||
|
||||
Compile spec to model.
|
||||
Compile :ref:`mjSpec` to :ref:`mjModel`. A spec can be edited and compiled multiple times, returning a new
|
||||
:ref:`mjModel` instance that takes the edits into account.
|
||||
If compilation fails, :ref:`mj_compile` returns ``NULL``; the error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _mj_recompile:
|
||||
|
||||
@@ -63,10 +65,8 @@ reallocate existing :ref:`mjModel` and :ref:`mjData` instances in-place. Second,
|
||||
newly added or removed degrees of freedom. This allows the user to continue simulation with the same model and data
|
||||
struct pointers while editing the model programmatically.
|
||||
|
||||
.. admonition:: Incomplete implementation
|
||||
:class: attention
|
||||
|
||||
This function is currently incomplete, preserving only ``mjData.qpos`` and ``mjData.qvel``.
|
||||
:ref:`mj_recompile` returns 0 if compilation succeed. In the case of failure, the given :ref:`mjModel` and :ref:`mjData`
|
||||
instances will be deleted; as in :ref:`mj_compile`, the compilation error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _mj_saveLastXML:
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ The key function here is :ref:`mj_loadXML`. It invokes the built-in parser and c
|
||||
a valid mjModel, or NULL - in which case the user should check the error information in the user-provided string.
|
||||
The model and all files referenced in it can be loaded from disk or from a VFS when provided.
|
||||
|
||||
.. _mj_compile:
|
||||
|
||||
Compile :ref:`mjSpec` to :ref:`mjModel`. A spec can be edited and compiled multiple times, returning a new
|
||||
:ref:`mjModel` instance that takes the edits into account.
|
||||
If compilation fails, :ref:`mj_compile` returns ``NULL``; the error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _mj_recompile:
|
||||
|
||||
Recompile spec to model, preserving the state. Like :ref:`mj_compile`, this function compiles an :ref:`mjSpec` to an
|
||||
@@ -38,10 +44,8 @@ reallocate existing :ref:`mjModel` and :ref:`mjData` instances in-place. Second,
|
||||
newly added or removed degrees of freedom. This allows the user to continue simulation with the same model and data
|
||||
struct pointers while editing the model programmatically.
|
||||
|
||||
.. admonition:: Incomplete implementation
|
||||
:class: attention
|
||||
|
||||
This function is currently incomplete, preserving only ``mjData.qpos`` and ``mjData.qvel``.
|
||||
:ref:`mj_recompile` returns 0 if compilation succeed. In the case of failure, the given :ref:`mjModel` and :ref:`mjData`
|
||||
instances will be deleted; as in :ref:`mj_compile`, the compilation error can be read with :ref:`mjs_getError`.
|
||||
|
||||
.. _Mainsimulation:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user