Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions omnisafe/adapter/saute_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def reset(
info: Some information logged by the environment.
"""
obs, info = self._env.reset(seed=seed, options=options)
obs = obs.to(self._device)
self._safety_obs = torch.ones(self._env.num_envs, 1).to(self._device)
obs = self._augment_obs(obs)
return obs, info
Expand Down Expand Up @@ -161,6 +162,11 @@ def step(
info: Some information logged by the environment.
"""
next_obs, reward, cost, terminated, truncated, info = self._env.step(action)
next_obs = next_obs.to(self._device)
reward = reward.to(self._device)
cost = cost.to(self._device)
terminated = terminated.to(self._device)
truncated = truncated.to(self._device)
info['original_reward'] = reward

self._safety_step(cost)
Expand Down Expand Up @@ -214,6 +220,7 @@ def _augment_obs(self, obs: torch.Tensor) -> torch.Tensor:
Returns:
The augmented observation.
"""
obs = obs.to(self._device)
return torch.cat([obs, self._safety_obs], dim=-1)

def _log_value(
Expand Down