ravens/gripper.py
def activate_def(self, defId):
        """Simulates suction by anchoring vertices of the deformable object.

        Get distance values in `distances`, get indices for argsort, then
        resulting indices in `distances_sort` correspond _exactly_ to vertex
        indices arranged from nearest to furthest to the gripper.
        """
        _, vert_pos_l = p.getMeshData(defId, -1, flags=p.MESH_DATA_SIMULATION_MESH)
        gripper_position = np.float32(p.getLinkState(self.body, 0)[0])
        distances = []
        for v_position in vert_pos_l:
            d = gripper_position - np.float32(v_position)
            distances.append(np.linalg.norm(d))
        distances_sort = np.argsort(distances)

        anchors = []
        for i in range(self.def_nb_anchors):
            # For each vertex close enough (under threshold), create anchor(s).
            vIndex = distances_sort[i]
            if distances[vIndex] > self.def_threshold:
                #print(f'WARNING, dist={distances[vIndex]:0.4f} > {self.def_threshold} '
                #    f'This means our gripper touched the surface (z=0)')
                pass
            # This should prevent us from gripping if the suction didn't grip anything.
            if distances[vIndex] > self.def_ignore:
                print(f'WARNING, dist={distances[vIndex]:0.4f} > thresh '
                    f'{self.def_ignore:0.4f}. No points are close to the suction')
                break
            anchorId = p.createSoftBodyAnchor(
                    softBodyBodyUniqueId=defId,
                    nodeIndex=vIndex,
                    bodyUniqueId=self.body,
                    linkIndex=-1,)
            anchors.append(anchorId)

        info = {'anchors': anchors,
                'closest_vertex': distances_sort[0],
                'min_distance': np.min(distances),}
        #print(info)
        return info
Simulates suction by anchoring vertices of the deformable object.

        Get distance values in `distances`, get indices for argsort, then
        resulting indices in `distances_sort` correspond _exactly_ to vertex
        indices arranged from nearest to furthest to the gripper.
        
Simulates suction by anchoring vertices of the deformable object.
Get distance values in `distances`, get indices for argsort, then
resulting indices in `distances_sort` correspond _exactly_ to vertex
indices arranged from nearest to furthest to the gripper.
Simulates suction by anchoring vertices of the deformable object . Get distance values in ` distances ` get indices for argsort then resulting indices in ` distances_sort ` correspond _exactly_ to vertex indices arranged from nearest to furthest to the gripper .
def activate_def(self, defId):
        _, vert_pos_l = p.getMeshData(defId, -1, flags=p.MESH_DATA_SIMULATION_MESH)
        gripper_position = np.float32(p.getLinkState(self.body, 0)[0])
        distances = []
        for v_position in vert_pos_l:
            d = gripper_position - np.float32(v_position)
            distances.append(np.linalg.norm(d))
        distances_sort = np.argsort(distances)
        anchors = []
        for i in range(self.def_nb_anchors):
            vIndex = distances_sort[i]
            if distances[vIndex] > self.def_threshold:
                pass
            if distances[vIndex] > self.def_ignore:
                print(f'WARNING, dist={distances[vIndex]:0.4f} > thresh '
                    f'{self.def_ignore:0.4f}. No points are close to the suction')
                break
            anchorId = p.createSoftBodyAnchor(
                    softBodyBodyUniqueId=defId,
                    nodeIndex=vIndex,
                    bodyUniqueId=self.body,
                    linkIndex=-1,)
            anchors.append(anchorId)
        info = {'anchors': anchors,
                'closest_vertex': distances_sort[0],
                'min_distance': np.min(distances),}
        return info
def activate_def ( self , defId ) : _ , vert_pos_l = p . getMeshData ( defId , - 1 , flags = p . MESH_DATA_SIMULATION_MESH ) gripper_position = np . float32 ( p . getLinkState ( self . body , 0 ) [ 0 ] ) distances = [ ] for v_position in vert_pos_l : d = gripper_position - np . float32 ( v_position ) distances . append ( np . linalg . norm ( d ) ) distances_sort = np . argsort ( distances ) anchors = [ ] for i in range ( self . def_nb_anchors ) : vIndex = distances_sort [ i ] if distances [ vIndex ] > self . def_threshold : pass if distances [ vIndex ] > self . def_ignore : print ( f'WARNING, dist={distances[vIndex]:0.4f} > thresh ' f'{self.def_ignore:0.4f}. No points are close to the suction' ) break anchorId = p . createSoftBodyAnchor ( softBodyBodyUniqueId = defId , nodeIndex = vIndex , bodyUniqueId = self . body , linkIndex = - 1 , ) anchors . append ( anchorId ) info = { 'anchors' : anchors , 'closest_vertex' : distances_sort [ 0 ] , 'min_distance' : np . min ( distances ) , } return info
Simulates suction by anchoring vertices of the deformable object.
Simulates suction by anchoring vertices of the deformable object .
"""Simulates suction by anchoring vertices of the deformable object.

        Get distance values in `distances`, get indices for argsort, then
        resulting indices in `distances_sort` correspond _exactly_ to vertex
        indices arranged from nearest to furthest to the gripper.
        """ # For each vertex close enough (under threshold), create anchor(s). #print(f'WARNING, dist={distances[vIndex]:0.4f} > {self.def_threshold} ' #    f'This means our gripper touched the surface (z=0)') # This should prevent us from gripping if the suction didn't grip anything. #print(info)
self
defId