mobilemanipbench-data / debug /850 /n052_regrip /n052_regrip_moves.diff
prlq's picture
debug/850: N052 regrip experiment diffs
df97e9a verified
Raw History Blame Contribute Delete
2.81 kB
--- /scratch/sz850/magicsim_atomic/patches/n052/moves.py.orig 2026-11-08 21:58:53.784845000 -0500
+++ /scratch/sz850/magicsim_atomic/patches/n052/moves.py 2026-11-08 21:58:53.788681000 -0500
@@ -347,7 +347,7 @@
PICK_HEIGHT = 0.04 if ROBOT == "go2_arm" else 0.12
-def pick_top_down(ctx, name: str, *, also_ignore=(), pre_height: float = PICK_HEIGHT, lift: float = PICK_HEIGHT, tcp_height: float = GRASP_TCP_HEIGHT, via_x: float | None = None, square: bool = False, label: str = "pick", tilt: float | None = None, lift2: tuple[float, float] | None = None):
+def pick_top_down(ctx, name: str, *, also_ignore=(), pre_height: float = PICK_HEIGHT, lift: float = PICK_HEIGHT, tcp_height: float = GRASP_TCP_HEIGHT, via_x: float | None = None, square: bool = False, label: str = "pick", tilt: float | None = None, lift2: tuple[float, float] | None = None, regrip: int = 0, centre_tol: float = 0.012):
"""Phases that pinch the loose rigid object ``name`` from above across its short horizontal axis and lift it ``lift``.
The dataset objects (dice, pens, rubber blocks) are annotated with dexterous-hand candidates the stock ``Grasp`` skill cannot use with the
@@ -380,6 +380,20 @@
yield move_to(tcp + np.array([0.0, 0.0, pre_height]), down, closing, MOVE_PRE, f"{label}:pre")
yield from settle_at(ctx, tcp, down, closing, label=f"{label}:down")
yield hand("close", f"{label}:close")
+ # N052 experiment (opt-in, default off): after the pinch closes, check the object sits between the pads along the closing axis. If it is off-centre by more
+ # than centre_tol the pinch is asymmetric (536 s101: the left pad tip hit the scale plate, the right pad closed to the stop at ~0 force, the dice ended 5 cm to
+ # one side), so open, re-descend on the object's CURRENT position and close again (at most `regrip` times).
+ for k in range(regrip):
+ obj, _ = ctx.object(name)
+ eef, _ = ctx.eef()
+ off = float(np.dot(np.asarray(obj, dtype=float) - np.asarray(eef, dtype=float), np.asarray(closing, dtype=float)))
+ if abs(off) <= centre_tol:
+ break
+ yield hand("open", f"{label}:regrip{k}:open")
+ tcp = np.asarray(obj, dtype=float) + np.array([0.0, 0.0, tcp_height])
+ yield move_to(tcp + np.array([0.0, 0.0, 0.03]), down, closing, MOVE_LINEAR, f"{label}:regrip{k}:up")
+ yield from settle_at(ctx, tcp, down, closing, label=f"{label}:regrip{k}:down")
+ yield hand("close", f"{label}:regrip{k}:close")
yield move_to(tcp + np.array([0.0, 0.0, lift]), down, closing, MOVE_LINEAR, f"{label}:lift")
if lift2 is not None and ROBOT == "go2_arm":
yield move_to(tcp + np.array([0.0, 0.0, float(lift2[1])]), go2_approach(ctx, tcp, closing, float(lift2[0])), closing, MOVE_LINEAR, f"{label}:lift2")