Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing step to return truncate=True #445

Merged
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
14 changes: 8 additions & 6 deletions metaworld/envs/mujoco/sawyer_xyz/sawyer_xyz_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,9 @@ def sawyer_observation_space(self):
def step(self, action):
assert len(action) == 4, f"Actions should be size 4, got {len(action)}"
self.set_xyz_action(action[:3])
if self.curr_path_length >= self.max_path_length:
raise ValueError("You must reset the env manually once truncate==True")
self.do_simulation([action[-1], -action[-1]], n_frames=self.frame_skip)
if self.curr_path_length > self.max_path_length:
raise ValueError(
"Maximum path length allowed by the benchmark has been exceeded"
)
self.curr_path_length += 1

# Running the simulator can sometimes mess up site positions, so
Expand Down Expand Up @@ -496,12 +494,16 @@ def step(self, action):
dtype=np.float64,
)
reward, info = self.evaluate_state(self._last_stable_obs, action)
# step will never return a terminal if there is a success
# step will never return a terminate==True if there is a success
# but we can return truncate=True if the current path length == max path length
truncate = False
if self.curr_path_length == self.max_path_length:
truncate = True
return (
np.array(self._last_stable_obs, dtype=np.float64),
reward,
False,
False,
truncate,
info,
)

Expand Down
Loading