Convert mju_error and mju_warning to variadic functions, supporting printf-like arguments. The functions mju_error_i, mju_error_s, mju_warning_i, and mju_warning_s are now deprecated.
PiperOrigin-RevId: 515431052 Change-Id: I440de0cb417ce216b6d636a5d86dc9ef6cc1fc06
This commit is contained in:
committed by
Copybara-Service
parent
2e6a37e8c5
commit
d3d789cf7d
@@ -1841,7 +1841,7 @@ mju_error_i
|
||||
|
||||
.. mujoco-include:: mju_error_i
|
||||
|
||||
Error function with int argument; msg is a printf format string.
|
||||
Deprecated: use mju_error
|
||||
|
||||
.. _mju_error_s:
|
||||
|
||||
@@ -1850,7 +1850,7 @@ mju_error_s
|
||||
|
||||
.. mujoco-include:: mju_error_s
|
||||
|
||||
Error function with string argument.
|
||||
Deprecated: use mju_error
|
||||
|
||||
.. _mju_warning:
|
||||
|
||||
@@ -1868,7 +1868,7 @@ mju_warning_i
|
||||
|
||||
.. mujoco-include:: mju_warning_i
|
||||
|
||||
Warning function with int argument.
|
||||
Deprecated: use mju_warning
|
||||
|
||||
.. _mju_warning_s:
|
||||
|
||||
@@ -1877,7 +1877,7 @@ mju_warning_s
|
||||
|
||||
.. mujoco-include:: mju_warning_s
|
||||
|
||||
Warning function with string argument.
|
||||
Deprecated: use_mju_warning
|
||||
|
||||
.. _mju_clearHandlers:
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ General
|
||||
For instance, the constraint Jacobian matrix from the `humanoid100.xml
|
||||
<https://github.com/deepmind/mujoco/blob/main/model/humanoid100/humanoid100.xml>`_ model, which previously required
|
||||
~500,000 ``mjtNum``'s, now only requires ~6000. Very large models can now load and run with the CG solver.
|
||||
- Modified :ref:`mju_error` and :ref:`mju_warning` to be variadic functions (support for printf-like arguments). The
|
||||
functions :ref:`mju_error_i`, :ref:`mju_error_s`, :ref:`mju_warning_i`, and :ref:`mju_warning_s` are now deprecated.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2041,10 +2041,10 @@ void mjui_update(int section, int item, const mjUI* ui,
|
||||
const mjuiState* state, const mjrContext* con);
|
||||
mjuiItem* mjui_event(mjUI* ui, mjuiState* state, const mjrContext* con);
|
||||
void mjui_render(mjUI* ui, const mjuiState* state, const mjrContext* con);
|
||||
void mju_error(const char* msg);
|
||||
void mju_error(const char* msg, ...) mjPRINTFLIKE(1, 2);
|
||||
void mju_error_i(const char* msg, int i);
|
||||
void mju_error_s(const char* msg, const char* text);
|
||||
void mju_warning(const char* msg);
|
||||
void mju_warning(const char* msg, ...) mjPRINTFLIKE(1, 2);
|
||||
void mju_warning_i(const char* msg, int i);
|
||||
void mju_warning_s(const char* msg, const char* text);
|
||||
void mju_clearHandlers(void);
|
||||
|
||||
@@ -724,16 +724,13 @@ triggers an error. It also keeps track of the maximum stack allocation; see :ref
|
||||
Errors, warnings, memory allocation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
When a terminal error occurs, MuJoCo calls the function :ref:`mju_error` internally. This function has a single argument
|
||||
which is the error message. The helper functions :ref:`mju_error_i` and :ref:`mju_error_s` are also used, but they
|
||||
simply construct the error message using a printf format string and an additional integer or string argument, and then
|
||||
call mju_error. Here is what mju_error does:
|
||||
When a terminal error occurs, MuJoCo calls the function :ref:`mju_error` internally. Here is what mju_error does:
|
||||
|
||||
#. Append the error message at the end of the file MUJOCO_LOG.TXT in the program directory (create the file if it does
|
||||
not exist). Also write the date and time along with the error message.
|
||||
#. If the user error callback :ref:`mju_user_error` is installed, call that function
|
||||
with the error message as argument. Otherwise printf the error message, printf "Press Enter to exit...", getchar()
|
||||
and exit(1).
|
||||
#. If the user error callback :ref:`mju_user_error` is installed, call that function with the error message as
|
||||
argument. Otherwise, print the error message and "Press Enter to exit..." to standard output. Then wait for any
|
||||
keyboard input, and then terminate the simulator with failure.
|
||||
|
||||
If a user error callback is installed, it must **not** return, otherwise the behavior of the simulator is undefined.
|
||||
The idea here is that if mju_error is called, the simulation cannot continue and the user is expected to make some
|
||||
@@ -988,4 +985,4 @@ of mass of the kinematic tree). Such a rotation will not only rotate the body bu
|
||||
spatial vector must have non-zero linear velocity to compensate for the side-effect of rotation around an off-body
|
||||
axis. If you call mj_objectVelocity, the resulting 6D quantity will be represented in a frame that is centered at the
|
||||
body and aligned with the world. Thus the linear component will now be zero as expected. This function will also put
|
||||
translation in front of rotation, which is our convention for local and global coordinates.
|
||||
translation in front of rotation, which is our convention for local and global coordinates.
|
||||
|
||||
Reference in New Issue
Block a user