hylo.manip.dexgrasp¶
Package: hylo-manip · Core contracts
dexgrasp ¶
Multi-finger grasp planning for any dexterous hand (a HandModel: HandSpec plus its MJCF) on an object given as points or a mesh.
Object: one or more convex parts (the hull of the points, of the mesh, or of each given part), so the signed distance to the object is the smallest of the parts' hull distances and a ray's entry into the object is exact. A partial point cloud seen from above is extruded down to the table first (the hidden underside is solid).
Planning, per candidate hand pose: 1. sample: approach directions (+x of the TCP) over the sphere, minus those from below the table, times rolls about the approach (the +y closing axis); the TCP aims at the object's centre (plus offsets during refinement); 2. approach: the open hand (a rigid point set) slides along the approach until its first point would enter the object or the table (ray-hull entry distances, exact), never past the centre; 3. close: each finger moves from the open command towards the closing command (HandSpec.closed for "power", the "pinch" preset for "pinch") until its links touch the object (a sweep, then bisection per finger); 4. score: contacts are the finger and palm samples within a few millimetres of the surface (one per link, the hull facet's normal); the epsilon measure of their friction-cone wrenches (force closure when positive), the total normal force needed to hold the object against gravity, penetration, how many fingers touch, and an optional preferred approach direction or pose; 5. refine: the best few are perturbed (offset, tilt, roll) for a couple of rounds and re-scored (a short cross-entropy search over the pose; the fingers re-close each time).
plan() returns DexGrasp records, best first; to_goals() turns them into toolkit Goals (pre-pose back along the
approach with the hand open, then the hand closing to a squeeze command past the contact angles).
ObjectGeom
dataclass
¶
ObjectGeom(planes: list[ndarray], points: ndarray, centre: ndarray, radius: float, mass: float = 0.1, part_spheres: list | None = None)
An object as convex parts (list of facet arrays) with its surface samples.
from_parts
classmethod
¶
parts: point sets (world), each one convex part (its hull).
from_points
classmethod
¶
One convex part from observed points; with a table height the points are extruded down to it.
from_mesh
classmethod
¶
from_mesh(V: ndarray, F: ndarray, parts: Sequence[tuple[ndarray, ndarray]] | None = None, mass: float = 0.1, spacing: float = 0.004) -> 'ObjectGeom'
A mesh (its hull), or several convex parts of it (V, F each) for a concave object.
sdf ¶
Signed distance (negative inside; outside a lower bound of the true distance) and the outward normal of
the nearest facet. With far, points farther than radius + far from the centre are not evaluated (their
distance is reported as far, normal zero).
entry ¶
Per point, the smallest advance s >= 0 along unit direction a at which it enters the object (inf: never).
DexGrasp
dataclass
¶
DexGrasp(tcp: ndarray, approach: ndarray, q_open: ndarray, q_contact: ndarray, q_squeeze: ndarray, contacts: ndarray, normals: ndarray, contact_fingers: list[str], epsilon: float, effort: float, penetration: float, score: float, style: str, refined: bool = False, info: dict = dict())
PlannerConfig
dataclass
¶
PlannerConfig(mu: float = 0.5, cone_edges: int = 8, n_dirs: int = 32, n_rolls: int = 6, min_down: float = -0.25, max_up: float = 0.2, table_clearance: float = 0.004, contact_tol: float = 0.004, pen_tol: float = 0.0015, max_penetration: float = 0.004, sweep: int = 14, squeeze: float = 0.35, pre_dist: float = 0.1, keep: int = 10, refine_top: int = 6, refine_rounds: int = 2, refine_samples: int = 10, offset_sigma: float = 0.008, tilt_sigma: float = 0.15, seed: int = 0)
DexGraspPlanner ¶
Grasps of one hand. See the module docstring.
evaluate ¶
evaluate(obj: ObjectGeom, R: ndarray, aim: ndarray, table_z: float | None, style: str, q_open: ndarray | None = None, scene: ndarray | None = None, prefer: dict | None = None) -> DexGrasp | None
Approach along R's x axis towards aim, close, score. None when the hand cannot get near. Without
q_open the hand approaches open, and again with a wider pre-shape (half way to the "flat" preset) when the
open hand stops short of the aim (fingertips on the object's top); the better grasp is kept.
plan ¶
plan(obj: ObjectGeom, table_z: float | None = None, style: str | None = None, scene: ndarray | None = None, prefer: dict | None = None, rotations: Sequence[ndarray] | None = None) -> list[DexGrasp]
Ranked grasps (best first). style: "power", "pinch" (a preset name) or None for both. prefer: {"approach": unit vector, "tcp": 4x4 pose, "w_approach", "w_rot", "w_pos"} biases the ranking towards it. rotations: candidate TCP rotations instead of the sampled sphere.
mesh_surface ¶
Points on a triangle mesh, about spacing apart (plus the vertices).
to_goals ¶
Toolkit Goals (verb "grasp"): pre-pose back along the approach, hand open while moving, then the squeeze.