grasp
Main class for analytic metrics
- Author:
Lukas Rustler
- class pybullet_grasper.grasp.Grasp(client: Any)[source]
Bases:
objectClass to encapsulate functions regarding grasp quality. Based on: https://ieeexplore.ieee.org/document/1371616/ and https://ieeexplore.ieee.org/document/772531/
- class MinkowskiSum(wrenches: ndarray, cone_vertices: int, contacts: int, dims: int = 6)[source]
Bases:
objectRecursively compute Minkowski sum of individual wrenches.
- minkowski_sum(contact_id: int, prev_sum: ndarray | None = None, used_wrenches: int = 0) int[source]
Recursive function itself :param contact_id: id of contact :type contact_id: int :param prev_sum: previous sum; used to sum more than two wrenches :type prev_sum: np.ndarray, optional, default=None :param used_wrenches: number of currently selected wrenches :type used_wrenches: int, optional, default=0 :return: 0 :rtype: int
- colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
- static compute_cone(mus: ndarray, forces: ndarray, normals: ndarray, points: ndarray, num_edges: int = 8) Tuple[ndarray, ndarray][source]
Function to compute the friction cone for given normal force :param mus: friction coefficient :type mus: array of floats :param forces: normal forces in the touch points :type forces: Nx3 np.array() :param normals: the size of the force :type normals: Nx1 np.array() :param points: array with contact points :type points: Nx3 np.array/ :param num_edges: number of edges to approximate the cone :type num_edges: int, optional, default=8 :return: approximated forces on the edge of the friction cones :rtype: tuple[np.ndarray, np.ndarray]
- evaluate_contact(hull_types: List[str] = ['L1', 'Linf']) Dict[str, ConvexHull][source]
Call necessary function and computes the convex hull of wrenches
- Parameters:
hull_types (list[str], optional, default=["L1", "Linf"]) – types of hull: L1 or Linf
- Returns:
computed convex hulls for requested metrics
- Return type:
dict[str, scipy.spatial.ConvexHull]
- get_contact_info(object_id: int, torque_origin: ndarray) Tuple[ndarray | None, ndarray | None, ndarray | None, ndarray | None][source]
Obtain contact information and divide it into arrays :param object_id: id of the grasped object :type object_id: int :return: contact points, contact normals, contact forces, mutual frictions :rtype: tuple[np.ndarray | None, np.ndarray | None, np.ndarray | None, np.ndarray | None]
- project_to_3d(where_to_project: ndarray, fixed_coordinates: List[int], hyperplanes: ndarray, hull_type: str = 'L1_fixed_force') None[source]
Projects selected dimensions of a 6D hull to 3D and builds a mesh for visualization.
- Parameters:
where_to_project (np.ndarray) – values used for fixed dimensions during projection
fixed_coordinates (list[int]) – indices of coordinates that stay fixed during projection
hyperplanes (np.ndarray) – hyperplane representation of the source hull
hull_type (str, optional, default="L1_fixed_force") – name used as key in visualized GWS meshes
- Returns:
None
- Return type:
None
- rgb_colors = array([[0.12156863, 0.46666667, 0.70588235], [1. , 0.49803922, 0.05490196], [0.17254902, 0.62745098, 0.17254902], [0.83921569, 0.15294118, 0.15686275], [0.58039216, 0.40392157, 0.74117647], [0.54901961, 0.3372549 , 0.29411765], [0.89019608, 0.46666667, 0.76078431], [0.49803922, 0.49803922, 0.49803922], [0.7372549 , 0.74117647, 0.13333333], [0.09019608, 0.74509804, 0.81176471]])