in robogym/wrappers/randomizations.py [0:0]
def step(self, action):
obs, rew, done, info = self.env.step(action)
# Simulate flipping somehow
if self._side > 0:
if self.unwrapped._random_state.uniform() > self._p_flip_pos:
self._side = -self._side
else:
if self.unwrapped._random_state.uniform() > self._p_flip_neg:
self._side = -self._side
if self._side > 0:
noise = self.unwrapped._random_state.exponential(
1.0 / self._positive_lambda
)
else:
noise = self.unwrapped._random_state.exponential(
1.0 / self._negative_lambda
)
noise *= self._variance_multiplier
if self._side < 0:
# Rescale
fraction = noise / self._orig_value
noise = self._orig_value * (fraction / (1 + fraction))
if self._side < 0:
# Clip the noise if it's negative so that the simulation is stable
noise = np.clip(noise, 0.0, self._orig_value / 2)
self.unwrapped.sim.model.opt.timestep = self._bias_multiplier * (
self._orig_value + self._side * noise
)
return self.observation(obs), rew, done, info