Rename mjDSBL_AUTORESETNAN to mjDSBL_AUTORESET.

- Expose in MJCF.
- Add documentation.
- Improve handling in simulate.

PiperOrigin-RevId: 657606140
Change-Id: I6a27c2f4842d7d4ae32642f2a6255e5f8f1f605a
This commit is contained in:
Yuval Tassa
2024-07-30 08:40:55 -07:00
committed by Copybara-Service
parent 123a01bd83
commit 24a555062d
13 changed files with 48 additions and 23 deletions
+24 -2
View File
@@ -199,6 +199,16 @@ void scanPluginLibraries() {
//------------------------------------------- simulation -------------------------------------------
const char* Diverged(int disableflags, const mjData* d) {
if (disableflags & mjDSBL_AUTORESET) {
for (mjtWarning w : {mjWARN_BADQACC, mjWARN_BADQVEL, mjWARN_BADQPOS}) {
if (d->warning[w].number > 0) {
return mju_warningText(w, d->warning[w].lastinfo);
}
}
}
return nullptr;
}
mjModel* LoadModel(const char* file, mj::Simulate& sim) {
// this copy is needed so that the mju::strlen call below compiles
@@ -356,7 +366,13 @@ void PhysicsLoop(mj::Simulate& sim) {
// run single step, let next iteration deal with timing
mj_step(m, d);
stepped = true;
const char* message = Diverged(m->opt.disableflags, d);
if (message) {
sim.run = 0;
mju::strcpy_arr(sim.load_error, message);
} else {
stepped = true;
}
}
// in-sync: step until ahead of cpu
@@ -381,7 +397,13 @@ void PhysicsLoop(mj::Simulate& sim) {
// call mj_step
mj_step(m, d);
stepped = true;
const char* message = Diverged(m->opt.disableflags, d);
if (message) {
sim.run = 0;
mju::strcpy_arr(sim.load_error, message);
} else {
stepped = true;
}
// break if reset
if (d->time < prevSim) {