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:
+3
-2
@@ -2407,8 +2407,9 @@ GIVE_LOOSE = re.compile( # with something in the hand, the whole sentence asks
|
|||||||
IN_MY_HAND = re.compile(r"\b(?:in|into|on) my (?:hands?|palm)\b|(?:제|내|나의|저의) 손(?:에|위에|바닥에|으로)", re.I)
|
IN_MY_HAND = re.compile(r"\b(?:in|into|on) my (?:hands?|palm)\b|(?:제|내|나의|저의) 손(?:에|위에|바닥에|으로)", re.I)
|
||||||
REFUSE_PICK = ("I'm holding something already. Tell me where to put it first.",
|
REFUSE_PICK = ("I'm holding something already. Tell me where to put it first.",
|
||||||
"이미 뭔가 들고 있어요. 먼저 어디에 둘지 말씀해 주세요.")
|
"이미 뭔가 들고 있어요. 먼저 어디에 둘지 말씀해 주세요.")
|
||||||
REFUSE_OPEN = ("I won't open my hand while I'm holding something: it would fall. Say put it down or hand it over.",
|
REFUSE_OPEN = ("I won't open my hand while I'm holding something: it would fall. Say put it down or hand it over, "
|
||||||
"물건을 들고 있어서 손을 펴면 떨어져요. 내려놓으라고 하시거나 달라고 해 주세요.")
|
"or hold it and say let go.",
|
||||||
|
"물건을 들고 있어서 손을 펴면 떨어져요. 내려놓으라고 하시거나 달라고 하시거나, 잡으시고 놓으라고 해 주세요.")
|
||||||
|
|
||||||
# ---------- while holding: the person says they hold it themselves, so the hand may open ("I've got it", "I am holding
|
# ---------- while holding: the person says they hold it themselves, so the hand may open ("I've got it", "I am holding
|
||||||
# the cuff, so let's open", "내가 잡고 있어", "제가 들고 있어요, 놓아"); whisper's cuff / cop for cup ----------
|
# the cuff, so let's open", "내가 잡고 있어", "제가 들고 있어요, 놓아"); whisper's cuff / cop for cup ----------
|
||||||
|
|||||||
+13
-2
@@ -417,6 +417,8 @@ REACH_COME_M = 1.5 # m; a person further than this is driven to
|
|||||||
# never held out from afar (owner, 2026-10-28)
|
# never held out from afar (owner, 2026-10-28)
|
||||||
COME_CLOSER_SAY = ("Please come a little closer.", "조금 더 가까이 와 주세요.")
|
COME_CLOSER_SAY = ("Please come a little closer.", "조금 더 가까이 와 주세요.")
|
||||||
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
|
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
|
||||||
|
HAND_LOOK_KEEP_S = 10.0 # s a look at the hand (fetch.look_at_hand) stands for: the arm goes to carry and
|
||||||
|
# back once per order, not once per question about the hand
|
||||||
REACH_HOLD_S = 30.0 # s the hand stays held out after a reach, then the arm folds back to look (estimate)
|
REACH_HOLD_S = 30.0 # s the hand stays held out after a reach, then the arm folds back to look (estimate)
|
||||||
HAND_EMPTY_SAID = re.compile( # the person says Lumi's hand is empty: checked again (fetch.check_hand), not just agreed
|
HAND_EMPTY_SAID = re.compile( # the person says Lumi's hand is empty: checked again (fetch.check_hand), not just agreed
|
||||||
r"\b(?:nothing|not anything) (?:is )?in (?:your|ur) hand\b|\b(?:your|ur) hand(?:'s| is) empty\b|"
|
r"\b(?:nothing|not anything) (?:is )?in (?:your|ur) hand\b|\b(?:your|ur) hand(?:'s| is) empty\b|"
|
||||||
@@ -2268,7 +2270,10 @@ class Lumi:
|
|||||||
self.fetch_say(*STAND_IN_FRONT_SAY)
|
self.fetch_say(*STAND_IN_FRONT_SAY)
|
||||||
return None
|
return None
|
||||||
if not turn: # a waist turn takes the head along onto them (fetch._waist_to look): no head move here,
|
if not turn: # a waist turn takes the head along onto them (fetch._waist_to look): no head move here,
|
||||||
self.turn_head(HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)), force=True) # it raced it
|
yaw = HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)) # it raced it
|
||||||
|
log(f" reach: the head on them ({yaw:+.0f} deg) while the arm goes out")
|
||||||
|
safe(fetch._aim_at, None) # an earlier task's target no longer holds the head (it looked
|
||||||
|
self.turn_head(yaw, force=True) # away until the arm was out, 2026-10-30)
|
||||||
self.stay()
|
self.stay()
|
||||||
try:
|
try:
|
||||||
fetch.reach(turn, say=self.fetch_say, look=angle)
|
fetch.reach(turn, say=self.fetch_say, look=angle)
|
||||||
@@ -2343,8 +2348,14 @@ class Lumi:
|
|||||||
`look`: for an order that needs the hand or words about what is in it, a fully shut hand is looked at first
|
`look`: for an order that needs the hand or words about what is in it, a fully shut hand is looked at first
|
||||||
(fetch.look_at_hand: the arm to carry, slowly)."""
|
(fetch.look_at_hand: the arm to carry, slowly)."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
|
seen = getattr(self, "hand_looked", (0.0, None))
|
||||||
|
if look and time.time() - seen[0] < HAND_LOOK_KEEP_S and seen[1] is not None:
|
||||||
|
return seen[1] # one look per order: route asks several times
|
||||||
h = safe(fetch.look_at_hand if look else fetch.check_hand)
|
h = safe(fetch.look_at_hand if look else fetch.check_hand)
|
||||||
return self.fetch_status() == "holding" if h is None else bool(h)
|
held = self.fetch_status() == "holding" if h is None else bool(h)
|
||||||
|
if look:
|
||||||
|
self.hand_looked = (time.time(), held)
|
||||||
|
return held
|
||||||
|
|
||||||
# ---------- dashboard commands, trips ----------
|
# ---------- dashboard commands, trips ----------
|
||||||
def poll_commands(self):
|
def poll_commands(self):
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ Every value here is a constant at the top of its file, with a comment on what it
|
|||||||
| `vision/objects.py` | `SLICE_MM`, `BODY_PCT`, `BODY_FRACTION` | 10 mm, 75, 0.9 | A bottle's width profile (`objects.body`): slices this thick; its body as wide as this percentile of the slices; the body begins at the first slice from the top this much as wide |
|
| `vision/objects.py` | `SLICE_MM`, `BODY_PCT`, `BODY_FRACTION` | 10 mm, 75, 0.9 | A bottle's width profile (`objects.body`): slices this thick; its body as wide as this percentile of the slices; the body begins at the first slice from the top this much as wide |
|
||||||
| `manipulation/skills.py` | `GRASPS` | cup upright; apple, orange, sports ball round; the rest refused | Which classes are picked and how |
|
| `manipulation/skills.py` | `GRASPS` | cup upright; apple, orange, sports ball round; the rest refused | Which classes are picked and how |
|
||||||
| `tasks/fetch.py` | `PICK_TRIES` | 2 | A missed / slipped pick is tried this often |
|
| `tasks/fetch.py` | `PICK_TRIES` | 2 | A missed / slipped pick is tried this often |
|
||||||
|
| `manipulation/skills.py` | `SHUT_GRIP_MM`, `STILL_MM` | 88 mm, 15 mm | A pick that closes fully on a cup the fingers meet 77 mm (the belly's closed gap) to this wide is decided by the camera after the lift: a thing at its place with its top within `STILL_MM` of the picked top = missed, else held. 88 is partly an estimate |
|
||||||
| `manipulation/skills.py` | `SEEN_UNDER_MM` | 8 mm | Added to the camera's width to get the width the fingers meet (`grip_width`), which the limits above are compared with |
|
| `manipulation/skills.py` | `SEEN_UNDER_MM` | 8 mm | Added to the camera's width to get the width the fingers meet (`grip_width`), which the limits above are compared with |
|
||||||
| `tasks/fetch.py` | `HEAD_READS`, `HEAD_SAME_MM` | 4, 120 mm | Head camera frames read per view; a thing counts when seen at least twice within this distance |
|
| `tasks/fetch.py` | `HEAD_READS`, `HEAD_SAME_MM` | 4, 120 mm | Head camera frames read per view; a thing counts when seen at least twice within this distance |
|
||||||
| `tasks/fetch.py` | `HEAD_SIDE_DEG` | 60° | Head yaw towards the side of a turn on the spot, for the arm-sweep check (`head_hits`) |
|
| `tasks/fetch.py` | `HEAD_SIDE_DEG` | 60° | Head yaw towards the side of a turn on the spot, for the arm-sweep check (`head_hits`) |
|
||||||
|
|||||||
+40
-2
@@ -64,6 +64,14 @@ BELOW_RIM_MM = 32.0 # grasp this far below the obje
|
|||||||
# (they are 13 mm thick; owner, 2026-10-29)
|
# (they are 13 mm thick; owner, 2026-10-29)
|
||||||
ABOVE_MM = 100.0 # approach / retreat height over the grasp pose
|
ABOVE_MM = 100.0 # approach / retreat height over the grasp pose
|
||||||
LIFT_MM = 30.0 # first lift after closing, then check the grip again
|
LIFT_MM = 30.0 # first lift after closing, then check the grip again
|
||||||
|
SHUT_GRIP_MM = 88.0 # a close that ends fully shut (AI_1 over gripper.EMPTY_AI) on a thing
|
||||||
|
# the fingers meet at most this wide may still hold it: an 84 mm cup
|
||||||
|
# (76 seen) was held at 4084, empty closes read 4084-4182 (2026-10-30);
|
||||||
|
# the camera decides after the lift (stands_still), from the belly's
|
||||||
|
# closed gap (gripper.GAP_MM, 77) up. 88: 84 + 4, the
|
||||||
|
# 4 an estimate of the camera's width spread
|
||||||
|
STILL_MM = 15.0 # stands_still(): a top this near the picked one still stands on the
|
||||||
|
# table (half of LIFT_MM: a held one is LIFT_MM higher)
|
||||||
MAX_TILT_DEG = 15.0 # deg; a held cup's axis may lean this far from vertical on a joint
|
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)
|
# 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)
|
PLACE_EXTRA_MM = 3.0 # put down this much higher than it was picked (same table)
|
||||||
@@ -200,6 +208,9 @@ OPEN_AI = gripper.CLOSED_AI # AI_1 below this after opening
|
|||||||
BACK_OUT_NEAR_MM = 30.0 # back_out: the hand this near the stopped pick's way in is still in it
|
BACK_OUT_NEAR_MM = 30.0 # back_out: the hand this near the stopped pick's way in is still in it
|
||||||
|
|
||||||
_held = {} # what pick() holds: {"top_mm", "x", "y"} for place() / put_down()
|
_held = {} # what pick() holds: {"top_mm", "x", "y"} for place() / put_down()
|
||||||
|
released = {} # _held of the last thing let go in a place, with "at" (time): AI_1 read
|
||||||
|
# open once while the fingers stayed shut and the cup came back up
|
||||||
|
# (2026-10-30); fetch._put_down puts it down again with it
|
||||||
_pick_way = {} # the pick's waypoints {name: pose} from the move to above until the
|
_pick_way = {} # the pick's waypoints {name: pose} from the move to above until the
|
||||||
# hand holds or has backed out (back_out after a stop)
|
# hand holds or has backed out (back_out after a stop)
|
||||||
_cancel = threading.Event() # set by cancel(): the running skill makes no further move
|
_cancel = threading.Event() # set by cancel(): the running skill makes no further move
|
||||||
@@ -618,6 +629,19 @@ def locate(xy, top_mm, table_mm, width_mm, radius=LOCATE_MM):
|
|||||||
return "here", {"x": float(c[0]), "y": float(c[1]), "top_mm": float(tall[:, 2].max()), "width_mm": width_mm}
|
return "here", {"x": float(c[0]), "y": float(c[1]), "top_mm": float(tall[:, 2].max()), "width_mm": width_mm}
|
||||||
|
|
||||||
|
|
||||||
|
def stands_still(obj):
|
||||||
|
"""After the lift: does the torso camera still see a thing standing where `obj` was picked (within CLUSTER_MM of
|
||||||
|
its centre, its top within STILL_MM of the picked top)? A camera that is not live says no."""
|
||||||
|
moved(objects.CAMERA) # frames from after the lift only
|
||||||
|
try:
|
||||||
|
seen = look()
|
||||||
|
except SkillError as e:
|
||||||
|
log(f"after the lift: {e}")
|
||||||
|
return False
|
||||||
|
return any(o["top_mm"] is not None and abs(o["top_mm"] - obj["top_mm"]) <= STILL_MM and
|
||||||
|
np.hypot(o["x"] - obj["x"], o["y"] - obj["y"]) < CLUSTER_MM for o in seen)
|
||||||
|
|
||||||
|
|
||||||
def hand_sees():
|
def hand_sees():
|
||||||
"""What the torso depth camera sees where a held object would be (on the cup's axis just below the grasp point,
|
"""What the torso depth camera sees where a held object would be (on the cup's axis just below the grasp point,
|
||||||
from the arm's joints now): "object", "empty", or "unknown" (out of view, no depth, the fingers in the way).
|
from the arm's joints now): "object", "empty", or "unknown" (out of view, no depth, the fingers in the way).
|
||||||
@@ -1101,13 +1125,25 @@ def _do_pick(obj, waypoints, ja):
|
|||||||
log("closing")
|
log("closing")
|
||||||
s = gripper.close()
|
s = gripper.close()
|
||||||
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']} finger sensor {s['object_in_front']}")
|
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']} finger sensor {s['object_in_front']}")
|
||||||
if not s["holding"]:
|
# fully shut on a narrow one: AI_1 reads as on nothing whether it is held or not (SHUT_GRIP_MM); one narrower than
|
||||||
|
# the belly's closed gap (a paper cup squeezed flat) is not held by it
|
||||||
|
shut = not s["holding"] and s["ai"][0] > gripper.EMPTY_AI and \
|
||||||
|
gripper.GAP_MM["belly"][1] <= (grip_width(obj) or MAX_WIDTH) <= SHUT_GRIP_MM
|
||||||
|
if not s["holding"] and not shut:
|
||||||
_give_up("I missed it.", back)
|
_give_up("I missed it.", back)
|
||||||
|
if shut:
|
||||||
|
log("fully shut on a narrow one: the camera decides after the lift")
|
||||||
# held from here on: a stop in the lift leaves it ready to put down
|
# held from here on: a stop in the lift leaves it ready to put down
|
||||||
_held.update(top_mm=obj["top_mm"], x=obj["x"], y=obj["y"], yaw=yaw_of(grasp), table=table,
|
_held.update(top_mm=obj["top_mm"], x=obj["x"], y=obj["y"], yaw=yaw_of(grasp), table=table,
|
||||||
tips=grip_width(obj) < BELLY_MIN_MM, below=obj["top_mm"] - grasp_height(obj), back=back)
|
tips=grip_width(obj) < BELLY_MIN_MM, below=obj["top_mm"] - grasp_height(obj), back=back,
|
||||||
|
narrow=shut) # fetch._in_hand: held while shut
|
||||||
_pick_way.clear()
|
_pick_way.clear()
|
||||||
_line("lift", lift)
|
_line("lift", lift)
|
||||||
|
if shut:
|
||||||
|
if stands_still(obj): # it stands where it was: the hand is empty
|
||||||
|
_give_up("I missed it.", back)
|
||||||
|
log("it is gone from the table: held")
|
||||||
|
return
|
||||||
s = gripper.state()
|
s = gripper.state()
|
||||||
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']}")
|
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']}")
|
||||||
if not s["holding"]:
|
if not s["holding"]:
|
||||||
@@ -1127,6 +1163,8 @@ def _do_place(waypoints):
|
|||||||
log(f"AI_1 {s['ai'][0]:.0f}")
|
log(f"AI_1 {s['ai'][0]:.0f}")
|
||||||
if s["ai"][0] > OPEN_AI:
|
if s["ai"][0] > OPEN_AI:
|
||||||
raise SkillError("My hand did not open.") # stay put: lifting now would drag the object
|
raise SkillError("My hand did not open.") # stay put: lifting now would drag the object
|
||||||
|
released.clear()
|
||||||
|
released.update(_held, at=time.time())
|
||||||
_held.clear()
|
_held.clear()
|
||||||
for name, pose in waypoints[n:]:
|
for name, pose in waypoints[n:]:
|
||||||
_line(name, pose)
|
_line(name, pose)
|
||||||
|
|||||||
+30
-7
@@ -184,6 +184,8 @@ SHORT_LOG_M = 0.03 # m; a straight drive (timed) that odometry says ca
|
|||||||
COAST_S = 0.3 # s; the base coasts a little after a joy_control stop: frames from then on are used
|
COAST_S = 0.3 # s; the base coasts a little after a joy_control stop: frames from then on are used
|
||||||
# (estimate; measure-axis waits 1 s for its pose)
|
# (estimate; measure-axis waits 1 s for its pose)
|
||||||
GIVE_WAIT_S = 30.0 # s; no release by then: keep holding it and go back to carry (never drop it)
|
GIVE_WAIT_S = 30.0 # s; no release by then: keep holding it and go back to carry (never drop it)
|
||||||
|
RELEASED_KEEP_S = 600.0 # s; what a place let go of counts as still known (its height) for this long, when the
|
||||||
|
# hand turns out to hold it again (the fingers stayed shut, skills.released)
|
||||||
# Opening needs a word from the person ("thank you", or Release in the dashboard): AI_1 can't feel a pull. Measured
|
# Opening needs a word from the person ("thank you", or Release in the dashboard): AI_1 can't feel a pull. Measured
|
||||||
# 2026-10-15 with the cup in the closed gripper: its median stayed 2780-2870 during gentle pulls (only its noise
|
# 2026-10-15 with the cup in the closed gripper: its median stayed 2780-2870 during gentle pulls (only its noise
|
||||||
# grew, sd 20 -> 50-75), while the fingers settling after the move changed it by 192.
|
# grew, sd 20 -> 50-75), while the fingers settling after the move changed it by 192.
|
||||||
@@ -581,7 +583,7 @@ def _drive_wait(watch_holding, again, goal):
|
|||||||
if watch_holding and time.time() - last_hold >= HOLD_CHECK_S:
|
if watch_holding and time.time() - last_hold >= HOLD_CHECK_S:
|
||||||
last_hold = time.time()
|
last_hold = time.time()
|
||||||
try:
|
try:
|
||||||
held = gripper.state()["holding"]
|
held = _grip_holds()
|
||||||
except (ConnectionError, OSError, KeyError):
|
except (ConnectionError, OSError, KeyError):
|
||||||
held = True # one missed read: look again next second
|
held = True # one missed read: look again next second
|
||||||
if not held:
|
if not held:
|
||||||
@@ -2374,6 +2376,11 @@ def _put_down(say=None, on=None):
|
|||||||
down, back to look. `on` (brain.place_on): put it on that named thing instead (a table with no colour: as above);
|
down, back to look. `on` (brain.place_on): put it on that named thing instead (a table with no colour: as above);
|
||||||
{"pointed": True}: where the person points (_put_pointed)."""
|
{"pointed": True}: where the person points (_put_pointed)."""
|
||||||
top = skills._held.get("top_mm")
|
top = skills._held.get("top_mm")
|
||||||
|
back = skills.released
|
||||||
|
if top is None and back and time.time() - back.get("at", 0.0) < RELEASED_KEEP_S:
|
||||||
|
log("what I put down last is in my hand again: putting it down the same way")
|
||||||
|
skills._held.update({k: v for k, v in back.items() if k != "at"})
|
||||||
|
top = skills._held.get("top_mm")
|
||||||
if top is None:
|
if top is None:
|
||||||
raise FetchError("I'm not holding anything I picked.")
|
raise FetchError("I'm not holding anything I picked.")
|
||||||
_step("placing")
|
_step("placing")
|
||||||
@@ -2661,17 +2668,31 @@ def _in_hand():
|
|||||||
return seen == "object"
|
return seen == "object"
|
||||||
|
|
||||||
|
|
||||||
|
def _grip_holds():
|
||||||
|
"""gripper.state()'s "holding", or fully shut on a narrow one held all the same (skills._do_pick, close_hand):
|
||||||
|
AI_1 can't tell a drop then."""
|
||||||
|
g = gripper.state()
|
||||||
|
return g["holding"] or bool(skills._held.get("narrow")) and g.get("ai", [0.0])[0] > gripper.EMPTY_AI
|
||||||
|
|
||||||
|
|
||||||
def look_at_hand():
|
def look_at_hand():
|
||||||
"""check_hand before an order that needs something in the hand (put down, give, bring) or when told what is in
|
"""check_hand before an order that needs something in the hand (put down, give, bring) or when told what is in
|
||||||
it: a fully shut hand first goes slowly (holding) along the checked route to CHECK_POSE, so the camera can tell."""
|
it: a fully shut hand first goes slowly (holding) along the checked route to CHECK_POSE, so the camera can tell,
|
||||||
_to_check_pose()
|
and back to look after it, held or not (it stayed in carry, 2026-10-30): the order goes on from look."""
|
||||||
return check_hand()
|
moved = _to_check_pose()
|
||||||
|
held = check_hand()
|
||||||
|
if moved:
|
||||||
|
try:
|
||||||
|
arm_route.goto(arm_route.HOME, holding=held)
|
||||||
|
except (arm_route.RouteError, motion.MotionError, ConnectionError, OSError) as e:
|
||||||
|
log(f"hand: can't go back to look after the check: {e}")
|
||||||
|
return held
|
||||||
|
|
||||||
|
|
||||||
def _to_check_pose():
|
def _to_check_pose():
|
||||||
"""A fully shut hand to CHECK_POSE (look_at_hand), not while a task runs."""
|
"""A fully shut hand to CHECK_POSE (look_at_hand), not while a task runs. True when the arm moved there."""
|
||||||
if _busy() or CHECK_POSE not in motion.poses():
|
if _busy() or CHECK_POSE not in motion.poses():
|
||||||
return
|
return False
|
||||||
try:
|
try:
|
||||||
shut = gripper.state().get("ai", [0.0])[0] > gripper.EMPTY_AI
|
shut = gripper.state().get("ai", [0.0])[0] > gripper.EMPTY_AI
|
||||||
except (ConnectionError, OSError, KeyError):
|
except (ConnectionError, OSError, KeyError):
|
||||||
@@ -2681,8 +2702,10 @@ def _to_check_pose():
|
|||||||
if not _at_pose(CHECK_POSE):
|
if not _at_pose(CHECK_POSE):
|
||||||
log(f"hand: fully shut, the arm to {CHECK_POSE} to look at it")
|
log(f"hand: fully shut, the arm to {CHECK_POSE} to look at it")
|
||||||
arm_route.goto(CHECK_POSE, holding=True)
|
arm_route.goto(CHECK_POSE, holding=True)
|
||||||
|
return True
|
||||||
except (arm_route.RouteError, motion.MotionError, ConnectionError, OSError) as e:
|
except (arm_route.RouteError, motion.MotionError, ConnectionError, OSError) as e:
|
||||||
log(f"hand: can't look at it from {CHECK_POSE}: {e}")
|
log(f"hand: can't look at it from {CHECK_POSE}: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def close_hand():
|
def close_hand():
|
||||||
@@ -3174,7 +3197,7 @@ def _move(direction, m, holding):
|
|||||||
if cut(): # someone stopped me: wait, then the rest of the way, checked again
|
if cut(): # someone stopped me: wait, then the rest of the way, checked again
|
||||||
_go_on()
|
_go_on()
|
||||||
continue
|
continue
|
||||||
if holding and not gripper.state()["holding"]:
|
if holding and not _grip_holds():
|
||||||
skills._held.clear()
|
skills._held.clear()
|
||||||
_set(holding=False)
|
_set(holding=False)
|
||||||
raise FetchError("I dropped it.", "떨어뜨렸어요.")
|
raise FetchError("I dropped it.", "떨어뜨렸어요.")
|
||||||
|
|||||||
@@ -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._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.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
|
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._put_down = lambda say, on=None: put.append(on)
|
||||||
fetch._lift_to = fetch.head_ahead = lambda *a, **k: None
|
fetch._lift_to = fetch.head_ahead = lambda *a, **k: None
|
||||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||||
@@ -41,6 +42,7 @@ def reset(sees, pose="give"):
|
|||||||
grip.clear(), grip.update(OPEN)
|
grip.clear(), grip.update(OPEN)
|
||||||
eye["sees"], arm["pose"] = sees, pose
|
eye["sees"], arm["pose"] = sees, pose
|
||||||
moves.clear(), put.clear()
|
moves.clear(), put.clear()
|
||||||
|
L.hand_looked = (0.0, None) # no earlier look at the hand counts
|
||||||
|
|
||||||
|
|
||||||
def routed(text):
|
def routed(text):
|
||||||
@@ -56,7 +58,7 @@ arm["pose"] = "look"
|
|||||||
assert fetch.check_hand() and fetch.state()["holding"]
|
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
|
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 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.place()
|
||||||
fetch._thread.join(2)
|
fetch._thread.join(2)
|
||||||
assert put == [{"name": "dining table", "colour": None}] or put == [None], put # it went on to put it down
|
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")
|
reset("empty")
|
||||||
assert L.arm_pose("close") and not fetch.state()["holding"]
|
assert L.arm_pose("close") and not fetch.state()["holding"]
|
||||||
assert not fetch.check_hand() and not moves
|
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:
|
try:
|
||||||
fetch.place()
|
fetch.place()
|
||||||
raise AssertionError("put down with an empty hand")
|
raise AssertionError("put down with an empty hand")
|
||||||
@@ -85,7 +87,7 @@ assert not L.held_now(look=True)
|
|||||||
reset("object", pose="look")
|
reset("object", pose="look")
|
||||||
grip.update(SHUT)
|
grip.update(SHUT)
|
||||||
assert not fetch.check_hand() and not moves # from look nothing is seen there: shut = empty
|
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)
|
arm["pose"] = "look" # still held away from carry (the next words' check)
|
||||||
assert fetch.check_hand() and fetch.state()["holding"]
|
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)
|
grip.update(ai=[3500.0, 489.0], closed=True, holding=True)
|
||||||
assert fetch.check_hand() and not moves
|
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)")
|
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")
|
||||||
|
|||||||
@@ -429,6 +429,42 @@ assert np.allclose(np.subtract(p["grasp"][:2], lines_[2][1][:2]), d * back)
|
|||||||
skills._held.clear()
|
skills._held.clear()
|
||||||
print("skills side grasp ok")
|
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
|
# ---------- 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 ----------
|
# 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`
|
def stop_at(where, at): # STOP while moving to waypoint `where`: the hand ends at `at`
|
||||||
|
|||||||
Reference in New Issue
Block a user