From 2cedec3e1bc5b2b28d6401fd63a62990552927be Mon Sep 17 00:00:00 2001 From: Cutshion Date: Thu, 29 Oct 2026 11:13:09 +0900 Subject: [PATCH] Update gripper geometry for the new fingers and log base notifications Co-Authored-By: Claude Opus 5.5 --- docs/TUNING.md | 4 ++-- manipulation/skills.py | 4 ++-- robot/agv.py | 9 ++++++++- robot/drive_log.py | 3 +++ robot/gripper.py | 6 +++--- tests/test_gripper.py | 8 ++++---- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/TUNING.md b/docs/TUNING.md index bc67247..1891c3f 100644 --- a/docs/TUNING.md +++ b/docs/TUNING.md @@ -94,8 +94,8 @@ Every value here is a constant at the top of its file, with a comment on what it | `tasks/fetch.py` | `PICK_ZONE_CENTRE` | (−100, 580) mm | Where a base move brings an object (arm base frame) | | `tasks/fetch.py` | `LOST_BACK_M`, `LOST_TURN_DEG` | 0.15 m, 20° | An object lost after a base move: back off, turn each way, look again | | `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` | `MIN_WIDTH`, `MAX_WIDTH` | 72, 92 mm | Object widths the gripper takes (belly open 96, closed 70; tips open 88 / close to 59; [10_GRIPPER.md](10_GRIPPER.md)). `MIN_WIDTH` 61 enables the finger-tip grasp (61–72 mm) | -| `manipulation/skills.py` | `BELLY_MIN_MM` | 72 mm | Thinner objects are held between the finger tips (the belly closes only to 70 mm) | +| `manipulation/skills.py` | `MIN_WIDTH`, `MAX_WIDTH` | 70, 90 mm | Object widths the gripper takes (belly open 94, closed 68; tips open 89 / close to 63; [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` | `TIPS_OFFSET` (`data/grasp_tips_teach.json` `tips_offset_flange`) | [−0.4, −4.6, 28.2] mm | Finger-tip grasp: the object's axis goes this far from the hooks' belly centre (flange frame, level, turned with the grasp); taught | | `manipulation/skills.py` | `TIP_CLEAR_MM`, `ROUND_BITE_MM` | 10, 10 mm | Round things (apple, orange, ball): the finger tips (`TIP_MM` 60, estimate) stay this far above the table; the grasp point at least this far below the top, else refused. Estimates | | `manipulation/skills.py` | `BELOW_SHOULDER_MM` | 80 mm | Bottles: the grasp point this far below where the body begins; the hand's lowest part (`TIP_MM` below) must stay `TIP_CLEAR_MM` above the table under it (`table_near`, else the bottle's lowest point seen) | diff --git a/manipulation/skills.py b/manipulation/skills.py index f67adbf..6a938f6 100644 --- a/manipulation/skills.py +++ b/manipulation/skills.py @@ -65,14 +65,14 @@ LIFT_MM = 30.0 # first lift after closing, the MAX_TILT_DEG = 15.0 # deg; a held cup's axis may lean this far from vertical on a joint # move with it (place_options; tasks/fetch.py uses the same) PLACE_EXTRA_MM = 3.0 # put down this much higher than it was picked (same table) -MIN_WIDTH, MAX_WIDTH = 72.0, 92.0 # mm: the hooks' belly goes round the cup (open 96, closed 70). The tips +MIN_WIDTH, MAX_WIDTH = 70.0, 90.0 # mm: the hooks' belly goes round the cup (open 94, closed 68). The tips # grasp (61-72) missed twice live on a 66 mm can (2026-10-22): off by the # owner until it is checked; 61 brings it back. Over 84 is the owner's # call (2026-10-19), not tried live yet SEEN_UNDER_MM = 8.0 # the camera's width is this much under the width the fingers meet # (2026-10-19: 73 seen / 85 by tape, 81 seen / 85 by AI_1); the # limits here are the fingers', compared with grip_width() -BELLY_MIN_MM = 72.0 # thinner is held between the finger tips: the belly closes only to 70 +BELLY_MIN_MM = 70.0 # thinner is held between the finger tips: the belly closes only to 68 # (a 70 mm steel cup was missed there and knocked over, 2026-10-19) FRAMES = 8 # camera frames looked at by find() FRAME_GAP_S = 0.2 # s between them diff --git a/robot/agv.py b/robot/agv.py index fbf0551..825c78d 100644 --- a/robot/agv.py +++ b/robot/agv.py @@ -27,6 +27,10 @@ _guard = {"gen": 0, "held": False, "reason": None} # base caps navigation and joy_control by them and forgets them at its restart (its own 0.3 m/s; follow asked 0.5 and # drove 0.30, 2026-10-28). None: the base's own. max_speed = {"linear": None, "angular": None} +# the base's notifications ("type": "notification": docking failed, no path, ...) read on this connection, oldest +# first; robot/drive_log.py logs and clears them. Only the last NOTICES_KEEP are kept. +notices = [] +NOTICES_KEEP = 50 def set_max_speed(linear, angular): @@ -47,7 +51,10 @@ def _ask(command, tag, timeout): except json.JSONDecodeError: break buf = _conn["buf"] = buf.lstrip()[end:] - if msg.get("uuid") == tag: + if msg.get("type") == "notification": + notices.append(msg) + del notices[:-NOTICES_KEEP] + elif msg.get("uuid") == tag: return msg chunk = s.recv(65536) if not chunk: # the base closed the connection: never loop forever diff --git a/robot/drive_log.py b/robot/drive_log.py index 175a497..9da5d08 100644 --- a/robot/drive_log.py +++ b/robot/drive_log.py @@ -112,6 +112,9 @@ def watch(log=print): if down: log("base answering again") down = False + while agv.notices: # why the base failed a move or a docking (code, words) + n = agv.notices.pop(0) + log(f"base: {n.get('code')} {n.get('description')} {n.get('data') or ''}".rstrip()) for line in d.update(st, time.time()): log(line) if "seems stuck" in line and not d.drive.get("why"): diff --git a/robot/gripper.py b/robot/gripper.py index 68865e6..b541bf3 100644 --- a/robot/gripper.py +++ b/robot/gripper.py @@ -25,9 +25,9 @@ CLOSED_AI = 400 # AI_1 above this = closed on something (open reads # 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) 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 with a tape 2026-10-19 (docs/gripper/README.md); the gap -# is taken as linear in AI_1: an 82 mm metal cup read 2189-2310 (2026-10-13), the line gives 81-83 mm at the belly -GAP_MM = {"tips": (88.0, 59.0), "belly": (96.0, 70.0), "neck": (73.0, 47.0), "shank": (66.0, 39.0)} +# inner gap (mm) between the fingers, (open, closed), measured with a tape (docs/gripper/README.md; the straight part +# "shank" not measured on these fingers, the earlier one kept); the gap is taken as linear in AI_1 +GAP_MM = {"tips": (89.0, 63.0), "belly": (94.0, 68.0), "neck": (57.0, 30.0), "shank": (66.0, 39.0)} MOVE_S = 1.5 # s a full stroke takes (measured ~1 s) SENSOR_DI = 0 # DI_1 READ_TRIES, READ_GAP_S = 5, 0.1 # get_data now and then answers without the tool I/O: ask again diff --git a/tests/test_gripper.py b/tests/test_gripper.py index 430f934..20d08b6 100644 --- a/tests/test_gripper.py +++ b/tests/test_gripper.py @@ -2,9 +2,9 @@ import no_robot # noqa: F401 any connection to the robot fails the test from robot import gripper as g -assert g.gap_mm(g.AI_OPEN) == 96.0 and g.gap_mm(g.AI_SHUT) == 70.0 # belly, open / closed (tape) -assert g.gap_mm(50) == 96.0 and g.gap_mm(5000) == 70.0 # readings past the ends are clamped -assert abs(g.gap_mm(2250) - 82.0) < 1.5 # the 82 mm metal cup, 2026-10-13 -assert g.gap_mm(g.AI_SHUT, "tips") == 59.0 and g.gap_mm(g.AI_OPEN, "shank") == 66.0 +assert g.gap_mm(g.AI_OPEN) == 94.0 and g.gap_mm(g.AI_SHUT) == 68.0 # belly, open / closed (tape) +assert g.gap_mm(50) == 94.0 and g.gap_mm(5000) == 68.0 # readings past the ends are clamped +assert abs(g.gap_mm((g.AI_OPEN + g.AI_SHUT) / 2) - 81.0) < 0.01 # linear between +assert g.gap_mm(g.AI_SHUT, "tips") == 63.0 and g.gap_mm(g.AI_OPEN, "shank") == 66.0 assert all(hasattr(g, n) for n in ("MOVE_S", "SENSOR_DI", "READ_TRIES", "READ_GAP_S", "CLOSED_AI", "EMPTY_AI")) print("gripper ok")