Fix bug in simulate noise injection logic.

Noise injection was occurring at every iteration of the physics thread, rather than before every call to `mj_step`, leading to time-step-dependent noise rate.

- Moved the logic from main.cc to a `Simulate::` method, called before `mj_step`.
- Reduced the maximum time-scale slider value back to 4 seconds (recent increase was due to this bug).

PiperOrigin-RevId: 643350296
Change-Id: I96832905e6614f92ac725298b16fcabe64ea1df1
This commit is contained in:
Yuval Tassa
2024-06-14 08:12:12 -07:00
committed by Copybara-Service
parent 3d63c873aa
commit 6a532fc53e
3 changed files with 40 additions and 29 deletions
+4 -1
View File
@@ -86,6 +86,9 @@ class Simulate {
// add state to history buffer
void AddToHistory();
// inject control noise
void InjectNoise();
// constants
static constexpr int kMaxFilenameLength = 1000;
@@ -294,7 +297,7 @@ class Simulate {
{mjITEM_BUTTON, "Load key", 3},
{mjITEM_BUTTON, "Save key", 3},
{mjITEM_SLIDERNUM, "Noise scale", 5, &this->ctrl_noise_std, "0 1"},
{mjITEM_SLIDERNUM, "Noise rate", 5, &this->ctrl_noise_rate, "0 20"},
{mjITEM_SLIDERNUM, "Noise rate", 5, &this->ctrl_noise_rate, "0 4"},
{mjITEM_SEPARATOR, "History", 1},
{mjITEM_SLIDERINT, "", 5, &this->scrub_index, "0 0"},
{mjITEM_END}