Environment reset#
EnvironmentReset governs state initialization, domain randomization, and reset lifecycle
events when an environment starts up or an episode terminates. It manages both simulation-wide resets and partial resets
across arbitrary subsets of parallel worlds.
Reset pipeline#
When an environment is reset (either completely or partially via a boolean env_mask of shape (nworld,)), the
reset pipeline executes the following stages in strict sequence:
Model parameter restoration: If model parameters were perturbed by previous domain randomizations,
reaf-simrestores the default un-randomized model fields (e.g. mass, friction, damping, joint ranges) in-place for the masked worlds:sim.model.restore_defaults(env_mask)
This prevents cumulative parameter drift across successive episodes.
Device layer reset: Calls
device_layer.reset(env_mask), which resets the underlyingSimulatorstate (callingmj_resetDataormjw.reset_datato resetqpostoqpos0and zeroqvel,ctrl,qfrc), clears device queues and delay lines, and resets substep processors.Resetter callbacks: Executes registered resetters (such as
FunctionalEnvironmentReset,DomainRandomizationResetter, or task-specific hooks) to apply initial joint positions, velocities, and newly sampled domain randomizations.Model const update: If any model fields were modified during the reset callback,
TorchWrapperflushes minimalset_conststages to update derived physics quantities:sim.set_const()
Forward kinematics & sensor evaluation: Calls
sim.forward()anddevice_layer.forward()to ensure that all derived kinematics (Cartesian poses, matrices, site positions, camera images) are fresh and valid for the initialFIRSTtimestep observation.
DomainRandomizationResetter#
DomainRandomizationResetter evaluates declarative randomization terms. Terms can be
triggered either once at environment startup (trigger="startup") or at the start of every episode
(trigger="reset").
Simulation-only terminations#
Certain termination conditions represent simulation failures or physical violations (such as objects falling below a floor plane, excessive contact forces, or simulation instability) that should terminate an episode during training in simulation, but have no place in real robot task logic.
TerminationResetter checks these sim-only criteria at each control step, keeping task
definitions clean, portable, and invariant across simulation and hardware.
For full class signatures and details, see reaf.simulation.torch.EnvironmentReset in the API reference.