Refactor compiler warning handling.
Compiler warnings are now accumulated in a vector of strings within the mjSpec object. New API functions `mjs_numWarnings` and `mjs_getWarning` are added to access these warnings. The compiler's log handler now chains warnings to the global log handler, ensuring they are still displayed immediately. Call sites in `mj_loadXML`, `mj_compile`, and the Python and WASM bindings have been updated to use the new warning API. PiperOrigin-RevId: 933361650 Change-Id: I47cab98a460c57b0898c0a1a43fce2a5b9648eb1
This commit is contained in:
committed by
Copybara-Service
parent
55c6332f20
commit
6f8bb5ef55
@@ -2161,7 +2161,25 @@ Get compiler timing diagnostics from spec, returns pointer to array of size mjNC
|
||||
|
||||
.. mujoco-include:: mjs_isWarning
|
||||
|
||||
Return 1 if compiler error is a warning.
|
||||
Return 1 if compiler error is a warning. Deprecated: use mjs_numWarnings(s) > 0.
|
||||
|
||||
.. _mjs_numWarnings:
|
||||
|
||||
`mjs_numWarnings <#mjs_numWarnings>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_numWarnings
|
||||
|
||||
Get number of warnings accumulated in the spec.
|
||||
|
||||
.. _mjs_getWarning:
|
||||
|
||||
`mjs_getWarning <#mjs_getWarning>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_getWarning
|
||||
|
||||
Get the i-th warning message (returns nullptr if index out of bounds).
|
||||
|
||||
.. _Miscellaneous:
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ General
|
||||
- New types: :ref:`mjtLogLevel`, :ref:`mjtLogTopic`, :ref:`mjLogMessage`, :ref:`mjLogConfig`.
|
||||
- The legacy callbacks :ref:`mju_user_error` and :ref:`mju_user_warning` are deprecated but remain functional.
|
||||
|
||||
- Added :ref:`mjs_numWarnings` and :ref:`mjs_getWarning` for retrieving all warnings accumulated during model
|
||||
compilation and attachment. Deprecated :ref:`mjs_isWarning` in favor of ``mjs_numWarnings(s) > 0``.
|
||||
- Improved primal solver convergence under float32. Improvements initially proposed by :github:user:`n3b` in
|
||||
:issue:`2313` and :github:user:`denzeler-nvidia` in :doc:`MJWarp <mjwarp/index>` pull request
|
||||
`1374 <https://github.com/google-deepmind/mujoco_warp/pull/1374>`__.
|
||||
|
||||
@@ -3555,6 +3555,8 @@ void mju_writeLog(const char* type, const char* msg);
|
||||
const char* mjs_getError(mjSpec* s);
|
||||
const double* mjs_getTimer(mjSpec* s);
|
||||
int mjs_isWarning(mjSpec* s);
|
||||
int mjs_numWarnings(const mjSpec* spec);
|
||||
const char* mjs_getWarning(const mjSpec* spec, int index);
|
||||
void mju_zero3(mjtNum res[3]);
|
||||
void mju_copy3(mjtNum res[3], const mjtNum data[3]);
|
||||
void mju_scl3(mjtNum res[3], const mjtNum vec[3], mjtNum scl);
|
||||
|
||||
Reference in New Issue
Block a user