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:
committed by
Copybara-Service
parent
123a01bd83
commit
24a555062d
+24
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user