Add a new disable flag mjDSBL_AUTORESETNAN.

PiperOrigin-RevId: 654677473
Change-Id: Id92383fe413729bf6697353aa6e0bc8a946ec7e8
This commit is contained in:
Saran Tunyasuvunakool
2024-07-22 03:21:09 -07:00
committed by Copybara-Service
parent d49d4bf64c
commit f62792594f
8 changed files with 31 additions and 11 deletions
+3 -2
View File
@@ -9,15 +9,16 @@ General
^^^^^^^
1. Renamed ``mjModel.tex_rbg`` to ``mjModel.tex_data``.
2. Added a new disable flag ``mjDSBL_AUTORESETNAN`` to disable automatic reset when NaNs or infinities are produced.
MJX
^^^
2. Added more fields to ``mjx.Model`` and ``mjx.Data`` for further compatibility with the corresponding MuJoCo structs.
3. Added more fields to ``mjx.Model`` and ``mjx.Data`` for further compatibility with the corresponding MuJoCo structs.
Python bindings
^^^^^^^^^^^^^^^
2. Added support for asset dictionary argument in ``mujoco.spec.from_file``, ``mujoco.spec.from_string`` and
4. Added support for asset dictionary argument in ``mujoco.spec.from_file``, ``mujoco.spec.from_string`` and
``mujoco.spec.compile``.
Version 3.2.0 (Jul 15, 2024)
+2 -1
View File
@@ -418,8 +418,9 @@ typedef enum mjtDisableBit_ { // disable default feature bitflags
mjDSBL_SENSOR = 1<<12, // sensors
mjDSBL_MIDPHASE = 1<<13, // mid-phase collision filtering
mjDSBL_EULERDAMP = 1<<14, // implicit integration of joint damping in Euler integrator
mjDSBL_AUTORESETNAN = 1<<15, // automatic reset when numerical issues are detected
mjNDISABLE = 15 // number of disable flags
mjNDISABLE = 16 // number of disable flags
} mjtDisableBit;
typedef enum mjtEnableBit_ { // enable optional feature bitflags
mjENBL_OVERRIDE = 1<<0, // override contact parameters
+2 -1
View File
@@ -61,8 +61,9 @@ typedef enum mjtDisableBit_ { // disable default feature bitflags
mjDSBL_SENSOR = 1<<12, // sensors
mjDSBL_MIDPHASE = 1<<13, // mid-phase collision filtering
mjDSBL_EULERDAMP = 1<<14, // implicit integration of joint damping in Euler integrator
mjDSBL_AUTORESETNAN = 1<<15, // automatic reset when numerical issues are detected
mjNDISABLE = 15 // number of disable flags
mjNDISABLE = 16 // number of disable flags
} mjtDisableBit;
+2 -1
View File
@@ -42,7 +42,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjDSBL_SENSOR', 4096),
('mjDSBL_MIDPHASE', 8192),
('mjDSBL_EULERDAMP', 16384),
('mjNDISABLE', 15),
('mjDSBL_AUTORESETNAN', 32768),
('mjNDISABLE', 16),
]),
)),
('mjtEnableBit',
+6
View File
@@ -739,12 +739,18 @@ void MakePhysicsSection(mj::Simulate* sim) {
for (int i=0; i<mjNDISABLE; i++) {
mju::strcpy_arr(defFlag[0].name, mjDISABLESTRING[i]);
defFlag[0].pdata = sim->disable + i;
if ((1 << i) == mjDSBL_AUTORESETNAN) {
defFlag[0].state = 0;
} else {
defFlag[0].state = 2;
}
mjui_add(&sim->ui0, defFlag);
}
mjui_add(&sim->ui0, defEnableFlags);
for (int i=0; i<mjNENABLE; i++) {
mju::strcpy_arr(defFlag[0].name, mjENABLESTRING[i]);
defFlag[0].pdata = sim->enable + i;
defFlag[0].state = 2;
mjui_add(&sim->ui0, defFlag);
}
// add contact override
+12 -4
View File
@@ -52,7 +52,9 @@ void mj_checkPos(const mjModel* m, mjData* d) {
for (int i=0; i < m->nq; i++) {
if (mju_isBad(d->qpos[i])) {
mj_warning(d, mjWARN_BADQPOS, i);
mj_resetData(m, d);
if (!(m->opt.disableflags & mjDSBL_AUTORESETNAN)) {
mj_resetData(m, d);
}
d->warning[mjWARN_BADQPOS].number++;
d->warning[mjWARN_BADQPOS].lastinfo = i;
return;
@@ -67,7 +69,9 @@ void mj_checkVel(const mjModel* m, mjData* d) {
for (int i=0; i < m->nv; i++) {
if (mju_isBad(d->qvel[i])) {
mj_warning(d, mjWARN_BADQVEL, i);
mj_resetData(m, d);
if (!(m->opt.disableflags & mjDSBL_AUTORESETNAN)) {
mj_resetData(m, d);
}
d->warning[mjWARN_BADQVEL].number++;
d->warning[mjWARN_BADQVEL].lastinfo = i;
return;
@@ -82,10 +86,14 @@ void mj_checkAcc(const mjModel* m, mjData* d) {
for (int i=0; i < m->nv; i++) {
if (mju_isBad(d->qacc[i])) {
mj_warning(d, mjWARN_BADQACC, i);
mj_resetData(m, d);
if (!(m->opt.disableflags & mjDSBL_AUTORESETNAN)) {
mj_resetData(m, d);
}
d->warning[mjWARN_BADQACC].number++;
d->warning[mjWARN_BADQACC].lastinfo = i;
mj_forward(m, d);
if (!(m->opt.disableflags & mjDSBL_AUTORESETNAN)) {
mj_forward(m, d);
}
return;
}
}
+2 -1
View File
@@ -57,7 +57,8 @@ const char* mjDISABLESTRING[mjNDISABLE] = {
"Refsafe",
"Sensor",
"Midphase",
"Eulerdamp"
"Eulerdamp",
"AutoResetNaN"
};
+2 -1
View File
@@ -157,7 +157,8 @@ public enum mjtDisableBit : int{
mjDSBL_SENSOR = 4096,
mjDSBL_MIDPHASE = 8192,
mjDSBL_EULERDAMP = 16384,
mjNDISABLE = 15,
mjDSBL_AUTORESETNAN = 32768,
mjNDISABLE = 16,
}
public enum mjtEnableBit : int{
mjENBL_OVERRIDE = 1,