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

The meaning of "terminated" and "truncated" #34

Open
pumfish opened this issue Sep 29, 2024 · 1 comment
Open

The meaning of "terminated" and "truncated" #34

pumfish opened this issue Sep 29, 2024 · 1 comment

Comments

@pumfish
Copy link

pumfish commented Sep 29, 2024

Hello, I'm trying to add new simulation environment experiments in ManiSkill2-Learn.
While modifying the code, I noticed the following function in vec_env.py.

    # Special functions
    def step_dict(self, actions, idx=None, restart=True):
        idx, slice_idx = self._process_idx(idx)
        obs = self.recent_obs.slice(slice_idx).copy(wrapper=False)
        next_obs, reward, terminated, truncated, info = self.step(actions, idx=idx)
        term_or_trunc = np.logical_or(terminated, truncated)
        if np.any(term_or_trunc) and restart:
            self.reset(idx=np.where(term_or_trunc[..., 0])[0])
            
        return dict(
            obs=obs,
            next_obs=next_obs,
            actions=GDict(actions).f64_to_f32(wrapper=False),
            rewards=reward,
            dones=terminated,
            episode_dones=term_or_trunc,
            infos=info,
            worker_indices=idx,
        )

I checked the step function in ManiSkill2 and found that truncated is set to False. Doesn't that mean dones will always equal episode_dones?
Also, when a task is completed successfully and when a task reaches the maximum number of steps, what value should terminated return?

@xuanlinli17
Copy link
Collaborator

xuanlinli17 commented Sep 29, 2024

dones doesn't equal to episode_dones. See

"episode_dones": False if i < length - 1 else True,
. episode_dones is merely an episode separator, while dones is success indicator. dones corresponds to terminated while episode_dones corresponds to truncated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants