Skip to content

Commit

Permalink
Respect global/visual/realtime attribute (initial value of realtime).
Browse files Browse the repository at this point in the history
https://mujoco.readthedocs.io/en/latest/XMLreference.html#visual-global-realtime

PiperOrigin-RevId: 622875257
Change-Id: I219979aa3f5eb9add6ace692d218852de4cd4fa0
  • Loading branch information
yuvaltassa authored and copybara-github committed Apr 8, 2024
1 parent 734bda2 commit 17841fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mjpc/simulate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,18 @@ void Simulate::LoadOnRenderThread() {
// clear request
this->loadrequest = 0;
cond_loadrequest.notify_all();

// set real time index
int numclicks = sizeof(this->percentRealTime) / sizeof(this->percentRealTime[0]);
float min_error = 1e6;
float desired = mju_log(100*this->m->vis.global.realtime);
for (int click=0; click < numclicks; click++) {
float error = mju_abs(mju_log(this->percentRealTime[click]) - desired);
if (error < min_error) {
min_error = error;
this->real_time_index = click;
}
}
}

//------------------------------------------- rendering --------------------------------------------
Expand Down

0 comments on commit 17841fd

Please sign in to comment.