Add realtime parameter to visual global.

PiperOrigin-RevId: 478775714
Change-Id: Ic2d178a5c57d298d005215219ce8470392c4651b
This commit is contained in:
Alessio Quaglino
2022-10-04 07:08:21 -07:00
committed by Copybara-Service
parent f85cfb8ed2
commit bc1490b7a8
10 changed files with 29 additions and 3 deletions
+12
View File
@@ -1648,6 +1648,18 @@ void Simulate::loadmodel() {
// 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->realTimeIndex = click;
}
}
}