Fix load time reporting in simulate.
Before this change, a model which took more than 1/4 seconds to load caused the simulation to pause, which is a behavior that is only supposed to occur for models that loaded with a warning. PiperOrigin-RevId: 665786861 Change-Id: Ie3a6c8d18a6abbb425a0bbcc5a8e55d5fd7a0c72
This commit is contained in:
committed by
Copybara-Service
parent
ad9cd7301e
commit
cf3e60f9a4
+7
-7
@@ -245,13 +245,6 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) {
|
||||
auto load_interval = mj::Simulate::Clock::now() - load_start;
|
||||
double load_seconds = Seconds(load_interval).count();
|
||||
|
||||
// if no error and load took more than 1/4 seconds, report load time
|
||||
if (!loadError[0] && load_seconds > 0.25) {
|
||||
mju::sprintf_arr(loadError, "Model loaded in %.2g seconds", load_seconds);
|
||||
}
|
||||
|
||||
mju::strcpy_arr(sim.load_error, loadError);
|
||||
|
||||
if (!mnew) {
|
||||
std::printf("%s\n", loadError);
|
||||
return nullptr;
|
||||
@@ -264,6 +257,13 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) {
|
||||
sim.run = 0;
|
||||
}
|
||||
|
||||
// if no error and load took more than 1/4 seconds, report load time
|
||||
if (!loadError[0] && load_seconds > 0.25) {
|
||||
mju::sprintf_arr(loadError, "Model loaded in %.2g seconds", load_seconds);
|
||||
}
|
||||
|
||||
mju::strcpy_arr(sim.load_error, loadError);
|
||||
|
||||
return mnew;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user