Prevent division by zero in Ornstein–Uhlenbeck control noise.
PiperOrigin-RevId: 498753494 Change-Id: Ib43e165a4da524c12fab4ea05848b084b2e7713c
This commit is contained in:
committed by
Copybara-Service
parent
eb8389fead
commit
a173e01f42
@@ -737,6 +737,7 @@ Euler integrator, semi-implicit in velocity.
|
||||
|
||||
def test_float_constant(self):
|
||||
self.assertEqual(mujoco.mjMAXVAL, 1e10)
|
||||
self.assertEqual(mujoco.mjMINVAL, 1e-15)
|
||||
|
||||
def test_string_constants(self):
|
||||
self.assertLen(mujoco.mjDISABLESTRING, mujoco.mjtDisableBit.mjNDISABLE)
|
||||
|
||||
@@ -78,6 +78,9 @@ PYBIND11_MODULE(_constants, pymodule) {
|
||||
// from mujoco.h
|
||||
X(mjVERSION_HEADER);
|
||||
|
||||
// from mjtnum.h
|
||||
X(mjMINVAL);
|
||||
|
||||
#undef X
|
||||
pymodule.attr("mjDISABLESTRING") = MakeTuple(mjDISABLESTRING);
|
||||
pymodule.attr("mjENABLESTRING") = MakeTuple(mjENABLESTRING);
|
||||
|
||||
@@ -136,7 +136,8 @@ def _physics_loop(simulate: Simulate, loader: Optional[_InternalLoaderType]):
|
||||
# Inject noise.
|
||||
if simulate.ctrlnoisestd != 0.0:
|
||||
# Convert rate and scale to discrete time (Ornstein–Uhlenbeck).
|
||||
rate = math.exp(-m.opt.timestep / simulate.ctrlnoiserate)
|
||||
rate = math.exp(-m.opt.timestep /
|
||||
max(simulate.ctrlnoiserate, mujoco.mjMINVAL))
|
||||
scale = simulate.ctrlnoisestd * math.sqrt(1 - rate * rate)
|
||||
|
||||
for i in range(m.nu):
|
||||
|
||||
Reference in New Issue
Block a user