Tell a narrow cup in the hand from a miss and face the person when reaching out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 20:55:06 +09:00
co-authored by Claude Opus 5.5
parent f19f54ce58
commit 19ba5fe58f
7 changed files with 153 additions and 16 deletions
+30 -3
View File
@@ -27,6 +27,7 @@ fetch.motion.poses = lambda: {"look": [0] * 6, "carry": [1] * 6, "give": [2] * 6
fetch._at_pose = lambda name: arm["pose"] == name
fetch.arm_route.goto = lambda target, holding=False, **kw: moves.append((target, holding)) or arm.update(pose=target)
fetch._scene = lambda fn, *a: None # the owner's hand was gone: no name for it
real_put_down = fetch._put_down
fetch._put_down = lambda say, on=None: put.append(on)
fetch._lift_to = fetch.head_ahead = lambda *a, **k: None
L = lumi.Lumi.__new__(lumi.Lumi)
@@ -41,6 +42,7 @@ def reset(sees, pose="give"):
grip.clear(), grip.update(OPEN)
eye["sees"], arm["pose"] = sees, pose
moves.clear(), put.clear()
L.hand_looked = (0.0, None) # no earlier look at the hand counts
def routed(text):
@@ -56,7 +58,7 @@ arm["pose"] = "look"
assert fetch.check_hand() and fetch.state()["holding"]
kind, data = routed("Put the cup on the table.") # an order that needs the hand: looked at from carry
assert kind == "hand" and data[0][0] == "place" and data[1] is True, (kind, data)
assert moves == [("carry", True)], moves # slowly, as with a cup in the hand
assert moves == [("carry", True), ("look", True)], moves # slowly, as with a cup in the hand, then back to look
fetch.place()
fetch._thread.join(2)
assert put == [{"name": "dining table", "colour": None}] or put == [None], put # it went on to put it down
@@ -73,7 +75,7 @@ assert not fetch.look_at_hand() and not fetch.state()["holding"]
reset("empty")
assert L.arm_pose("close") and not fetch.state()["holding"]
assert not fetch.check_hand() and not moves
assert routed("Put the cup on the table.")[0] != "hand" and moves == [("carry", True)] # looked at, then empty
assert routed("Put the cup on the table.")[0] != "hand" and moves == [("carry", True), ("look", False)] # looked at
try:
fetch.place()
raise AssertionError("put down with an empty hand")
@@ -85,7 +87,7 @@ assert not L.held_now(look=True)
reset("object", pose="look")
grip.update(SHUT)
assert not fetch.check_hand() and not moves # from look nothing is seen there: shut = empty
assert L.held_now(look=True) and moves == [("carry", True)] and fetch.state()["holding"]
assert L.held_now(look=True) and moves == [("carry", True), ("look", True)] and fetch.state()["holding"]
arm["pose"] = "look" # still held away from carry (the next words' check)
assert fetch.check_hand() and fetch.state()["holding"]
@@ -101,3 +103,28 @@ reset("empty")
grip.update(ai=[3500.0, 489.0], closed=True, holding=True)
assert fetch.check_hand() and not moves
print("hand check ok (narrow cup closed on, looked at from carry, closed on nothing, the 2026-10-23 case)")
# ---------- the fingers stayed shut at a put-down while AI_1 read open: the cup came back up (2026-10-30) ----------
class _Placing(Exception):
pass
fetch.skills._held.clear()
fetch.skills.released.clear()
fetch.skills.released.update(top_mm=-185.0, x=50.0, y=626.0, at=time.time())
real_step = fetch._step
fetch._step = lambda *a, **k: (_ for _ in ()).throw(_Placing()) # the put-down's first step: far enough
try:
real_put_down()
except _Placing:
pass
assert fetch.skills._held.get("top_mm") == -185.0, fetch.skills._held # put down the same way again
fetch.skills._held.clear()
fetch.skills.released["at"] = time.time() - fetch.RELEASED_KEEP_S - 1 # long ago: not known any more
try:
real_put_down()
raise AssertionError("put down with nothing known")
except fetch.FetchError:
pass
fetch._step = real_step
print("hand check: a cup back in the hand after a put-down is put down again")
+36
View File
@@ -429,6 +429,42 @@ assert np.allclose(np.subtract(p["grasp"][:2], lines_[2][1][:2]), d * back)
skills._held.clear()
print("skills side grasp ok")
# ---------- a narrow cup lets the fingers shut fully: AI_1 reads as on nothing (live 2026-10-30: a 76 mm seen cup held
# at 4084, called a miss); the camera decides after the lift: gone from the table = held, still there = missed --------
narrow = {**cup, "width_mm": 76.0}
real_look = skills.look
for ai, seen, held in ((4084.0, [], True), # gone from its place
(4084.0, [dict(narrow, top_mm=narrow["top_mm"] + skills.LIFT_MM)], True), # seen in the hand
(4150.0, [dict(narrow, x=narrow["x"] + 10, top_mm=narrow["top_mm"] + 4)], False)): # stands
skills.gripper.close = lambda a=ai: {"ai": [a], "holding": False, "object_in_front": False}
skills.gripper.state = lambda a=ai: {"ai": [a], "holding": False}
skills.look = lambda frames=None, ignore=None, s=seen: s
lines_.clear(), opened.clear(), skills._held.clear()
try:
skills._do_pick(narrow, skills.plan_pick(narrow), READY)
assert held and skills._held["narrow"] and not opened, (ai, skills._held)
assert [n for n, _ in lines_] == ["grasp", "lift"], lines_ # on to carry from the lift
except skills.SkillError as e:
assert not held and e.args[0] == "I missed it." and opened and not skills._held, (ai, e.args)
skills.look = lambda frames=None, ignore=None: (_ for _ in ()).throw(skills.SkillError("My camera isn't working right now."))
skills._do_pick(narrow, skills.plan_pick(narrow), READY) # can't tell: not called a miss
assert skills._held["narrow"]
skills.look = lambda frames=None, ignore=None: (_ for _ in ()).throw(AssertionError("looked"))
skills.gripper.close = lambda: {"ai": [4150.0], "holding": False, "object_in_front": False}
try: # too wide to shut on: a miss at once
skills._do_pick({**cup, "width_mm": 84.0}, skills.plan_pick({**cup, "width_mm": 84.0}), READY)
raise AssertionError("a wide miss went on")
except skills.SkillError as e:
assert e.args[0] == "I missed it.", e.args
try: # a paper cup squeezed flat: empty
skills._do_pick({**cup, "width_mm": 63.0}, skills.plan_pick({**cup, "width_mm": 63.0}), READY)
raise AssertionError("a squeezed paper cup held")
except skills.SkillError as e:
assert e.args[0] == "I missed it.", e.args
skills.look = real_look
skills._held.clear()
print("skills narrow shut ok")
# ---------- a pick stopped on its way in (the open hand beside / around the cup): the next pick backs out the way it
# came first, never a diagonal move from there; a stop once the fingers hold it leaves it ready to put down ----------
def stop_at(where, at): # STOP while moving to waypoint `where`: the hand ends at `at`