Skip to content

Commit 6904649

Browse files
authored
fix(managers): ManagerBasedRVEnv.reset accepts seed (honor env.reset(seed=) contract) (#800)
ManagerBasedRVEnv (the manager-based RL base for mjlab v2 / Isaac-Lab-style tasks) overrode reset(self, env_ids=None) without seed, so gym.make(task).reset(seed=) raised 'TypeError: reset() got an unexpected keyword argument seed' for every manager-based task — surfaced by the MuJoCo benchmark (12 mjlab v2 tasks failed to reset). Add seed=None and forward to handler.set_seed (this base reimplements reset and doesn't call super), matching the seed-contract fix already applied to the other reimplementing bases (humanoid LeggedRobotTask, beyondmimic). Verified on MuJoCo (8xRTX5090): mjlab.cartpole_swingup_v2 / cartpole_balance_v2 / velocity_flat_g1_v2 now load + reset(seed=0) + run a rollout (previously TypeError).
1 parent 78587cf commit 6904649

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

roboverse_learn/managers/manager_based_rv_env.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,18 @@ def _apply_setup_events(self) -> None:
336336
# env api
337337
# ------------------------------------------------------------------
338338

339-
def reset(self, env_ids: Sequence[int] | None = None):
340-
"""Reset selected envs (or all)."""
339+
def reset(self, env_ids: Sequence[int] | None = None, seed: int | None = None):
340+
"""Reset selected envs (or all).
341+
342+
``seed`` is forwarded to the handler when supported, honoring the
343+
``env.reset(seed=)`` contract (this base reimplements ``reset`` and does
344+
not call ``super().reset``). Without this, ``gym.make(...).reset(seed=)``
345+
raised ``TypeError`` for every manager-based (mjlab v2) task.
346+
"""
347+
if seed is not None:
348+
set_seed = getattr(self.handler, "set_seed", None)
349+
if callable(set_seed):
350+
set_seed(seed)
341351
if env_ids is None:
342352
env_ids = torch.arange(self.num_envs, dtype=torch.int64, device=self.device)
343353
elif not isinstance(env_ids, torch.Tensor):

0 commit comments

Comments
 (0)