Repository navigation
Extract grasp validation and use physical labels in atomic skills - #1297
Conversation
[High impact] The latest changes appear safe to merge. SummaryThis PR adds standalone physical grasp validation and labeling, then lets atomic skills select from prepared physical labels.
|
47323b0 to
93ec91f
Compare
han-xudong
left a comment
There was a problem hiding this comment.
I found one blocking regression in Affordance expansion and seven additional issues in grasp validation, configuration compatibility, and cache handling. The inline comments include the conditions that trigger each issue. The focused suite passed 760 tests with the pinned DexSim version.
han-xudong
left a comment
There was a problem hiding this comment.
Follow-up review of 866ab81c. The Affordance branch and TCP calibration fixes passed focused probes. The inline findings cover remaining gaps in physical-label validation and the horizontal handover tutorial.
yuecideng
left a comment
There was a problem hiding this comment.
Follow-up ideas for grasp labeling
I ran the CobotMagic V100 cup on 93ec91f with DexSim 0.6.1rc1, then checked the sampling, batching, and output paths at ebb642d. The numbers below are from the earlier run.
-
Sample across support modes. The two placements retained in the quick cup run differed by 179.5° in overall rotation and both settled on their sides. For the cup, allocate part of the placement budget to each of upright, side-lying, and inverted. For general meshes, group settled poses by the object-frame support normal and contact region, then retain some yaw diversity inside each group. The 3×3 demonstration produced all three cup modes and successful grasps in each.
-
Pack different placements into one physics batch. Extend
restore_placementto accept one transform per arena while keeping the single-transform input for existing callers. Track the placement, direction, and candidate index per row when pooling pending trials across placements. This would let another placement use the spare slots in a partial batch. The drop stage could also use a smaller scene sized to its own budget. The defaults currently allocate 2,400 arenas for at most 100 drop attempts, anddrop_objectsfills the remaining arenas with the final rotation. -
Keep validation evidence with each label. Preserve the tested TCP, placement, backend, and grasp-quality measurements such as slip, rotation, and bilateral contact fraction. In the paired cup run, two TCPs passed on both backends and moved 5.67 mm and 6.97 mm relative to the gripper during the DexUni hold. When pose NMS groups nearby labels, retain each original trial and its evidence. That would let a consumer prefer a steadier grasp among the candidates that satisfy its geometry and IK checks.
-
Precompute common asset caches before planning. The final-TCP consistency issue from the earlier revision is covered by the calibration fix. A precompute path using the same cache identity would also let commonly used hand and object pairs avoid synchronous labeling on the first planning call.
For verification, run the same three placements and nine TCPs once grouped by placement and once in a mixed batch. Compare per-candidate outcomes and placement provenance. On the full cup labeling run, report coverage per support mode, the fraction of arena slots assigned to real candidates, and passing labels after NMS per wall-clock second.
Pool trials across settled placements, retain NMS membership and measured contact quality, and precompute mounted-hand labels with the planning cache identity.
|
@yuecideng, all four items from your grasp-labeling follow-up are implemented in
On the full CobotMagic cup run (seed 0, GPU PhysX, DexSim 0.6.0), the five placements covered two upright, two side-lying and one inverted. They yielded 6,890, 5,695 and 3,904 labels after NMS, respectively. Real trials occupied 20,698/21,600 slots (95.82%). The CLI produced 16,489 labels in 146.38 s, or 112.65 labels/s end to end. For the three-placement, nine-TCP replay, all nine restored placements matched their recorded transforms within |
yuecideng
left a comment
There was a problem hiding this comment.
Architecture follow-up
Keep the split between reusable Affordance geometry, physical label preparation, and robot-specific planning. The offline CLI and the isolated cache worker already share the labeling implementation. Preparation and lookup also share the key builder, which is important for parity.
- Group the validator, labeling pipeline, and cache under
embodichain/lab/sim/affordance/grasp/, as clarified in the directory discussion. Keep existing public Affordance imports available through thin re-exports. - Have each host resolve the effective grasp request once and use it for preparation and lookup. The deployment CLI currently enumerates commands and TCP adjustments from templates, while planning resolves those values from the invocation. The deployment adapter can own the Gym assembly and no-render event setup, with the CLI responsible for argument handling and reporting.
I added the standalone cold-cache trace and regression suggestion to the existing thread.
| Returns: | ||
| Padded candidates with explicit validity. | ||
| """ | ||
| from embodichain.lab.sim.grasp.cache import validated_label_provider |
There was a problem hiding this comment.
[P2] Keep physical-cache enforcement at the Atomic Skill boundary
This shared query now calls validated_label_provider() before dispatching to the supplied generator. A geometry-only AntipodalGraspPoseGenerator with its default validated_labels=None therefore raises ValueError before get_valid_grasp_poses(). The same public query on the base branch delegates directly to the supplied geometry generator.
Please let the shared Affordance query use the injected candidate service, and apply the physical-label requirement at the Atomic Skill entry point. A focused regression can cover both the geometry-only query and the skill's physical-label requirement.
There was a problem hiding this comment.
Fixed in f244eacc0. AntipodalAffordance.get_grasp_candidates() delegates to the injected generator's get_valid_grasp_poses(), so it works with a geometry-only Antipodal generator. Atomic Skill service registration enforces the physical-label requirement, and Antipodal skill planning reads the validated cache.
A focused regression uses the same generator with validated_labels=None in both paths. The shared query returns the candidate rows and their validity mask. Registering that generator for an Atomic Skill raises the expected error.
|
@yuecideng, following up on your architecture review. The validator, labeling pipeline and cache now live together under
The standalone host now resolves each invocation once, prepares its labels, and hands that same request to the planner. Regression tests cover an invocation-level command override and mirrored TCP, plus a batch with different closing commands and a 12 mm TCP offset. On DexSim 0.6.1rc1, standalone PickUp launched one labeling worker from an empty cache and zero on the warm run. The handover regression also generated and reused both hands' label files. |
yuecideng
left a comment
There was a problem hiding this comment.
Verified the host-side cold-cache fix at 47f5947bc. The standalone sampled-grasp examples and tutorials use the shared preparation path before planning. Motion benchmarks prepare the keys during case generation and planner setup, outside timed compilation.
Both the cube and Rubik's-cube PickUp regressions passed with real GPU simulation. Each cold run launched one labeling worker and each warm run reused its cache. The 220 focused tests, Black, and API documentation checks passed.
The validator, labeling, and cache modules are under affordance/grasp/. The shared Affordance query delegates to the geometry generator.
Description
This PR targets
main.embodichain label-graspssamples stable object placements and upper-hemisphere approaches, validates candidates in physics, applies pose NMS and saves object-local TCPs, opening widths and placement provenance in a PyTorch file. Per-direction checkpoints support--resume. The cup example resolves the standalone CobotMagic V100 hand from the existing robot catalog. Custom URDFs and meshes can be supplied explicitly.PickUp,HandOver,AxisAlign,Slide,OpenDoorandCoordinatedPickmentreuse physical labels keyed by the hand URDF, scaled mesh and validation settings, including the mounted finger drives and pad contact properties. Eligible grasps are ordered by closing-axis and contact-center cost, then by TCP +Z alignment for equal costs. The arm checks the required waypoints in groups of 50 candidates. Nominal planning selects the first reachable label. Affordance branches use distinct reachable labels and can match a preferred object-local pose. Antipodal requires a physical label cache and two contact pads. PickUp and prototype refinement execute the same TCP that passed validation, including any configuredgrasp_frame_to_eefcalibration. Existing configs that setopening_weightmust remove it. Opening widths are still used for eligibility and are saved with the labels.Generate labels for the CobotMagic cup
From the repository root with the simulation environment active, run the full example with five placements, 64 directions and up to 100 candidates per direction.
Run PickUp and HandOver in a native window
Use the same environment from a graphical desktop. Each command runs one episode automatically.
--filter-dataset-savingskips dataset recording. The first grasp waits for physical validation if the hand and mesh are missing from the local cache. Subsequent runs reuse the labels. When enabled,force_refreshor the tutorial flag--force_reannotateregenerates each key once per service instance. This revision uses a new cache key for OBJ mesh transfer to the native worker.Franka PickUp runs the repeated pick-and-place task.
Dual UR5 HandOver uses DH PGI grippers to pick up, transfer and place the can. Each direction admits up to 200 candidates. The source and receiving TCP approach tolerances are 10° and 30°.
Validation
Type of change
opening_weightoptionChecklist
main. The standalone API, labeling command and atomic skills run using the existing catalog assets.