Rename a few functions and variables to be a bit more Googley.
PiperOrigin-RevId: 523963645 Change-Id: Ife7ed3f44aa83c64dfbdc3ca78ee6de2092b0d63
This commit is contained in:
committed by
Copybara-Service
parent
2e23594fe8
commit
5646c905cd
+18
-18
@@ -233,7 +233,7 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) {
|
||||
}
|
||||
}
|
||||
|
||||
mju::strcpy_arr(sim.loadError, loadError);
|
||||
mju::strcpy_arr(sim.load_error, loadError);
|
||||
|
||||
if (!mnew) {
|
||||
std::printf("%s\n", loadError);
|
||||
@@ -265,7 +265,7 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
mjData* dnew = nullptr;
|
||||
if (mnew) dnew = mj_makeData(mnew);
|
||||
if (dnew) {
|
||||
sim.load(sim.dropfilename, mnew, dnew);
|
||||
sim.Load(mnew, dnew, sim.dropfilename);
|
||||
|
||||
mj_deleteData(d);
|
||||
mj_deleteModel(m);
|
||||
@@ -287,7 +287,7 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
mjData* dnew = nullptr;
|
||||
if (mnew) dnew = mj_makeData(mnew);
|
||||
if (dnew) {
|
||||
sim.load(sim.filename, mnew, dnew);
|
||||
sim.Load(mnew, dnew, sim.filename);
|
||||
|
||||
mj_deleteData(d);
|
||||
mj_deleteModel(m);
|
||||
@@ -327,10 +327,10 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
double elapsedSim = d->time - syncSim;
|
||||
|
||||
// inject noise
|
||||
if (sim.ctrlnoisestd) {
|
||||
if (sim.ctrl_noise_std) {
|
||||
// convert rate and scale to discrete time (Ornstein–Uhlenbeck)
|
||||
mjtNum rate = mju_exp(-m->opt.timestep / mju_max(sim.ctrlnoiserate, mjMINVAL));
|
||||
mjtNum scale = sim.ctrlnoisestd * mju_sqrt(1-rate*rate);
|
||||
mjtNum rate = mju_exp(-m->opt.timestep / mju_max(sim.ctrl_noise_rate, mjMINVAL));
|
||||
mjtNum scale = sim.ctrl_noise_std * mju_sqrt(1-rate*rate);
|
||||
|
||||
for (int i=0; i<m->nu; i++) {
|
||||
// update noise
|
||||
@@ -342,7 +342,7 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
}
|
||||
|
||||
// requested slow-down factor
|
||||
double slowdown = 100 / sim.percentRealTime[sim.realTimeIndex];
|
||||
double slowdown = 100 / sim.percentRealTime[sim.real_time_index];
|
||||
|
||||
// misalignment condition: distance from target sim time is bigger than syncmisalign
|
||||
bool misaligned =
|
||||
@@ -350,16 +350,16 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
|
||||
// out-of-sync (for any reason): reset sync times, step
|
||||
if (elapsedSim < 0 || elapsedCPU.count() < 0 || syncCPU.time_since_epoch().count() == 0 ||
|
||||
misaligned || sim.speedChanged) {
|
||||
misaligned || sim.speed_changed) {
|
||||
// re-sync
|
||||
syncCPU = startCPU;
|
||||
syncSim = d->time;
|
||||
sim.speedChanged = false;
|
||||
sim.speed_changed = false;
|
||||
|
||||
// clear old perturbations, apply new
|
||||
mju_zero(d->xfrc_applied, 6*m->nbody);
|
||||
sim.applyposepertubations(0); // move mocap bodies only
|
||||
sim.applyforceperturbations();
|
||||
sim.ApplyPosePerturbations(0); // move mocap bodies only
|
||||
sim.ApplyForcePerturbations();
|
||||
|
||||
// run single step, let next iteration deal with timing
|
||||
mj_step(m, d);
|
||||
@@ -370,22 +370,22 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
bool measured = false;
|
||||
mjtNum prevSim = d->time;
|
||||
|
||||
double refreshTime = simRefreshFraction/sim.refreshRate;
|
||||
double refreshTime = simRefreshFraction/sim.refresh_rate;
|
||||
|
||||
// step while sim lags behind cpu and within refreshTime
|
||||
while (Seconds((d->time - syncSim)*slowdown) < mj::Simulate::Clock::now() - syncCPU &&
|
||||
mj::Simulate::Clock::now() - startCPU < Seconds(refreshTime)) {
|
||||
// measure slowdown before first step
|
||||
if (!measured && elapsedSim) {
|
||||
sim.measuredSlowdown =
|
||||
sim.measured_slowdown =
|
||||
std::chrono::duration<double>(elapsedCPU).count() / elapsedSim;
|
||||
measured = true;
|
||||
}
|
||||
|
||||
// clear old perturbations, apply new
|
||||
mju_zero(d->xfrc_applied, 6*m->nbody);
|
||||
sim.applyposepertubations(0); // move mocap bodies only
|
||||
sim.applyforceperturbations();
|
||||
sim.ApplyPosePerturbations(0); // move mocap bodies only
|
||||
sim.ApplyForcePerturbations();
|
||||
|
||||
// call mj_step
|
||||
mj_step(m, d);
|
||||
@@ -401,7 +401,7 @@ void PhysicsLoop(mj::Simulate& sim) {
|
||||
// paused
|
||||
else {
|
||||
// apply pose perturbation
|
||||
sim.applyposepertubations(1); // move mocap and dynamic bodies
|
||||
sim.ApplyPosePerturbations(1); // move mocap and dynamic bodies
|
||||
|
||||
// run mj_forward, to update rendering and joint sliders
|
||||
mj_forward(m, d);
|
||||
@@ -420,7 +420,7 @@ void PhysicsThread(mj::Simulate* sim, const char* filename) {
|
||||
m = LoadModel(filename, *sim);
|
||||
if (m) d = mj_makeData(m);
|
||||
if (d) {
|
||||
sim->load(filename, m, d);
|
||||
sim->Load(m, d, filename);
|
||||
mj_forward(m, d);
|
||||
|
||||
// allocate ctrlnoise
|
||||
@@ -481,7 +481,7 @@ int main(int argc, const char** argv) {
|
||||
std::thread physicsthreadhandle(&PhysicsThread, sim.get(), filename);
|
||||
|
||||
// start simulation UI loop (blocking call)
|
||||
sim->renderloop();
|
||||
sim->RenderLoop();
|
||||
physicsthreadhandle.join();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user