Fix formatting of large unsigned numbers in mju_warningText.

PiperOrigin-RevId: 479902611
Change-Id: Ia7187478a246b8b068684e75d6f3851d749844c9
This commit is contained in:
Saran Tunyasuvunakool
2022-10-09 04:54:39 -07:00
committed by Copybara-Service
parent c2f1381f31
commit 1a393429ef
5 changed files with 15 additions and 13 deletions
+1 -1
View File
@@ -1087,7 +1087,7 @@ MJAPI const char* mju_type2Str(int type);
MJAPI int mju_str2Type(const char* str); MJAPI int mju_str2Type(const char* str);
// Construct a warning message given the warning type and info. // Construct a warning message given the warning type and info.
MJAPI const char* mju_warningText(int warning, int info); MJAPI const char* mju_warningText(int warning, size_t info);
// Return 1 if nan or abs(x)>mjMAXVAL, 0 otherwise. Used by check functions. // Return 1 if nan or abs(x)>mjMAXVAL, 0 otherwise. Used by check functions.
MJAPI int mju_isBad(mjtNum x); MJAPI int mju_isBad(mjtNum x);
+1 -1
View File
@@ -6886,7 +6886,7 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
), ),
FunctionParameterDecl( FunctionParameterDecl(
name='info', name='info',
type=ValueType(name='int'), type=ValueType(name='size_t'),
), ),
), ),
doc='Construct a warning message given the warning type and info.', doc='Construct a warning message given the warning type and info.',
+9 -9
View File
@@ -947,45 +947,45 @@ int mju_str2Type(const char* str) {
// warning text // warning text
const char* mju_warningText(int warning, int info) { const char* mju_warningText(int warning, size_t info) {
static char str[1000]; static char str[1000];
switch (warning) { switch (warning) {
case mjWARN_INERTIA: case mjWARN_INERTIA:
mjSNPRINTF(str, "Inertia matrix is too close to singular at DOF %d. Check model.", info); mjSNPRINTF(str, "Inertia matrix is too close to singular at DOF %zu. Check model.", info);
break; break;
case mjWARN_CONTACTFULL: case mjWARN_CONTACTFULL:
mjSNPRINTF(str, mjSNPRINTF(str,
"Too many contacts. Either the arena memory is full, or nconmax is specified and is " "Too many contacts. Either the arena memory is full, or nconmax is specified and is "
"exceeded. Increase arena memory allocation, or increase/remove nconmax. " "exceeded. Increase arena memory allocation, or increase/remove nconmax. "
"(ncon = %d)", info); "(ncon = %zu)", info);
break; break;
case mjWARN_CNSTRFULL: case mjWARN_CNSTRFULL:
mjSNPRINTF(str, mjSNPRINTF(str,
"Insufficient arena memory for the number of constraints generated. " "Insufficient arena memory for the number of constraints generated. "
"Increase arena memory allocation above %d bytes.", info); "Increase arena memory allocation above %zu bytes.", info);
break; break;
case mjWARN_VGEOMFULL: case mjWARN_VGEOMFULL:
mjSNPRINTF(str, "Pre-allocated visual geom buffer is full. Increase maxgeom above %d.", info); mjSNPRINTF(str, "Pre-allocated visual geom buffer is full. Increase maxgeom above %zu.", info);
break; break;
case mjWARN_BADQPOS: case mjWARN_BADQPOS:
mjSNPRINTF(str, "Nan, Inf or huge value in QPOS at DOF %d. The simulation is unstable.", info); mjSNPRINTF(str, "Nan, Inf or huge value in QPOS at DOF %zu. The simulation is unstable.", info);
break; break;
case mjWARN_BADQVEL: case mjWARN_BADQVEL:
mjSNPRINTF(str, "Nan, Inf or huge value in QVEL at DOF %d. The simulation is unstable.", info); mjSNPRINTF(str, "Nan, Inf or huge value in QVEL at DOF %zu. The simulation is unstable.", info);
break; break;
case mjWARN_BADQACC: case mjWARN_BADQACC:
mjSNPRINTF(str, "Nan, Inf or huge value in QACC at DOF %d. The simulation is unstable.", info); mjSNPRINTF(str, "Nan, Inf or huge value in QACC at DOF %zu. The simulation is unstable.", info);
break; break;
case mjWARN_BADCTRL: case mjWARN_BADCTRL:
mjSNPRINTF(str, "Nan, Inf or huge value in CTRL at ACTUATOR %d. The simulation is unstable.", mjSNPRINTF(str, "Nan, Inf or huge value in CTRL at ACTUATOR %zu. The simulation is unstable.",
info); info);
break; break;
+3 -1
View File
@@ -22,6 +22,8 @@
extern "C" { extern "C" {
#endif #endif
#include <stddef.h>
//------------------------------ tendons and actuators --------------------------------------------- //------------------------------ tendons and actuators ---------------------------------------------
// wrap tendons around spheres and cylinders // wrap tendons around spheres and cylinders
@@ -86,7 +88,7 @@ MJAPI const char* mju_type2Str(int type);
MJAPI int mju_str2Type(const char* str); MJAPI int mju_str2Type(const char* str);
// warning text // warning text
MJAPI const char* mju_warningText(int warning, int info); MJAPI const char* mju_warningText(int warning, size_t info);
// return 1 if nan or abs(x)>mjMAXVAL, 0 otherwise // return 1 if nan or abs(x)>mjMAXVAL, 0 otherwise
MJAPI int mju_isBad(mjtNum x); MJAPI int mju_isBad(mjtNum x);
+1 -1
View File
@@ -3502,7 +3502,7 @@ public static unsafe extern int mju_str2Type([MarshalAs(UnmanagedType.LPStr)]str
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)] [DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.LPStr)] [return: MarshalAs(UnmanagedType.LPStr)]
public static unsafe extern string mju_warningText(int warning, int info); public static unsafe extern string mju_warningText(int warning, UIntPtr info);
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)] [DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern int mju_isBad(double x); public static unsafe extern int mju_isBad(double x);