ravens/agents/gt_state.py
def info_to_gt_obs(self, info, t_worldaug_world=None, goal=None):
        """Daniel: from info dict of IDs, create the observation for GT models.

        Assumes `info` consists of just PyBullet object IDs. Creates a numpy array
        from combining the `object_x_y_theta` from all IDs, and potentially add more
        info based on if using box dimensions or colors; see `__init__()` above.

        For soft body tasks, we should have data generated so that info[cloth_id] or
        info[bag_id] contains the 3D vertex position of each point. For now we only
        test with cloth since the bag ones are honestly probably better suited with
        just the beads (but will have to check). Fortunately, all the cloth tasks as
        of late October 2020 will use ID=5 as the soft body andit's also easy to check.

        (14 Oct 2020) adding `goal` as argument for goal conditioning. Use goal['info'].
            We're going to stack the two together into one input.
        (14 Oct 2020) adding support for cloth. We don't use `pos` and `quat`, just use
            the returned object_x_y_theta.
        """
        info = self.remove_nonint_keys(info)
        if goal is not None:
            g_info = self.remove_nonint_keys(goal['info'])
        else:
            g_info = {}

        observation_vector = []
        object_keys = sorted(info.keys())
        for object_key in object_keys:
            # Daniel: adding this special case.
            if (self.task in TASKS_SOFT and len(info[object_key]) == 2):
                object_x_y_theta = self.extract_x_y_theta(info[object_key], t_worldaug_world, softbody=True)
            else:
                object_x_y_theta, pos, quat = self.extract_x_y_theta(info[object_key], t_worldaug_world)
            observation_vector.append(object_x_y_theta)
            if self.use_box_dimensions:
                observation_vector.append(self.extract_box_dimensions(info[object_key]))
            if self.use_colors:
                # For bag-color-goal we only want IDs 4 and 38.
                if self.task in ['bag-color-goal']:
                    if object_key in [4, 38]:
                        #print(f'for {object_key}, color: {self.extract_color(info[object_key])}')
                        observation_vector.append(self.extract_color(info[object_key]))
                else:
                    observation_vector.append(self.extract_color(info[object_key]))

        # Repeat for goal info using `g_info` instead of `info`, assuming g_info != {}.
        for object_key in sorted(g_info.keys()):
            # Daniel: adding this special case.
            if (self.task in TASKS_SOFT and len(g_info[object_key]) == 2):
                object_x_y_theta = self.extract_x_y_theta(g_info[object_key], t_worldaug_world, softbody=True)
            else:
                object_x_y_theta, pos, quat = self.extract_x_y_theta(g_info[object_key], t_worldaug_world)
            observation_vector.append(object_x_y_theta)
            if self.use_box_dimensions:
                observation_vector.append(self.extract_box_dimensions(g_info[object_key]))
            if self.use_colors:
                # For bag-color-goal we only want IDs 4 and 38.
                if self.task in ['bag-color-goal']:
                    if object_key in [4, 38]:
                        #print(f'for {object_key}, color: {self.extract_color(g_info[object_key])}')
                        observation_vector.append(self.extract_color(g_info[object_key]))
                else:
                    observation_vector.append(self.extract_color(g_info[object_key]))

        # Finally, make it a single 1D np.array.
        if (self.task in TASKS_SOFT):
            # Daniel: was getting some errors w/setting the type since usually we will have:
            #   [array(x1,y1,z1), array(x2,y2,z2), ...] and doing np.array() on this will return
            #   array([ [x1,y1,z1], [x2,y2,z2], ...] ) and then reshape(-1) will return
            #   array([x1,y1,z1,x2,y2,z2,...]) and it's easy to make as np.float32 type.
            # But with stuff like cloth, we have:
            #   [array(x1,y1,z1), array(c1,c2,c3,c4,...,c100), ...] and this will mean the
            # np.array().reshape(-1) results in a 2D array of arrays, so we can't do np.float32.
            # However, np.concatenate seems to fix these issues.
            observation_vector = np.concatenate(observation_vector).reshape(-1).astype(np.float32)
        else:
            observation_vector = np.array(observation_vector).reshape(-1).astype(np.float32)

        # pad with zeros
        if self.max_obs_vector_length != 0:
             observation_vector = np.pad(observation_vector,
                [0, self.max_obs_vector_length-len(observation_vector)])

        return observation_vector
Daniel: from info dict of IDs, create the observation for GT models.

        Assumes `info` consists of just PyBullet object IDs. Creates a numpy array
        from combining the `object_x_y_theta` from all IDs, and potentially add more
        info based on if using box dimensions or colors; see `__init__()` above.

        For soft body tasks, we should have data generated so that info[cloth_id] or
        info[bag_id] contains the 3D vertex position of each point. For now we only
        test with cloth since the bag ones are honestly probably better suited with
        just the beads (but will have to check). Fortunately, all the cloth tasks as
        of late October 2020 will use ID=5 as the soft body andit's also easy to check.

        (14 Oct 2020) adding `goal` as argument for goal conditioning. Use goal['info'].
            We're going to stack the two together into one input.
        (14 Oct 2020) adding support for cloth. We don't use `pos` and `quat`, just use
            the returned object_x_y_theta.
        
from info dict of IDs, create the observation for GT models.
Assumes `info` consists of just PyBullet object IDs. Creates a numpy array
from combining the `object_x_y_theta` from all IDs, and potentially add more
info based on if using box dimensions or colors; see `__init__()` above.

For soft body tasks, we should have data generated so that info[cloth_id] or
info[bag_id] contains the 3D vertex position of each point. For now we only
test with cloth since the bag ones are honestly probably better suited with
just the beads (but will have to check). Fortunately, all the cloth tasks as
of late October 2020 will use ID=5 as the soft body andit's also easy to check.

(14 Oct 2020) adding `goal` as argument for goal conditioning. Use goal['info'].
We're going to stack the two together into one input.
(14 Oct 2020) adding support for cloth. We don't use `pos` and `quat`, just use
the returned object_x_y_theta.
from info dict of IDs create the observation for GT models . Assumes ` info ` consists of just PyBullet object IDs . Creates a numpy array from combining the ` object_x_y_theta ` from all IDs and potentially add more info based on if using box dimensions or colors ; see ` __init__ () ` above . For soft body tasks we should have data generated so that info [ cloth_id ] or info [ bag_id ] contains the 3D vertex position of each point . For now we only test with cloth since the bag ones are honestly probably better suited with just the beads ( but will have to check ) . Fortunately all the cloth tasks as of late October 2020 will use ID = 5 as the soft body andit ' s also easy to check . ( 14 Oct 2020 ) adding ` goal ` as argument for goal conditioning . Use goal [ ' info ' ] . We ' re going to stack the two together into one input . ( 14 Oct 2020 ) adding support for cloth . We don ' t use ` pos ` and ` quat ` just use the returned object_x_y_theta .
def info_to_gt_obs(self, info, t_worldaug_world=None, goal=None):
        info = self.remove_nonint_keys(info)
        if goal is not None:
            g_info = self.remove_nonint_keys(goal['info'])
        else:
            g_info = {}
        observation_vector = []
        object_keys = sorted(info.keys())
        for object_key in object_keys:
            if (self.task in TASKS_SOFT and len(info[object_key]) == 2):
                object_x_y_theta = self.extract_x_y_theta(info[object_key], t_worldaug_world, softbody=True)
            else:
                object_x_y_theta, pos, quat = self.extract_x_y_theta(info[object_key], t_worldaug_world)
            observation_vector.append(object_x_y_theta)
            if self.use_box_dimensions:
                observation_vector.append(self.extract_box_dimensions(info[object_key]))
            if self.use_colors:
                if self.task in ['bag-color-goal']:
                    if object_key in [4, 38]:
                        observation_vector.append(self.extract_color(info[object_key]))
                else:
                    observation_vector.append(self.extract_color(info[object_key]))
        for object_key in sorted(g_info.keys()):
            if (self.task in TASKS_SOFT and len(g_info[object_key]) == 2):
                object_x_y_theta = self.extract_x_y_theta(g_info[object_key], t_worldaug_world, softbody=True)
            else:
                object_x_y_theta, pos, quat = self.extract_x_y_theta(g_info[object_key], t_worldaug_world)
            observation_vector.append(object_x_y_theta)
            if self.use_box_dimensions:
                observation_vector.append(self.extract_box_dimensions(g_info[object_key]))
            if self.use_colors:
                if self.task in ['bag-color-goal']:
                    if object_key in [4, 38]:
                        observation_vector.append(self.extract_color(g_info[object_key]))
                else:
                    observation_vector.append(self.extract_color(g_info[object_key]))
        if (self.task in TASKS_SOFT):
            observation_vector = np.concatenate(observation_vector).reshape(-1).astype(np.float32)
        else:
            observation_vector = np.array(observation_vector).reshape(-1).astype(np.float32)
        if self.max_obs_vector_length != 0:
             observation_vector = np.pad(observation_vector,
                [0, self.max_obs_vector_length-len(observation_vector)])
        return observation_vector
def info_to_gt_obs ( self , info , t_worldaug_world = None , goal = None ) : info = self . remove_nonint_keys ( info ) if goal is not None : g_info = self . remove_nonint_keys ( goal [ 'info' ] ) else : g_info = { } observation_vector = [ ] object_keys = sorted ( info . keys ( ) ) for object_key in object_keys : if ( self . task in TASKS_SOFT and len ( info [ object_key ] ) == 2 ) : object_x_y_theta = self . extract_x_y_theta ( info [ object_key ] , t_worldaug_world , softbody = True ) else : object_x_y_theta , pos , quat = self . extract_x_y_theta ( info [ object_key ] , t_worldaug_world ) observation_vector . append ( object_x_y_theta ) if self . use_box_dimensions : observation_vector . append ( self . extract_box_dimensions ( info [ object_key ] ) ) if self . use_colors : if self . task in [ 'bag-color-goal' ] : if object_key in [ 4 , 38 ] : observation_vector . append ( self . extract_color ( info [ object_key ] ) ) else : observation_vector . append ( self . extract_color ( info [ object_key ] ) ) for object_key in sorted ( g_info . keys ( ) ) : if ( self . task in TASKS_SOFT and len ( g_info [ object_key ] ) == 2 ) : object_x_y_theta = self . extract_x_y_theta ( g_info [ object_key ] , t_worldaug_world , softbody = True ) else : object_x_y_theta , pos , quat = self . extract_x_y_theta ( g_info [ object_key ] , t_worldaug_world ) observation_vector . append ( object_x_y_theta ) if self . use_box_dimensions : observation_vector . append ( self . extract_box_dimensions ( g_info [ object_key ] ) ) if self . use_colors : if self . task in [ 'bag-color-goal' ] : if object_key in [ 4 , 38 ] : observation_vector . append ( self . extract_color ( g_info [ object_key ] ) ) else : observation_vector . append ( self . extract_color ( g_info [ object_key ] ) ) if ( self . task in TASKS_SOFT ) : observation_vector = np . concatenate ( observation_vector ) . reshape ( - 1 ) . astype ( np . float32 ) else : observation_vector = np . array ( observation_vector ) . reshape ( - 1 ) . astype ( np . float32 ) if self . max_obs_vector_length != 0 : observation_vector = np . pad ( observation_vector , [ 0 , self . max_obs_vector_length - len ( observation_vector ) ] ) return observation_vector
Daniel: from info dict of IDs, create the observation for GT models.
Daniel : from info dict of IDs create the observation for GT models .
"""Daniel: from info dict of IDs, create the observation for GT models.

        Assumes `info` consists of just PyBullet object IDs. Creates a numpy array
        from combining the `object_x_y_theta` from all IDs, and potentially add more
        info based on if using box dimensions or colors; see `__init__()` above.

        For soft body tasks, we should have data generated so that info[cloth_id] or
        info[bag_id] contains the 3D vertex position of each point. For now we only
        test with cloth since the bag ones are honestly probably better suited with
        just the beads (but will have to check). Fortunately, all the cloth tasks as
        of late October 2020 will use ID=5 as the soft body andit's also easy to check.

        (14 Oct 2020) adding `goal` as argument for goal conditioning. Use goal['info'].
            We're going to stack the two together into one input.
        (14 Oct 2020) adding support for cloth. We don't use `pos` and `quat`, just use
            the returned object_x_y_theta.
        """ # Daniel: adding this special case. # For bag-color-goal we only want IDs 4 and 38. #print(f'for {object_key}, color: {self.extract_color(info[object_key])}') # Repeat for goal info using `g_info` instead of `info`, assuming g_info != {}. # Daniel: adding this special case. # For bag-color-goal we only want IDs 4 and 38. #print(f'for {object_key}, color: {self.extract_color(g_info[object_key])}') # Finally, make it a single 1D np.array. # Daniel: was getting some errors w/setting the type since usually we will have: #   [array(x1,y1,z1), array(x2,y2,z2), ...] and doing np.array() on this will return #   array([ [x1,y1,z1], [x2,y2,z2], ...] ) and then reshape(-1) will return #   array([x1,y1,z1,x2,y2,z2,...]) and it's easy to make as np.float32 type. # But with stuff like cloth, we have: #   [array(x1,y1,z1), array(c1,c2,c3,c4,...,c100), ...] and this will mean the # np.array().reshape(-1) results in a 2D array of arrays, so we can't do np.float32. # However, np.concatenate seems to fix these issues. # pad with zeros
self
info
t_worldaug_world
goal