ravens/tasks/task.py
def done(self):
        """Check if the task is done AND has not failed.

        To be clear: for normal Ravens envs, `self.total_rewards` represents
        the sum of deltas, or the sum of the `reward` returned by `reward()`
        defined above. Think of it as the "true reward at this moment." I
        follow this convention for custom environments.

        For multi-step tasks such as `cloth-cover-item`, one must need to
        accomplish all stages correctly. HOWEVER, DO NOT use a condition here
        that says `done = (self.task_sage == X)` as that will prevent us from
        getting extra reward information, since in `self.reward()`, we first
        check if `done()` is True, then do the rewards. If it's a task-based
        done, then we immediately exit but don't compute the final reward
        statistics (undesirable).

        (08 Sept 2020): I added self.exit_gracefully, which will help us
        quickly exit if the demo has failed, but this is not handled here.

        (14 Sept 2020) We want self.done to return True if we should consider
        this episode a 'success'. If not, then if we return done=True with
        the understanding that it's a failure, we need to filter this episode
        elsewhere. So far the only tasks where this extra consideration has
        to be applied are bag-items-easy and bag-items-hard. See `main.py`
        and the `ignore_this_demo()` method.
        """
        zone_done, goal_done, cable_done, cov_done, bag_done = \
                False, False, False, False, False

        if self.metric == 'zone':
            zone_done = self.total_rewards == 1
        elif self.metric == 'cable-target':
            cable_done = self.total_rewards == 1
        elif self.metric == 'cable-ring':
            fraction = self.total_rewards / self.circle_area
            if fraction >= self.area_thresh:
                print(f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}')
                cable_done = True
        elif self.metric == 'cloth-coverage':
            if self.total_rewards >= self.coverage_threshold:
                cov_done = True
        elif self.metric == 'cloth-cover-item':
            cov_done = self.total_rewards == 1
        elif self.metric == 'bag-alone-open':
            fraction = self.total_rewards / self.circle_area
            if fraction >= self.area_thresh:
                print(f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}')
                bag_done = True
        elif self.metric == 'bag-items':
            bag_done = self.total_rewards > 0
        elif self.metric == 'bag-color-goal':
            bag_done = self.total_rewards >= 0.95

        # For envs with self.metric == 'pose'.
        if hasattr(self, 'goal'):
            goal_done = len(self.goal['steps']) == 0
        return zone_done or cable_done or cov_done or bag_done or goal_done
Check if the task is done AND has not failed.

        To be clear: for normal Ravens envs, `self.total_rewards` represents
        the sum of deltas, or the sum of the `reward` returned by `reward()`
        defined above. Think of it as the "true reward at this moment." I
        follow this convention for custom environments.

        For multi-step tasks such as `cloth-cover-item`, one must need to
        accomplish all stages correctly. HOWEVER, DO NOT use a condition here
        that says `done = (self.task_sage == X)` as that will prevent us from
        getting extra reward information, since in `self.reward()`, we first
        check if `done()` is True, then do the rewards. If it's a task-based
        done, then we immediately exit but don't compute the final reward
        statistics (undesirable).

        (08 Sept 2020): I added self.exit_gracefully, which will help us
        quickly exit if the demo has failed, but this is not handled here.

        (14 Sept 2020) We want self.done to return True if we should consider
        this episode a 'success'. If not, then if we return done=True with
        the understanding that it's a failure, we need to filter this episode
        elsewhere. So far the only tasks where this extra consideration has
        to be applied are bag-items-easy and bag-items-hard. See `main.py`
        and the `ignore_this_demo()` method.
        
Check if the task is done AND has not failed.

For multi-step tasks such as `cloth-cover-item`, one must need to
accomplish all stages correctly.

(08 Sept 2020): I added self.exit_gracefully, which will help us
quickly exit if the demo has failed, but this is not handled here.

(14 Sept 2020) We want self.done to return True if we should consider
this episode a 'success'. If not, then if we return done=True with
the understanding that it's a failure, we need to filter this episode
elsewhere. So far the only tasks where this extra consideration has
to be applied are bag-items-easy and bag-items-hard. See `main.py`
and the `ignore_this_demo()` method.
Check if the task is done AND has not failed . For multi - step tasks such as ` cloth - cover - item ` one must need to accomplish all stages correctly . ( 08 Sept 2020 ) : I added self . exit_gracefully which will help us quickly exit if the demo has failed but this is not handled here . ( 14 Sept 2020 ) We want self . done to return True if we should consider this episode a ' success ' . If not then if we return done = True with the understanding that it ' s a failure we need to filter this episode elsewhere . So far the only tasks where this extra consideration has to be applied are bag - items - easy and bag - items - hard . See ` main . py ` and the ` ignore_this_demo () ` method .
def done(self):
        zone_done, goal_done, cable_done, cov_done, bag_done = \
                False, False, False, False, False
        if self.metric == 'zone':
            zone_done = self.total_rewards == 1
        elif self.metric == 'cable-target':
            cable_done = self.total_rewards == 1
        elif self.metric == 'cable-ring':
            fraction = self.total_rewards / self.circle_area
            if fraction >= self.area_thresh:
                print(f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}')
                cable_done = True
        elif self.metric == 'cloth-coverage':
            if self.total_rewards >= self.coverage_threshold:
                cov_done = True
        elif self.metric == 'cloth-cover-item':
            cov_done = self.total_rewards == 1
        elif self.metric == 'bag-alone-open':
            fraction = self.total_rewards / self.circle_area
            if fraction >= self.area_thresh:
                print(f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}')
                bag_done = True
        elif self.metric == 'bag-items':
            bag_done = self.total_rewards > 0
        elif self.metric == 'bag-color-goal':
            bag_done = self.total_rewards >= 0.95
        if hasattr(self, 'goal'):
            goal_done = len(self.goal['steps']) == 0
        return zone_done or cable_done or cov_done or bag_done or goal_done
def done ( self ) : zone_done , goal_done , cable_done , cov_done , bag_done = False , False , False , False , False if self . metric == 'zone' : zone_done = self . total_rewards == 1 elif self . metric == 'cable-target' : cable_done = self . total_rewards == 1 elif self . metric == 'cable-ring' : fraction = self . total_rewards / self . circle_area if fraction >= self . area_thresh : print ( f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}' ) cable_done = True elif self . metric == 'cloth-coverage' : if self . total_rewards >= self . coverage_threshold : cov_done = True elif self . metric == 'cloth-cover-item' : cov_done = self . total_rewards == 1 elif self . metric == 'bag-alone-open' : fraction = self . total_rewards / self . circle_area if fraction >= self . area_thresh : print ( f'Frac: {fraction:0.4f} exceeds: {self.area_thresh:0.4f}' ) bag_done = True elif self . metric == 'bag-items' : bag_done = self . total_rewards > 0 elif self . metric == 'bag-color-goal' : bag_done = self . total_rewards >= 0.95 if hasattr ( self , 'goal' ) : goal_done = len ( self . goal [ 'steps' ] ) == 0 return zone_done or cable_done or cov_done or bag_done or goal_done
Check if the task is done AND has not failed.
Check if the task is done AND has not failed .
"""Check if the task is done AND has not failed.

        To be clear: for normal Ravens envs, `self.total_rewards` represents
        the sum of deltas, or the sum of the `reward` returned by `reward()`
        defined above. Think of it as the "true reward at this moment." I
        follow this convention for custom environments.

        For multi-step tasks such as `cloth-cover-item`, one must need to
        accomplish all stages correctly. HOWEVER, DO NOT use a condition here
        that says `done = (self.task_sage == X)` as that will prevent us from
        getting extra reward information, since in `self.reward()`, we first
        check if `done()` is True, then do the rewards. If it's a task-based
        done, then we immediately exit but don't compute the final reward
        statistics (undesirable).

        (08 Sept 2020): I added self.exit_gracefully, which will help us
        quickly exit if the demo has failed, but this is not handled here.

        (14 Sept 2020) We want self.done to return True if we should consider
        this episode a 'success'. If not, then if we return done=True with
        the understanding that it's a failure, we need to filter this episode
        elsewhere. So far the only tasks where this extra consideration has
        to be applied are bag-items-easy and bag-items-hard. See `main.py`
        and the `ignore_this_demo()` method.
        """ # For envs with self.metric == 'pose'.
self