Improve hand reach and arm return; fix hand state after closing empty
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-7
@@ -189,7 +189,7 @@ where = {"how": "unseen"} # what
|
||||
skills.locate = lambda xy, top, table, width, radius=None: \
|
||||
(where["how"], {"x": xy[0], "y": xy[1], "top_mm": top, "width_mm": width} if where["how"] == "here" else None)
|
||||
body = {"lift": 75.0}
|
||||
fetch.head.status = lambda: [body["lift"], -15.0, 0.0, 0.0]
|
||||
fetch.head.status = lambda: [body["lift"], -15.0, *fetch.HEAD_AHEAD] # the head at rest
|
||||
fetch.head.moveto = lambda pos, **kw: (calls.append(("lift", pos[0])), body.update(lift=pos[0]))
|
||||
skills.arm.cmd = lambda *a, **kw: (_ for _ in ()).throw(AssertionError(f"real arm command in a test: {a}"))
|
||||
skills.ik_chain = lambda wp, j: [[n, p, [0] * 6, None] for n, p in wp]
|
||||
@@ -700,7 +700,7 @@ fetch.CALIB_FILE.write_text(json.dumps({"arm_yaw_in_base_deg": -86.2, "waist_deg
|
||||
waist = {"deg": -15.0}
|
||||
real_status, real_move = fetch.head.status, fetch.head.moveto
|
||||
real_blocked, real_find_any = fetch._sweep_blocked, fetch._find_any
|
||||
fetch.head.status = lambda: [75.0, waist["deg"], 0.0, 0.0]
|
||||
fetch.head.status = lambda: [75.0, waist["deg"], *fetch.HEAD_AHEAD]
|
||||
fetch.head.moveto = lambda pos, **kw: waist.update(deg=pos[1])
|
||||
fetch._sweep_blocked = lambda deg, what: round(fetch._waist_turn() + deg) in blocked # by where it would end
|
||||
waist["deg"], blocked = 45.0, {0}
|
||||
@@ -922,8 +922,8 @@ ahead = lambda mm, side=0.0: [g0[0] + mm, g0[1] + side, g0[2]]
|
||||
scene["person_in_front"] = {"position_mm": ahead(900.0), "hands": {"left": {"position_mm": ahead(600.0, 100.0),
|
||||
"distance_m": 1.1}, "right": {"position_mm": ahead(400.0), "distance_m": 0.9}}}
|
||||
turns = []
|
||||
real_turn = fetch._turn
|
||||
fetch._turn = lambda deg, holding=False, why="": turns.append(deg) or deg < 90
|
||||
real_waist_to = fetch._waist_to
|
||||
fetch._waist_to = lambda deg: turns.append(deg) or deg < 90
|
||||
|
||||
|
||||
def reached(angle=0.0):
|
||||
@@ -947,13 +947,16 @@ assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, move
|
||||
scene["person_in_front"] = None # nobody seen: the hand at give
|
||||
st, moves = reached()
|
||||
assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, moves)
|
||||
st, moves = reached(40.0) # to the side (Patrol): the base turns first, by the
|
||||
st, moves = reached(40.0) # to the side (Patrol): the waist turns first, by the
|
||||
assert turns == [40.0 + fetch._waist_turn()] and poses()[-1] == "give", (turns, poses()) # waist's offset too
|
||||
turns.clear()
|
||||
said.clear()
|
||||
st, moves = reached(120.0) # the turn refused (charger, sweep): the arm stays
|
||||
st, moves = reached(120.0) # the waist turn refused (sweep): the arm stays
|
||||
assert st["status"] == "failed" and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, said)
|
||||
fetch._turn = real_turn
|
||||
turns.clear()
|
||||
st, moves = reached(160.0) # past the waist's limit (-15 + 160 > 140): stand in front
|
||||
assert st["status"] == "failed" and not turns and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, turns)
|
||||
fetch._waist_to = real_waist_to
|
||||
fetch._line_rows, fetch._scene = real_line_rows, real_scene
|
||||
hand["front"] = False
|
||||
# the cup is in the hand but nobody says okay: the hand never closes (their fingers may be in it)
|
||||
|
||||
+12
-2
@@ -25,7 +25,14 @@ PUT_BACK = ["put it back", "put it back where you found it", "return it to where
|
||||
"put back 해 줘", "제자리에 놔 줘", "제자리에 갖다 놓으시게", "원래 자리에 놓으십시오", "원위치에 놔 줘"]
|
||||
REACH = ["extend your arm toward me", "hold your hand out", "reach out", "reach for my hand", "arm forward please",
|
||||
"팔 뻗어 줘", "손 내밀어 줘", "손 쭉 내밀어 봐", "루미야 arm 뻗어 줘", "나한테 reach 해 볼래?"]
|
||||
FOLD = ["fold your arm", "tuck your arm in", "arm back home", "go back to your look pose", "팔 접어", "팔 원래대로 해 줘"]
|
||||
FOLD = ["fold your arm", "tuck your arm in", "arm back home", "go back to your look pose", "팔 접어", "팔 원래대로 해 줘",
|
||||
"take your hand back", "put your arm down", "arm back", "Lumi, arm back please", "back to look position",
|
||||
"go back to look position", "go back to look pose", "Your look position.", "return to the look position",
|
||||
"pull your hand back", "bring your arm back", "put your hand down", "lower your arm", "can you put your arm down?",
|
||||
"손 내려", "손 내려 줘", "손 좀 내려 주세요", "손 거둬", "팔 거둬", "팔 내려 주실래요?", "팔 원위치", "루미야 팔 접어 줘",
|
||||
"okay, 팔 내려", "take your arm back 해 줘"]
|
||||
NOT_FOLD = ["don't take your hand back", "팔 내리지 마", "why did you put your arm down?", "hand back", "give it back",
|
||||
"give me your hand", "손 내밀어"]
|
||||
NOT_GIVE = ["don't give it to me yet", "give it to me after the talk", "when my mom comes, give it to her", "give me a break",
|
||||
"give it a try", "give up", "she gave me that cup this morning", "I gave it to the guy at the booth",
|
||||
"can you give me directions to the subway?", "who will you give that to?", "give it to me, cancel",
|
||||
@@ -51,6 +58,9 @@ def main():
|
||||
for words, want in [(w, "reach") for w in REACH] + [(w, "fold") for w in FOLD]:
|
||||
if brain.intent(words, MARKERS) != ("arm", want):
|
||||
bad.append((words, want, brain.intent(words, MARKERS)))
|
||||
for words in NOT_FOLD:
|
||||
if brain.intent(words, MARKERS) == ("arm", "fold"):
|
||||
bad.append((words, "not fold", brain.intent(words, MARKERS)))
|
||||
for words in NOT_GIVE:
|
||||
if brain.held_give(words, MARKERS) or brain.held_place(words, MARKERS):
|
||||
bad.append((words, "no hand", brain.hand_request(words, True, None, MARKERS)))
|
||||
@@ -65,7 +75,7 @@ def main():
|
||||
bad.append((words, "look center", brain.intent(words, MARKERS)))
|
||||
assert not bad, "\n".join(f"{t!r}: want {w}, got {g}" for t, w, g in bad)
|
||||
n = len(CALLS) * len(TAILS) * len(GIVE_EN + GIVE_KO) + len(CALLS) * (len(PUT_DOWN) + len(PUT_BACK)) + \
|
||||
len(REACH) + len(FOLD) + len(NOT_GIVE) + 6
|
||||
len(REACH) + len(FOLD) + len(NOT_FOLD) + len(NOT_GIVE) + 6
|
||||
print(f"held hand ok ({n} cases)")
|
||||
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ assert brain.head_goal("right 200", 0, 0) == (-180.0, 0, "yaw")
|
||||
assert brain.head_goal("up 50", 0, 0) == (0, 35.0, "pitch")
|
||||
assert brain.head_goal("left small", 10, 0) == (25.0, 0, None)
|
||||
assert brain.head_goal("down", 20, 10) == (20, -5, None)
|
||||
assert brain.head_goal("center", 30, 20) == (0, brain.head_hw.HEAD_REST_PITCH, None) == (0, -5.0, None) # rest: looking down
|
||||
assert brain.head_goal("left", 40, 0) == (55.0, 0, None) and brain.head_goal("right", -40, 0) == (-55.0, 0, None) # "look left"
|
||||
assert brain.head_goal("up", 0, 20) == (0, 30.0, None) and brain.head_goal("left", -40, 0) == (40, 0, None) # again: further
|
||||
for said, want in {"Look at the left side.": "left", "Look at the right side.": "right", "Lumi, look at the left side.": "left",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""The live sequence of 2026-10-23 15:21-15:23, replayed with fakes: "give me a hand" / handshake words with an empty
|
||||
hand are arm reach (the rules, not the LLM's "I can't shake hands"), and a reach whose body move hangs ends at once on
|
||||
STOP, so the next "give me your hand" starts instead of "I'm busy with another task". No robot.
|
||||
STOP, so the next "give me your hand" starts instead of "I'm busy with another task". And 2026-10-23 17:40-17:43:
|
||||
"close your hand" on nothing is not holding (the camera saw the person's hand by the held-out arm), "there is nothing
|
||||
in your hand" checks the hand again, and "okay, thank you" / a timeout folds the held-out arm. No robot.
|
||||
|
||||
.venv/bin/python tests/test_reach_live.py
|
||||
"""
|
||||
@@ -57,4 +59,42 @@ hung.set() # the body answers again
|
||||
fetch.reach(0.0) # the next "give me your hand": starts, not "busy"
|
||||
fetch._thread.join(2)
|
||||
assert moved == ["give", "hand"] and fetch.state()["status"] == "done", (moved, fetch.state()["status"])
|
||||
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move)")
|
||||
# ---------- closed on nothing is empty, whatever the camera sees ----------
|
||||
grip = {"ai": [4153.0, 489.0], "holding": False} # the live close of 17:40:39
|
||||
fetch.gripper.state = lambda: dict(grip)
|
||||
fetch.skills.hand_sees = lambda: "object" # the person's hand by the held-out fingers
|
||||
assert fetch._in_hand() is False
|
||||
fetch._set(status="done", holding=True) # the stale "holding" of 17:41
|
||||
assert fetch.check_hand() is False and not fetch.state()["holding"]
|
||||
grip.update(ai=[3500.0, 489.0], holding=True) # closed on a cup: held
|
||||
fetch.skills.hand_sees = lambda: "unknown"
|
||||
assert fetch._in_hand() is True
|
||||
|
||||
# ---------- the person says the hand is empty; "okay, thank you" / a timeout folds a held-out arm ----------
|
||||
from assistant import lumi
|
||||
for t in ["There is nothing in your hand.", "your hand is empty", "you're not holding anything", "손에 아무것도 없어",
|
||||
"손에 아무것도 없잖아요", "손 비었어"]:
|
||||
assert lumi.HAND_EMPTY_SAID.search(t), t
|
||||
for t in ["is there anything in your hand?", "what's in your hand", "give me your hand"]:
|
||||
assert not lumi.HAND_EMPTY_SAID.search(t), t
|
||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||
folds, status = [], {"now": "done"}
|
||||
L.fetch_status = lambda: status["now"]
|
||||
L.arm_pose = lambda target: folds.append(target) or True
|
||||
for text, want in [("Okay, thank you.", True), ("okay thanks", True), ("고마워", True), ("됐어", True),
|
||||
("what's the weather?", False), (None, False)]:
|
||||
folds.clear()
|
||||
L.reached_at = time.time()
|
||||
assert L.reach_done(text) == want and folds == (["fold"] if want else []), (text, folds)
|
||||
L.reached_at = time.time() - lumi.REACH_HOLD_S - 1 # nobody said anything: the timeout folds
|
||||
folds.clear()
|
||||
assert L.reach_done() and folds == ["fold"]
|
||||
status["now"] = "running" # still reaching: not yet
|
||||
L.reached_at, folds[:] = time.time() - lumi.REACH_HOLD_S - 1, []
|
||||
assert not L.reach_done("thanks") and not folds
|
||||
status["now"] = "failed" # the reach failed: the arm stays, no later fold
|
||||
assert not L.reach_done("thanks") and not folds and not L.reached_at
|
||||
L.reached_at = 0.0
|
||||
status["now"] = "done"
|
||||
assert not L.reach_done("thanks") and not folds # no reach out: "thanks" moves nothing
|
||||
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move, held state, auto fold)")
|
||||
|
||||
@@ -27,7 +27,7 @@ lumi.arm.cmd = lambda name, **a: dict(arm_state) if name == "get_robot_state" el
|
||||
|
||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||
L.lang, L.markers, L.current, L.patrol, L.vision, L.voice_angle = "en", M, None, None, None, 0.0
|
||||
L.turn_head = lambda *a: moved.append("head")
|
||||
L.turn_head = lambda *a, **k: moved.append("head")
|
||||
L.brain = types.SimpleNamespace(history=[])
|
||||
L.keep_listening = lambda: None
|
||||
L.mission_running = lambda: False
|
||||
@@ -190,7 +190,7 @@ for patrol, angle, want in ((False, 35.0, None), (True, 35.0, [35.0]), (False, -
|
||||
reached.clear(), said.clear(), moved.clear()
|
||||
got = L.reach_out(False)
|
||||
if want is None: # nothing moves, not even the head
|
||||
assert got is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]] and not moved, (angle, said)
|
||||
assert got is None and not reached and said == [lumi.GREETER_FRONT_SAY[0]] and not moved, (angle, said)
|
||||
else:
|
||||
assert got and reached == want and moved == ["head"], (patrol, angle, reached, moved)
|
||||
L.vision = None # nobody seen, the voice's direction not trusted: ask
|
||||
@@ -200,8 +200,14 @@ L.voice_trusted, L.voice_angle, L.modes.patrol = True, -50.0, True # heard fro
|
||||
assert L.reach_out(False) and reached == [-50.0]
|
||||
moved.clear(), reached.clear(), said.clear()
|
||||
L.fetch_status = lambda: "holding"
|
||||
real_check, fetch.check_hand = fetch.check_hand, lambda: True # the hand checked: something is in it
|
||||
assert lumi.Lumi.arm_pose(L, "reach") is None and moved == ["give"] and not reached # holding: hand it over
|
||||
assert lumi.Lumi.arm_pose(L, "open") is None and said == [lumi.brain_mod.REFUSE_OPEN[0]] # never dropped
|
||||
fetch.check_hand = lambda: False # a stale "holding", the hand empty: it opens
|
||||
real_open, lumi.gripper.open_ = lumi.gripper.open_, lambda: moved.append("open") or {}
|
||||
said.clear(), moved.clear()
|
||||
assert lumi.Lumi.arm_pose(L, "open") and moved == ["open"] and not said, (moved, said)
|
||||
lumi.gripper.open_, fetch.check_hand = real_open, real_check
|
||||
L.fetch_status = lambda: None
|
||||
fetch.reach = real_reach
|
||||
print(f"switches ok: {len(BASE)} base phrases refused with Greeter only, {len(IN_PLACE)} in place done; "
|
||||
|
||||
@@ -177,6 +177,7 @@ for th in threading.enumerate(): # a wave sta
|
||||
th.join(10)
|
||||
assert track.greeted and said == [lumi.GREETING] and calls == [], calls
|
||||
fetch.STATE_FILE.write_text('{"status": "idle", "holding": true}')
|
||||
hand["holding"] = True # the hand checked again: really held
|
||||
said.clear()
|
||||
assert L.wave(("Okay!", "네!")) is False and said == [wave.HOLDING[0]]
|
||||
L.lang = "ko"
|
||||
@@ -184,6 +185,11 @@ said.clear()
|
||||
assert L.wave() is False and said == [wave.HOLDING[1]]
|
||||
said.clear()
|
||||
assert L.wave(quiet=True) is False and said == [] # a goodbye wave refused: no words about it
|
||||
hand["holding"] = False # a stale "holding", the hand empty (2026-10-23
|
||||
real_wave, wave.wave = wave.wave, lambda on_start=None: None # 17:43): checked again, not refused for holding
|
||||
said.clear()
|
||||
assert L.wave() is True and said == [] and not fetch.state()["holding"], said
|
||||
wave.wave = real_wave
|
||||
fetch.STATE_FILE.unlink()
|
||||
|
||||
# ---------- "bye bye" to the person in view: a (quiet) wave beside the goodbye; else only the goodbye ----------
|
||||
|
||||
Reference in New Issue
Block a user