ravens/gripper.py
def activate(self, possible_objects, def_IDs):
        """
        Simulates suction by creating rigid fixed constraint between suction
        gripper and contacted object.

        :def_IDs: a list of IDs of deformable objects.
        """
        if not self.activated:
            # Only report contact points involving linkIndexA of bodyA (the
            # suction) -- returns a list (actually, a tuple) of such points.
            points = p.getContactPoints(bodyA=self.body, linkIndexA=0)

            if len(points) > 0:
                # Handle contact with a rigid object.
                for point in points:
                    object_id, contact_link = point[2], point[4]
                if object_id in possible_objects:
                    body_pose = p.getLinkState(self.body, 0)
                    object_pose = p.getBasePositionAndOrientation(object_id)
                    world_to_body = p.invertTransform(
                        body_pose[0], body_pose[1])
                    object_to_body = p.multiplyTransforms(
                        world_to_body[0], world_to_body[1],
                        object_pose[0], object_pose[1])
                    self.contact_constraint = p.createConstraint(
                        parentBodyUniqueId=self.body,
                        parentLinkIndex=0,
                        childBodyUniqueId=object_id,
                        childLinkIndex=contact_link,
                        jointType=p.JOINT_FIXED,
                        jointAxis=(0, 0, 0),
                        parentFramePosition=object_to_body[0],
                        parentFrameOrientation=object_to_body[1],
                        childFramePosition=(0, 0, 0),
                        childFrameOrientation=(0, 0, 0))
                    # Handle the case when rigid item makes contact with a
                    # deformable, which will cause this distance to shrink.
                    # Assumes gripper is suctioning ONE rigid item at a time.
                    distance = np.linalg.norm(
                            np.float32(body_pose[0]) - np.float32(object_pose[0]))
                    self.init_grip_distance = distance
                    self.init_grip_item = object_id
                #print(f'Gripping a rigid item!')
            elif (self.def_grip_item is not None):
                # Otherwise, focus on gripping a _deformable_ with anchors.
                info = self.activate_def(self.def_grip_item)
                self.def_grip_anchors = info['anchors']
                self.def_min_vertex = info['closest_vertex']
                self.def_min_distance = info['min_distance']
                #print(f'Gripping a deformable!')

            self.activated = True

        Simulates suction by creating rigid fixed constraint between suction
        gripper and contacted object.

        :def_IDs: a list of IDs of deformable objects.
        
Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object.
Simulates suction by creating rigid fixed constraint between suction gripper and contacted object .
def activate(self, possible_objects, def_IDs):
        if not self.activated:
            points = p.getContactPoints(bodyA=self.body, linkIndexA=0)
            if len(points) > 0:
                for point in points:
                    object_id, contact_link = point[2], point[4]
                if object_id in possible_objects:
                    body_pose = p.getLinkState(self.body, 0)
                    object_pose = p.getBasePositionAndOrientation(object_id)
                    world_to_body = p.invertTransform(
                        body_pose[0], body_pose[1])
                    object_to_body = p.multiplyTransforms(
                        world_to_body[0], world_to_body[1],
                        object_pose[0], object_pose[1])
                    self.contact_constraint = p.createConstraint(
                        parentBodyUniqueId=self.body,
                        parentLinkIndex=0,
                        childBodyUniqueId=object_id,
                        childLinkIndex=contact_link,
                        jointType=p.JOINT_FIXED,
                        jointAxis=(0, 0, 0),
                        parentFramePosition=object_to_body[0],
                        parentFrameOrientation=object_to_body[1],
                        childFramePosition=(0, 0, 0),
                        childFrameOrientation=(0, 0, 0))
                    distance = np.linalg.norm(
                            np.float32(body_pose[0]) - np.float32(object_pose[0]))
                    self.init_grip_distance = distance
                    self.init_grip_item = object_id
            elif (self.def_grip_item is not None):
                info = self.activate_def(self.def_grip_item)
                self.def_grip_anchors = info['anchors']
                self.def_min_vertex = info['closest_vertex']
                self.def_min_distance = info['min_distance']
            self.activated = True
def activate ( self , possible_objects , def_IDs ) : if not self . activated : points = p . getContactPoints ( bodyA = self . body , linkIndexA = 0 ) if len ( points ) > 0 : for point in points : object_id , contact_link = point [ 2 ] , point [ 4 ] if object_id in possible_objects : body_pose = p . getLinkState ( self . body , 0 ) object_pose = p . getBasePositionAndOrientation ( object_id ) world_to_body = p . invertTransform ( body_pose [ 0 ] , body_pose [ 1 ] ) object_to_body = p . multiplyTransforms ( world_to_body [ 0 ] , world_to_body [ 1 ] , object_pose [ 0 ] , object_pose [ 1 ] ) self . contact_constraint = p . createConstraint ( parentBodyUniqueId = self . body , parentLinkIndex = 0 , childBodyUniqueId = object_id , childLinkIndex = contact_link , jointType = p . JOINT_FIXED , jointAxis = ( 0 , 0 , 0 ) , parentFramePosition = object_to_body [ 0 ] , parentFrameOrientation = object_to_body [ 1 ] , childFramePosition = ( 0 , 0 , 0 ) , childFrameOrientation = ( 0 , 0 , 0 ) ) distance = np . linalg . norm ( np . float32 ( body_pose [ 0 ] ) - np . float32 ( object_pose [ 0 ] ) ) self . init_grip_distance = distance self . init_grip_item = object_id elif ( self . def_grip_item is not None ) : info = self . activate_def ( self . def_grip_item ) self . def_grip_anchors = info [ 'anchors' ] self . def_min_vertex = info [ 'closest_vertex' ] self . def_min_distance = info [ 'min_distance' ] self . activated = True
Simulates suction by creating rigid fixed constraint between suction
gripper and contacted object.
Simulates suction by creating rigid fixed constraint between suction gripper and contacted object .
"""
        Simulates suction by creating rigid fixed constraint between suction
        gripper and contacted object.

        :def_IDs: a list of IDs of deformable objects.
        """ # Only report contact points involving linkIndexA of bodyA (the # suction) -- returns a list (actually, a tuple) of such points. # Handle contact with a rigid object. # Handle the case when rigid item makes contact with a # deformable, which will cause this distance to shrink. # Assumes gripper is suctioning ONE rigid item at a time. #print(f'Gripping a rigid item!') # Otherwise, focus on gripping a _deformable_ with anchors. #print(f'Gripping a deformable!')
self
possible_objects
def_IDs
def_IDs
a list of IDs of deformable objects.
a list of IDs of deformable objects .