From b0e9ce39ab7abc4fa84534586d7f950b28b215f5 Mon Sep 17 00:00:00 2001 From: Cutshion Date: Thu, 29 Oct 2026 19:10:11 +0900 Subject: [PATCH] Recalibrate the grasp point and camera for reliable top grasps Co-Authored-By: Claude Opus 5.5 --- data/grasp_teach.json | 8 +-- data/grasp_top_teach.json | 125 ++++++++++++++++++++++++++++++++++++++ docs/TUNING.md | 1 + manipulation/skills.py | 4 +- robot/gripper.py | 3 +- tests/test_reach.py | 4 +- tests/test_skills.py | 2 +- vision/objects.py | 5 +- 8 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 data/grasp_top_teach.json diff --git a/data/grasp_teach.json b/data/grasp_teach.json index 17928d5..0ba740b 100644 --- a/data/grasp_teach.json +++ b/data/grasp_teach.json @@ -28,9 +28,9 @@ -301.0 ], "tcp_offset_flange": [ - 88.1, - -61.6, - 179.8 + 85.6, + -80.6, + 175.0 ], - "tcp_offset_note": "new fingers, 2026-10-29: mean of 3 owner's free-drive side grasps (data/grasp_side_teach.json; cup in the hooks' belly, grasp turned -24..-33 deg; the cup's centre seen after the hand backed out), spread under 1 mm; then 1 mm to the left across the fingers (the first auto side grasp brushed the cup with the right finger, owner); the old point was 43.5 mm too far out along the fingers. Height kept from the tape (hook bottom 20 mm over a 142 mm cup's rim + 8 mm). Before: [83.2, -69.2, 221.8]" + "tcp_offset_note": "new fingers, 2026-10-29: fitted to 7 owner's free-drive top grasps (data/grasp_top_teach.json; the cup centred in the hooks' belly about 5 cm under the rim, grasp turned -45..+32 deg, 4 cup spots) together with the camera's cup-centre error (vision/objects.py ROUND_FIX_MM): every sample within 5 mm; the height so that BELOW_RIM_MM puts the hooks where the owner held them. Before: [88.1, -61.6, 179.8]" } \ No newline at end of file diff --git a/data/grasp_top_teach.json b/data/grasp_top_teach.json new file mode 100644 index 0000000..5d91068 --- /dev/null +++ b/data/grasp_top_teach.json @@ -0,0 +1,125 @@ +{ + "note": "owner's free-drive top grasps: flange pose with the cup in the hooks' belly at the height to hold it; the cup's (x, y, top) seen after the hand went up; arm frame, mm / deg", + "samples": [ + { + "flange": [ + -32.73, + 395.05, + -122.97, + 85.34, + 45.38, + -138.41 + ], + "cup": [ + -179.5, + 526.0, + -185.0 + ] + }, + { + "flange": [ + -67.74, + 377.14, + -106.16, + 88.52, + 46.09, + -148.56 + ], + "cup": [ + -179.0, + 527.0, + -186.0 + ] + }, + { + "flange": [ + -109.59, + 353.26, + -109.32, + 87.41, + 46.54, + -166.57 + ], + "cup": [ + -177.0, + 529.0, + -180.0 + ] + }, + { + "flange": [ + -99.1, + 372.04, + -126.48, + 83.73, + 46.66, + 176.53 + ], + "cup": [ + -121.0, + 561.0, + -186.0 + ] + }, + { + "flange": [ + 83.91, + 434.11, + -112.24, + 86.4, + 45.29, + -123.79 + ], + "cup": [ + -94.0, + 532.0, + -185.0 + ] + }, + { + "flange": [ + 49.81, + 358.44, + -121.65, + 83.94, + 46.84, + -139.16 + ], + "cup": [ + -104.0, + 493.0, + -188.0 + ] + }, + { + "flange": [ + 67.96, + 403.95, + -116.63, + 85.47, + 46.75, + -105.22 + ], + "cup": [ + -126.0, + 445.0, + -185.5 + ] + }, + { + "flange": [ + 22.91, + 319.2, + -123.94, + 83.73, + 46.66, + -138.47 + ], + "cup": [ + -125.0, + 446.0, + -188.0 + ] + } + ] +} \ No newline at end of file diff --git a/docs/TUNING.md b/docs/TUNING.md index db983ea..7efb39b 100644 --- a/docs/TUNING.md +++ b/docs/TUNING.md @@ -98,6 +98,7 @@ Every value here is a constant at the top of its file, with a comment on what it | `tasks/fetch.py` | `WAIST_STEP_DEG` | 10° | "Give me your hand" turns the waist toward the person while the arm moves, in moves this long: a STOP ends the turn after the move it is in. Bigger is smoother, smaller stops sooner | | `manipulation/skills.py` | `BACK_OUT_NEAR_MM` | 30 mm | A pick stopped with the hand within this of its way in: the next pick first backs out the way it came (side: out, then up; top: up) | | `tasks/fetch.py` | `WIDTH_NEAR_MM` | 250 mm | A width further than this from the pick zone does not refuse a pick (far widths read ~8 mm too wide); measured again up close | +| `manipulation/skills.py` | `BELOW_RIM_MM` | 32 mm | Top grasp: the grasp point this far below the cup's top (40 let a cup narrower lower down slip out; 25 left the fingers' top over the rim) | | `manipulation/skills.py` | `MIN_WIDTH`, `MAX_WIDTH` | 70, 97 mm | Object widths the gripper takes from above (the open tips 100, margin 3; wider cups are taken from the side; belly 102 / 77, tips 100 / 73; [10_GRIPPER.md](10_GRIPPER.md)). `MIN_WIDTH` 61 enables the finger-tip grasp (61–72 mm) | | `manipulation/skills.py` | `BELLY_MIN_MM` | 70 mm | Thinner objects are held between the finger tips (the belly closes only to 68 mm) | | `manipulation/skills.py` | `SIDE_MAX_WIDTH`, `SIDE_BAND_MM`, `SIDE_SEEN_MM` | 97, 12, 0 mm | Side grasp of a cup too wide at the top: the width the fingers meet (seen + `SIDE_SEEN_MM`; the camera reads a cup's lower part about right, unlike its rim) must be `MIN_WIDTH`..this (open tips 100 mm) from `SIDE_BAND_MM` below to above the grasp point (the hooks are ~16 mm thick) | diff --git a/manipulation/skills.py b/manipulation/skills.py index 6898385..6f91394 100644 --- a/manipulation/skills.py +++ b/manipulation/skills.py @@ -59,7 +59,9 @@ PATH_SAG_MM = 20.0 # a joint move may take the gri TIP_MM = 60.0 # the hand's lowest part this far below the grasp point (estimate, kept # as a margin: the fingers lie level; the taught tips grasp had the # grasp point 113 mm above the table, owner's tape: finger plane 135) -BELOW_RIM_MM = 40.0 # grasp this far below the object's top +BELOW_RIM_MM = 32.0 # grasp this far below the object's top: a cup narrower lower down slipped + # out at 40, held at 25 with the fingers' top a little over the rim + # (they are 13 mm thick; owner, 2026-10-29) ABOVE_MM = 100.0 # approach / retreat height over the grasp pose LIFT_MM = 30.0 # first lift after closing, then check the grip again MAX_TILT_DEG = 15.0 # deg; a held cup's axis may lean this far from vertical on a joint diff --git a/robot/gripper.py b/robot/gripper.py index 599b8cb..49ace13 100644 --- a/robot/gripper.py +++ b/robot/gripper.py @@ -23,7 +23,8 @@ TOOL = 1 # set_digital_output type: 0 cabinet, 1 tool (TIO), CLOSE_DO, OPEN_DO = 0, 1 # DO_1, DO_2 (0-based) CLOSED_AI = 400 # AI_1 above this = closed on something (open reads 130-165; an 82 mm metal cup # held in the cup fingers reads ~2200-2300, 2026-10-13) -EMPTY_AI = 3900 # closed above this = nothing between the fingers (empty reads 4100-4200, noise +-50) +EMPTY_AI = 4000 # closed above this = nothing between the fingers (these fingers empty: 4084-4158; an 84 mm + # rim cup held ~4 cm down read 3902, 2026-10-29) AI_OPEN, AI_SHUT = 140.0, 4160.0 # AI_1 fully open / closed on nothing (2026-10-19) # inner gap (mm) between the fingers, (open, closed), measured by the owner (docs/gripper/README.md; the neck and the # straight part "shank" not measured again, the earlier ones kept); the gap is taken as linear in AI_1 diff --git a/tests/test_reach.py b/tests/test_reach.py index 41706f6..f5d6e16 100644 --- a/tests/test_reach.py +++ b/tests/test_reach.py @@ -49,8 +49,8 @@ cup = lambda x, y, top=-260.0: {"name": "cup", "colour": "grey", "x": float(x), reach = lambda o: skills.reachable_pick(o, accept=fetch._carry_ok) trusted = lambda o: skills.reachable_pick(o, accept=fetch._carry_ok, max_yaw=skills.TRUSTED_YAW_DEG) # fetch's first try -plan = reach(cup(-96, 598)) # picked live 2026-10-2x 15:39 (J5 +20, no turn): now -assert plan and round(skills.yaw_of(plan[0][1][1])) == -15, plan # no IK at the grasp unturned there; -15 is trusted +plan = reach(cup(-96, 598)) # picked live 2026-10-2x 15:39 (J5 +20, no turn): planned +assert plan and round(skills.yaw_of(plan[0][1][1])) == 0, plan # unturned, J5 +22 for xy in ((-171, 697), (-395, 629), (-480, 652)): # refused live from where it stood: still out of reach assert reach(cup(*xy)) is None, xy # of the arm alone at waist 0 (base moved then) diff --git a/tests/test_skills.py b/tests/test_skills.py index c5599a2..8491794 100644 --- a/tests/test_skills.py +++ b/tests/test_skills.py @@ -10,7 +10,7 @@ head_cam.head_centre = lambda: np.array([-92.97, -19.87, 356.12]) # the head's cup = {"name": "cup", "colour": "white", "x": -126.5, "y": 613.0, "top_mm": -261.0, "width_mm": 72.0} R = calib.rpy_matrix(*skills.GRASP_RPY) -g = np.array([cup["x"], cup["y"], cup["top_mm"] - 40]) +g = np.array([cup["x"], cup["y"], cup["top_mm"] - skills.BELOW_RIM_MM]) (n1, above), (n2, grasp), (n3, lift) = skills.plan_pick(cup) assert np.allclose(grasp[:3], g - R @ skills.GRASP_OFFSET) and grasp[3:] == list(skills.GRASP_RPY) diff --git a/vision/objects.py b/vision/objects.py index d2b1bb1..db8c4c4 100644 --- a/vision/objects.py +++ b/vision/objects.py @@ -33,8 +33,9 @@ EDGE_PCT = (1, 99) # percentiles taken as the object's edges (robust to MIN_SATURATION = 50 # HSV S below this is white / grey / black DARK_V = 60 # HSV V below this has no hue the camera can tell (black trousers: V ~48, S ~95, read # "blue"; blue jeans V ~90, 2026-10-22) -ROUND_FIX_MM = (13.9, -3.1) # mm (x, y), arm frame, added to a round thing's centre: the camera read cup centres this - # far off, mean of three spots 7-11 cm apart (hover readings, 2026-10-27; +-4 mm between them) +ROUND_FIX_MM = (19.0, -4.0) # mm (x, y), arm frame, added to a round thing's centre: the camera read cup centres this + # far off; fitted with the grasp point to 8 free-drive top grasps at 5 spots (2026-10-29, + # data/grasp_top_teach.json, centres seen without this fix; every one within 5 mm) EDGE_PX = 4 # a box this close to the bottom of the frame is cut off: height and centre z unknown STALE_S = 1.5 # s; an older detection file means the camera service is not live SURE_SCORE = 0.35 # a box scoring less (person.WEAK_SCORE) is kept only when depth measures this size there: