Grasp Viewer¶
Inspect articulated hand geometry, contact normals, and coordinate frames in 3-D. Selecting a grasp updates its configuration, joint coordinates, and quality tables together.
Click any demonstration to enlarge it with playback controls.
Inputs and Model Geometry¶
graspit_py.viewer writes a self-contained HTML file from planner JSON or a
schema 1.0 NPZ archive with its JSON metadata sidecar from the
dataset exporter. Writing the file uses NumPy and the Python
standard library; viewing it uses a WebGL2 browser. Each record links its pose,
coordinates, contacts, and quality samples in the display.
Robot and object XML files provide OFF triangle meshes, including models
written by the MuJoCo exporter. Forward kinematics from
graspit_py.kinematics places each hand link at the saved DOF values. The scene
reconstructs the saved nominal configuration from these model files and records.
Write a Viewer¶
The RealHand L6 walkthrough writes an exported hand, an object,
and ranked candidates under output/. This command writes a viewer for them:
python -m graspit_py.viewer output/candidates.json \
--robot output/hand/l6.xml --object output/object/cube.xml \
--out output/candidates.html
Open output/candidates.html in a browser that supports WebGL2. The command
prints the output path and any input warnings. It validates inputs before
writing the HTML; an invalid or unsupported input ends the command with exit
status 2 and an explanatory message. From a source checkout, run the command
from the repository root with PYTHONPATH=$PWD.
Dataset archives use the same command. The
LEAP mustard-bottle example
contains an NPZ archive, its JSON sidecar, and 2,048 object-surface points. For a
view of contacts, palm frames, and surface points, extract it and pass the archive:
mkdir -p output/leap-example
unzip docs/examples/learning/leap-mustard-example.zip -d output/leap-example
python -m graspit_py.viewer output/leap-example/ycb_mustard_bottle.npz \
--out output/leap-example/mustard.html
The archive alone supplies each candidate’s palm (hand-base) frame, nominal
contacts, and the object’s surface points. Add hand and object meshes by
supplying the exported LEAP robot XML through --robot and the object XML
prepared by the
household-object workflow
through --object. The script
examples/visualization/view_archive.py uses the Python interface to select
the rows with the largest native GraspIt! epsilon.
Option |
Meaning |
|---|---|
|
Planner |
|
Output |
|
GraspIt! robot XML; its palm and link XML files are read from the adjacent |
|
GraspIt! object XML |
|
Explicit archive JSON sidecar path (default: the |
|
Comma-separated zero-based source rows, shown in the given order (default: all rows) |
|
Drawn length of each normal arrow (default: 0.22 times half the diagonal of the object geometry’s bounding box, or of the first candidate’s hand and contacts without object geometry) |
|
Contact-to-hand distance above which a warning is added (default: 1.0) |
|
Page title |
Coordinates and Geometry¶
Every drawn coordinate is expressed in the object frame in millimeters. Planner
JSON already uses millimeters. For archives, the viewer multiplies the
translation of T_object_hand_m, the contact positions, and
object_pointcloud_m by 1000 and copies rotations, normals, DOF values, and
quality labels unchanged. The palm frame is the hand-base frame of the robot XML
and is drawn at T_object_hand.
Palm and link XML files are resolved under the iv/ directory beside the robot
XML, as GraspIt! resolves them, and each body’s geometryFile type="off" is
resolved beside its body XML. A vertex \(p\) of link \(l\) in chain \(c\), given in
that link’s frame, is drawn at
where \(T_{OH}\) is T_object_hand, \(B_c\) is the chain transform stored in the
robot XML, and \(A_k(q)=R_z(\theta_k)\,T_z(d_k)\,T_x(a_k)\,R_x(\alpha_k)\) is the
DH transform of joint \(k\). The joint angle \(\theta_k\) is the coupling ratio times
the joint’s DOF value plus the constant offset in its <theta> element. The
palm mesh is drawn at \(T_{OH}\).
Supply the robot model used for grasp generation. Its link meshes define
GraspIt!’s collision geometry and the viewer’s hand surfaces. For
hands exported from MuJoCo, these meshes are the exported collision geoms in the
selected mesh representation,
source or convex_hull. Record this choice with the export configuration; the
hand manifest stores the joint and link maps. The object mesh is drawn at the
identity pose of its own frame. Archive surface samples, when present, appear
as a surface-point layer.
An archive’s mesh_scale records a scale already applied to the model files.
The page lists it and draws OFF coordinates at their stored values. Contacts
are the saved nominal contacts. Each normal is drawn as an arrow that ends at
its contact and points into the object. The scene displays nominal poses and
contacts; the sample tables contain quality values from nominal and perturbed
closures.
Quality Labels and Samples¶
The quality panel groups the available values by their computation:
Field |
Displayed label |
Group |
|---|---|---|
|
Native GraspIt! epsilon |
Native GraspIt! Quality |
|
Recomputed epsilon, nominal closure |
Python Wrench-Quality Analysis |
|
Recomputed epsilon, sample mean |
Python Wrench-Quality Analysis |
|
Recomputed epsilon, lower-tail mean |
Python Wrench-Quality Analysis |
|
Recomputed task wrench capacity, nominal closure |
Python Wrench-Quality Analysis |
|
Recomputed task wrench capacity, sample mean |
Python Wrench-Quality Analysis |
|
Planner ranking score |
Planner Ranking |
Each value appears with the field description stored by the dataset exporter in archive metadata. The lower-tail mean also shows the planner’s tail mass when available. The native value follows GraspIt!’s material and normalization conventions. Recomputed values come from the Python grasp wrench space analysis in the source planner; Candidate Records defines them. The panel displays the scalar quality fields available in the selected record and omits missing fields. Numbers are rounded for display, and hovering over a value shows the stored number.
The sample table shows the recomputed epsilon matrix of the selected candidate.
Row 0 is the nominal closure, later rows are closures after perturbed
approaches, and columns follow planner.friction_samples. Task samples use
the same layout and appear even if the source record omits epsilon samples.
Failed closures contribute zero entries; successful closures contribute their
computed wrench-quality values, which can also be zero. These values
characterize modeled contact geometry under the recorded contact and friction
model.
Input Checks¶
Records are validated with the rules of the dataset exporter: millimeter and radian units, rigid homogeneous transforms, unit normals, one DOF count for all records, and sample columns matching the recorded friction coefficients when available. Hand and object models must meet the following requirements. A violation raises an input error:
Rigid revolute DOFs (
type="r"). Breakaway (type="b") and compliant (type="c") DOFs require contact history to recover joint angles. For the native Barrett model, inspect records as palm frames and contacts in this viewer. Reconstruct its full articulation by replaying the saved commands in native GraspIt!, as described in Barrett Breakaway Coordinates.Revolute DH joints,
<theta>expressions of the formd<k>with an optional*<ratio>and+<degrees>, andRevolutelinks with one joint per link. Chain transforms usetranslationandrotationMatrix.Exactly three values per chain translation and nine per rotation matrix, rigid chain transforms, and finite base and DH parameters, including coupling ratios and angle offsets.
Body geometry referenced by
geometryFile type="off". Bake body-level scaling and transforms into the mesh vertices;geometryScalingandtransformelements in a body XML trigger input errors.A plain
OFFheader, exactly three vertices per face, finite coordinates, and valid vertex indices.A robot DOF count matching every record and all referenced files present.
The viewer continues displaying records with the following warnings, listed on the page and printed to standard error:
a robot, object, or object-mesh SHA-256 that differs from the archive provenance record;
a supplied robot or object filename that differs from the filename recorded with the candidates;
archive DOF names that differ from the
dof_jointsof a hand manifest beside the robot XML;a saved contact farther than
--contact-tolerance-mmfrom the reconstructed hand triangles.
Large contact-to-hand distances flag inconsistencies among the supplied model, DOF order, and saved pose. The distance measures geometric consistency between the saved contacts and reconstructed hand triangles.
Python Interface¶
from graspit_py import viewer
records = viewer.load_records("output/candidates.json")
hand = viewer.load_hand_model("output/hand/l6.xml")
obj = viewer.load_object_model("output/object/cube.xml")
scene = viewer.build_scene(records, hand=hand, object_model=obj, rows=[0, 1, 2])
viewer.write_html(scene, "output/top-three.html")
load_records reads planner .json payloads and .npz archives, and
load_planner_records also accepts an in-memory payload dictionary. For each
candidate, the scene returned by build_scene includes the object-frame mesh
transforms in link_transforms_mm and the contact distances in
contact_hand_distance_mm. For a single record, hand_link_transforms and
hand_vertices_object_mm return these placements as NumPy arrays. Input errors
raise ViewerInputError, a subclass of ValueError.
Browser Requirements and File Size¶
WebGL2 enables the 3-D view. Other browsers show the tables and a message explaining that the 3-D view is disabled. Meshes are embedded as base64 float32 vertices and uint32 triangle indices, so the file size grows with the triangle count of the supplied meshes. Poses, DOF values, and quality labels are embedded as JSON numbers at their stored precision. The page follows the browser’s light or dark color preference.