File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ void PhysicsLoop(mj::Simulate& sim) {
381
381
sim.speed_changed = false ;
382
382
383
383
// inject noise
384
- sim.InjectNoise ();
384
+ sim.InjectNoise (sim. key );
385
385
386
386
// run single step, let next iteration deal with timing
387
387
mj_step (m, d);
@@ -412,7 +412,7 @@ void PhysicsLoop(mj::Simulate& sim) {
412
412
}
413
413
414
414
// inject noise
415
- sim.InjectNoise ();
415
+ sim.InjectNoise (sim. key );
416
416
417
417
// call mj_step
418
418
mj_step (m, d);
Original file line number Diff line number Diff line change @@ -2917,7 +2917,7 @@ void Simulate::AddToHistory() {
2917
2917
}
2918
2918
2919
2919
// inject Brownian noise
2920
- void Simulate::InjectNoise () {
2920
+ void Simulate::InjectNoise (int key ) {
2921
2921
// no noise, return
2922
2922
if (ctrl_noise_std <= 0 ) {
2923
2923
return ;
@@ -2936,6 +2936,11 @@ void Simulate::InjectNoise() {
2936
2936
halfrange = 0.5 * (top - bottom); // scales noise
2937
2937
}
2938
2938
2939
+ // overwrite midpoint with keyframe, if given
2940
+ if (key >= 0 ) {
2941
+ midpoint = m_->key_ctrl [key*m_->nu +i];
2942
+ }
2943
+
2939
2944
// exponential convergence to midpoint at ctrl_noise_rate
2940
2945
d_->ctrl [i] = rate * d_->ctrl [i] + (1 -rate) * midpoint;
2941
2946
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ class Simulate {
89
89
void AddToHistory ();
90
90
91
91
// inject control noise
92
- void InjectNoise ();
92
+ void InjectNoise (int key );
93
93
94
94
// constants
95
95
static constexpr int kMaxFilenameLength = 1000 ;
@@ -199,7 +199,7 @@ class Simulate {
199
199
int busywait = 0 ;
200
200
201
201
// keyframe index
202
- int key = 0 ;
202
+ int key = - 1 ;
203
203
204
204
// index of history-scrubber slider
205
205
int scrub_index = 0 ;
You can’t perform that action at this time.
0 commit comments