Fix bug in testspeed.cc for models that do not invoke the constraint solver.

PiperOrigin-RevId: 744650422
Change-Id: I0d49b7a3f3069f0c066e8758627e95f973b3a728
This commit is contained in:
Yuval Tassa
2025-04-07 03:00:34 -07:00
committed by Copybara-Service
parent d05251af2a
commit 26c14c500e
2 changed files with 13 additions and 16 deletions
+6 -7
View File
@@ -36,13 +36,12 @@ int constraints[maxthread];
mjtNum iterations[maxthread];
mjtNum simtime[maxthread];
// timer
// timer (microseconds)
mjtNum gettm(void) {
using std::chrono::steady_clock;
using Microseconds = std::chrono::duration<double, std::micro>;
static steady_clock::time_point tm_start = steady_clock::now();
auto elapsed = Microseconds(steady_clock::now() - tm_start);
return elapsed.count();
using Clock = std::chrono::steady_clock;
using Microseconds = std::chrono::duration<mjtNum, std::micro>;
static const Clock::time_point tm_start = Clock::now();
return Microseconds(Clock::now() - tm_start).count();
}
// deallocate and print message
@@ -99,7 +98,7 @@ void simulate(int id, int nstep, mjtNum* ctrl) {
contacts[id] += d[id]->ncon;
constraints[id] += d[id]->nefc;
int nisland = d[id]->solver_nisland;
if (nisland == 1) {
if (nisland == 1 || nisland == 0) {
iterations[id] += d[id]->solver_niter[0];
} else {
mjtNum niter = 0;