ravens/tasks/task.py
def random_pose(self, env, object_size, hard_code=False):
        """Get random collision-free pose in workspace bounds for object.

        For tasks like sweeping to a zone target, generates a target zone at
        random, then later generates items to be swept in it. The second step
        requires free space to avoid being within the zone.

        The `mask` defines a distribution over pixels in the 320x160 top-down
        image, where 0=black means don't sample those pixels. For the
        remaining pixels (1=white), sample uniformly from those. It should
        correctly detect if we have a bag [but may require a low enough z
        coord]. If you increase `object_size`, then that reduces the
        available sampling area.

        Args:
            object_size: a tuple (x,y,z) used to determine erode size.
            hard_code: dummy argument added by me to debug positions.

        Returns:
            (position,rotation): used to convert from base / root link (I
                think) to where the object (or zone) should be located. The
                position must be sampled from the workspace, which is why
                environments with target zones have the zones sampled on the
                workstation. The rotation is only applied on the z-axis since
                we assume objects start on the same level surface (i.e.,
                workstation) and it's a simple uniform sample.
        """
        plane_id = 1
        max_size = np.sqrt(object_size[0]**2 + object_size[1]**2)
        erode_size = int(np.round(max_size / self.pixel_size))
        colormap, heightmap, object_mask = self.get_object_masks(env)

        # Sample freespace regions in workspace.
        mask = np.uint8(object_mask == plane_id)
        mask[0, :], mask[:, 0], mask[-1, :], mask[:, -1] = 0, 0, 0, 0
        mask = cv2.erode(mask, np.ones((erode_size, erode_size), np.uint8))
        if np.sum(mask) == 0:
            print('Warning! Sum of mask is zero in random_pose().')
            return
        pixel = utils.sample_distribution(np.float32(mask))
        position = utils.pixel_to_position(
            pixel, heightmap, self.bounds, self.pixel_size)
        position = (position[0], position[1], object_size[2] / 2)
        rtheta = np.random.rand() * 2 * np.pi
        rotation = p.getQuaternionFromEuler((0, 0, rtheta))

        if hard_code:
            # Daniel: to debug some hard-coded positions / quaternions.
            position = (0.0, 0.0, 0.0)
            rotation = p.getQuaternionFromEuler((0,0,0))
        return position, rotation
Get random collision-free pose in workspace bounds for object.

        For tasks like sweeping to a zone target, generates a target zone at
        random, then later generates items to be swept in it. The second step
        requires free space to avoid being within the zone.

        The `mask` defines a distribution over pixels in the 320x160 top-down
        image, where 0=black means don't sample those pixels. For the
        remaining pixels (1=white), sample uniformly from those. It should
        correctly detect if we have a bag [but may require a low enough z
        coord]. If you increase `object_size`, then that reduces the
        available sampling area.

        Args:
            object_size: a tuple (x,y,z) used to determine erode size.
            hard_code: dummy argument added by me to debug positions.

        Returns:
            (position,rotation): used to convert from base / root link (I
                think) to where the object (or zone) should be located. The
                position must be sampled from the workspace, which is why
                environments with target zones have the zones sampled on the
                workstation. The rotation is only applied on the z-axis since
                we assume objects start on the same level surface (i.e.,
                workstation) and it's a simple uniform sample.
        
Get random collision-free pose in workspace bounds for object.
For tasks like sweeping to a zone target, generates a target zone at
random, then later generates items to be swept in it. The second step
requires free space to avoid being within the zone.

The `mask` defines a distribution over pixels in the 320x160 top-down
image, where 0=black means don't sample those pixels. For the
remaining pixels (1=white), sample uniformly from those. It should
correctly detect if we have a bag [but may require a low enough z
coord]. If you increase `object_size`, then that reduces the
available sampling area.
Get random collision - free pose in workspace bounds for object . For tasks like sweeping to a zone target generates a target zone at random then later generates items to be swept in it . The second step requires free space to avoid being within the zone . The ` mask ` defines a distribution over pixels in the 320x160 top - down image where 0 = black means don ' t sample those pixels . For the remaining pixels ( 1 = white ) sample uniformly from those . It should correctly detect if we have a bag [ but may require a low enough z coord ] . If you increase ` object_size ` then that reduces the available sampling area .
def random_pose(self, env, object_size, hard_code=False):
        plane_id = 1
        max_size = np.sqrt(object_size[0]**2 + object_size[1]**2)
        erode_size = int(np.round(max_size / self.pixel_size))
        colormap, heightmap, object_mask = self.get_object_masks(env)
        mask = np.uint8(object_mask == plane_id)
        mask[0, :], mask[:, 0], mask[-1, :], mask[:, -1] = 0, 0, 0, 0
        mask = cv2.erode(mask, np.ones((erode_size, erode_size), np.uint8))
        if np.sum(mask) == 0:
            print('Warning! Sum of mask is zero in random_pose().')
            return
        pixel = utils.sample_distribution(np.float32(mask))
        position = utils.pixel_to_position(
            pixel, heightmap, self.bounds, self.pixel_size)
        position = (position[0], position[1], object_size[2] / 2)
        rtheta = np.random.rand() * 2 * np.pi
        rotation = p.getQuaternionFromEuler((0, 0, rtheta))
        if hard_code:
            position = (0.0, 0.0, 0.0)
            rotation = p.getQuaternionFromEuler((0,0,0))
        return position, rotation
def random_pose ( self , env , object_size , hard_code = False ) : plane_id = 1 max_size = np . sqrt ( object_size [ 0 ] ** 2 + object_size [ 1 ] ** 2 ) erode_size = int ( np . round ( max_size / self . pixel_size ) ) colormap , heightmap , object_mask = self . get_object_masks ( env ) mask = np . uint8 ( object_mask == plane_id ) mask [ 0 , : ] , mask [ : , 0 ] , mask [ - 1 , : ] , mask [ : , - 1 ] = 0 , 0 , 0 , 0 mask = cv2 . erode ( mask , np . ones ( ( erode_size , erode_size ) , np . uint8 ) ) if np . sum ( mask ) == 0 : print ( 'Warning! Sum of mask is zero in random_pose().' ) return pixel = utils . sample_distribution ( np . float32 ( mask ) ) position = utils . pixel_to_position ( pixel , heightmap , self . bounds , self . pixel_size ) position = ( position [ 0 ] , position [ 1 ] , object_size [ 2 ] / 2 ) rtheta = np . random . rand ( ) * 2 * np . pi rotation = p . getQuaternionFromEuler ( ( 0 , 0 , rtheta ) ) if hard_code : position = ( 0.0 , 0.0 , 0.0 ) rotation = p . getQuaternionFromEuler ( ( 0 , 0 , 0 ) ) return position , rotation
Get random collision-free pose in workspace bounds for object.
Get random collision - free pose in workspace bounds for object .
"""Get random collision-free pose in workspace bounds for object.

        For tasks like sweeping to a zone target, generates a target zone at
        random, then later generates items to be swept in it. The second step
        requires free space to avoid being within the zone.

        The `mask` defines a distribution over pixels in the 320x160 top-down
        image, where 0=black means don't sample those pixels. For the
        remaining pixels (1=white), sample uniformly from those. It should
        correctly detect if we have a bag [but may require a low enough z
        coord]. If you increase `object_size`, then that reduces the
        available sampling area.

        Args:
            object_size: a tuple (x,y,z) used to determine erode size.
            hard_code: dummy argument added by me to debug positions.

        Returns:
            (position,rotation): used to convert from base / root link (I
                think) to where the object (or zone) should be located. The
                position must be sampled from the workspace, which is why
                environments with target zones have the zones sampled on the
                workstation. The rotation is only applied on the z-axis since
                we assume objects start on the same level surface (i.e.,
                workstation) and it's a simple uniform sample.
        """ # Sample freespace regions in workspace. # Daniel: to debug some hard-coded positions / quaternions.
used to convert from base / root link (I
think) to where the object (or zone) should be located. The
position must be sampled from the workspace, which is why
environments with target zones have the zones sampled on the
workstation. The rotation is only applied on the z-axis since
we assume objects start on the same level surface  and it's a simple uniform sample.
used to convert from base / root link ( I think ) to where the object ( or zone ) should be located . The position must be sampled from the workspace which is why environments with target zones have the zones sampled on the workstation . The rotation is only applied on the z - axis since we assume objects start on the same level surface and it ' s a simple uniform sample .
(position,rotation)
self
env
object_size
a tuple (x,y,z) used to determine erode size.
a tuple ( x y z ) used to determine erode size .
hard_code
dummy argument added by me to debug positions.
dummy argument added by me to debug positions .