Skip to content

Commit

Permalink
fix: remove duplicated auto reset (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaiejj authored Apr 30, 2024
1 parent 89717ba commit 3c9a235
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion omnisafe/adapter/online_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def _wrapper(
)
if self._env.need_auto_reset_wrapper:
self._env = AutoReset(self._env, device=self._device)
self._eval_env = AutoReset(self._eval_env, device=self._device)
if obs_normalize:
self._env = ObsNormalize(self._env, device=self._device)
self._eval_env = ObsNormalize(self._eval_env, device=self._device)
Expand Down
2 changes: 1 addition & 1 deletion omnisafe/envs/mujoco_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def step(
@property
def max_episode_steps(self) -> int:
"""The max steps per episode."""
return self._env.env.spec.max_episode_steps # type: ignore
return self._env.spec.max_episode_steps # type: ignore

def reset(
self,
Expand Down
4 changes: 2 additions & 2 deletions omnisafe/envs/safety_gymnasium_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(
else:
self.need_time_limit_wrapper = True
self.need_auto_reset_wrapper = True
self._env = safety_gymnasium.make(id=env_id, autoreset=True, **kwargs)
self._env = safety_gymnasium.make(id=env_id, autoreset=False, **kwargs)
assert isinstance(self._env.action_space, Box), 'Only support Box action space.'
assert isinstance(
self._env.observation_space,
Expand Down Expand Up @@ -230,7 +230,7 @@ def reset(
@property
def max_episode_steps(self) -> int:
"""The max steps per episode."""
return self._env.env.spec.max_episode_steps
return self._env.spec.max_episode_steps

def set_seed(self, seed: int) -> None:
"""Set the seed for the environment.
Expand Down

0 comments on commit 3c9a235

Please sign in to comment.