Recover the arm from any pose, put down on a remembered table and wave back at people

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 18:22:46 +09:00
co-authored by Claude Opus 5.5
parent b4ab7c71b1
commit eb8975ff6e
25 changed files with 1613 additions and 108 deletions
+37
View File
@@ -2410,6 +2410,41 @@ 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.",
"물건을 들고 있어서 손을 펴면 떨어져요. 내려놓으라고 하시거나 달라고 해 주세요.")
# ---------- 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 ----------
_HELD_IT = (rf"(?:it|that|this|one|them|(?:the|your|this|that) (?:\w+ )?(?:{_OBJ}|cuff|cop|thing)s?)"
r"(?=\s*(?:[,.!;]|$)|\s+(?:now|already|too|so|and|you|let|open|release|please|thanks?|lumi|firmly|tight|safely|"
r"right|here|in my|with my)\b)")
HOLDS_IT_EN = re.compile(
rf"\bi(?:'m| am)\s+(?:now\s+|already\s+|still\s+)?(?:holding|gripping|grabbing|carrying|grasping)(?:\s+on\s*to)?\s+{_HELD_IT}|"
rf"\bi(?:'ve| have)\s+(?:now\s+|already\s+|just\s+)?(?:got\s+)?(?:(?:a (?:good |firm )?)?(?:hold|grip) (?:of|on)\s+)?{_HELD_IT}|"
rf"\bi(?:'ve| have)?\s+(?:already\s+|just\s+)?(?:took|taken|grabbed|caught|got hold of|got a (?:good |firm )?grip on)\s+{_HELD_IT}|"
rf"\bi got (?:the|your) (?:\w+ )?(?:{_OBJ}|cuff|cop)s?\b|\bit(?:'s| is) (?:already |now )?in my hands?\b|"
rf"\bmy hands? (?:is|are) on (?:it|the (?:{_OBJ}|cuff))\b", re.I)
HOLDS_IT_KO = re.compile( # "잡고 있어" / "들고 있어" alone is an order to Lumi (keep holding): a claim needs 내가 / 제가
r"(?:내가|제가|나|저|i)\s+(?:\S+\s+){0,2}?(?:잡고|들고|쥐고|붙잡고|받치고|hold\w*\s*하고|holding\s*하고)\s*있|"
r"(?:내가|제가|나|저|i)\s+(?:\S+\s+){0,2}?(?:잡았|들었|받았|쥐었|가졌)|(?<![가-힣])(?:잡았|쥐었)(?:어|어요|습니다|다)?(?![가-힣])|"
r"(?:내|제) 손에 (?:있|들려|잡혀)", re.I)
HOLDS_IT_WEAK = re.compile(r"^\W*(?:(?:ok(?:ay)?|yes|yeah|alright)\W+)*(?:i\s+)?got (?:it|that)\b", re.I)
# "got it" is "understood" too: a claim only right after Lumi refused to open, or with an open word in the same words
HOLDS_IT_OPEN = re.compile(r"\bopen\b|\brelease\b|\blet (?:it |that |the \w+ )?go\b|\bletting go\b|놔|놓아|놓으|펴|열어|벌려", re.I)
HOLDS_IT_NOT = re.compile(r"\b(?:not|never|nobody|yet|dont|cant|wont|havent|aint|didnt)\b|n't\b|\b(?:if|when|once|after|until|before|will|gonna|going to|"
r"want to|wanna|can i|could i|may i|let me|i'll)\b|\?\s*$|"
r"(?:안|못)\s?(?:잡|들|쥐|받|가지|놔|놓|펴|열)|않|[가-힣]지 ?(?:마|말)|말고|으면|았으면|었으면|때\b|"
r"(?:잡을|들|쥘|받을)(?:게|께)|(?:잡았|들었|받았|쥐었)(?:어|어요|니|나요|습니까)\s*\?", re.I)
def person_holds(t, b=None):
"""The person says they hold what Lumi's hand holds, so it may open (not "I'm not holding it yet", "when I hold
it, let go", "잡았어?"). A bare "got it" counts with an open word or right after Lumi refused to open."""
t = t or ""
if HOLDS_IT_NOT.search(t):
return False
if HOLDS_IT_EN.search(t) or HOLDS_IT_KO.search(t):
return True
last = b.history[-1][1] if b is not None and getattr(b, "history", None) else ""
return bool(HOLDS_IT_WEAK.search(t)) and bool(HOLDS_IT_OPEN.search(t) or "refuse" in last or REFUSE_OPEN[0] in last)
# ---------- while holding: any request to hand the held thing over (the arm goes forward to `give`; whoever is in
# front takes it, the speaker or the person they point at: no person is aimed at or driven to) ----------
_GV = r"(?:give|gib|givv?e?|gi+ve|gve|hand|pass|deliver|bring)"
@@ -2657,6 +2692,8 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
t = CALLING.sub("", wording.ko_plain(_norm(text, markers)).strip()) # "루미야, 이리 줘", "혹시 저 줘요", "um, put it down"
if holding and re.search(r"\bi mean\b|\S\W*\bsorry\b", t):
return None # "place it— give it, I mean": a correction, the LLM reads it
if holding and person_holds(t, b):
return ("release", None) # "I've got it", "내가 잡고 있어": they hold it, the hand opens
if holding and OPEN_HAND.search(t) and not IN_MY_HAND.search(t) and not re.search(r"\b(?:don'?t|do not|never)\b|지 ?마", t):
return ("refuse", REFUSE_OPEN) # "손을 펴 주십시오", "그리퍼 열어 줘" with a cup: it would fall
if holding and FLOOR.search(t) and re.search(r"\b(?:put|place|set|drop|lay|leave|rest)\b|내려 ?놔|내려 ?놓|놔|놓|둬|두세|두십|두어", t) and \
+64 -25
View File
@@ -390,6 +390,7 @@ LOOK_ME_PITCH = 0.0 # deg, head pitch of the first turn to a pers
LOOK_ME_SETTLE_S = 0.6 # s after a head move before its camera is asked who is there
LOOK_ME_MAX_M = 6.0 # m; "look at me" finds callers up to this far (others count only within STAY_MAX)
LOOK_ME_BODY_DEG = 5.0 # deg past the head's yaw limit before the body turns to face the person
LOOK_ME_WAIST_DEG = 15.0 # deg; nobody seen with the waist turned more than this: it goes to the front first
LOOK_ME_TOP_ROW = 0.08 # share of the image height from the top where the person's head should be
LOOK_ME_EDGE_PX = 8 # a box edge this near the frame edge is cut by it
LOOK_ME_UP_STEP = 10.0 # deg up when the person's head is cut by the frame top (how much is cut is unknown)
@@ -415,8 +416,6 @@ REACH_COME_M = 1.5 # m; a person further than this is driven to
COME_CLOSER_SAY = ("Please come a little closer.", "조금 더 가까이 와 주세요.")
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
REACH_HOLD_S = 30.0 # s the hand stays held out after a reach, then the arm folds back to look (estimate)
REACH_DONE = re.compile(r"\b(?:thanks?|thank you|thx|ok(?:ay)?|got it|done|that'?s (?:it|all|enough)|enough|good|great|"
r"nice|cool|alright|all right)\b|고마워|고맙|감사|됐어|됐습니다|됐다|좋아|오케이|그만", re.I)
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"\byou(?:'re| are) not holding (?:anything|something)\b|\byou have nothing in (?:your|ur) hand\b|"
@@ -965,8 +964,9 @@ class Lumi:
def turn_head(self, yaw=None, pitch=None, force=False):
"""Automatic head moves (toward a speaker, a greeting, back to rest) wait while a look is held; force: an
order or a task."""
if not force and self.look_held():
order or a task. None while a task keeps the head on what it picks or puts on (fetch.aiming)."""
from tasks import fetch
if fetch.aiming() or not force and self.look_held():
return
def run():
@@ -1175,9 +1175,8 @@ class Lumi:
else: # stays on whoever the head is on: never the other side
found = min(seen, key=lambda s: abs(s[0] - gaze))
why = "nearest where the head looks" + ("" if voice is None else f", none at the voice {voice:+.0f} deg")
if found is None: # nobody in view: the head camera looks around first
guess = voice if voice is not None else getattr(self, "voice_guess", None) # an unsure voice still
first = gaze if guess is None else max(-head.YAW_LIMIT, min(head.YAW_LIMIT, guess)) # picks the side
def sweep(first): # the head camera looks to `first`'s side, then the other
side = 1.0 if first >= 0 else -1.0
for a in (side * head.YAW_LIMIT, -side * head.YAW_LIMIT):
log(f" look me: nobody seen, looking at {a:+.0f} deg")
@@ -1185,10 +1184,19 @@ class Lumi:
time.sleep(LOOK_ME_SETTLE_S) # new head camera frames from there
seen = self.vision.seen(LOOK_ME_MAX_M)
if seen:
found, why = min(seen, key=lambda s: abs(s[0] - a)), "found looking around"
break
if found is None and voice is None: # an unsure voice still gives the side
voice = getattr(self, "voice_guess", None)
return min(seen, key=lambda s: abs(s[0] - a)), "found looking around"
return None, ""
if found is None: # nobody in view: the head camera looks around first
if voice is None: # an unsure voice still picks the side
voice = getattr(self, "voice_guess", None)
found, why = sweep(gaze if voice is None else voice)
w = waist_turned()
if found is None and abs(w) > LOOK_ME_WAIST_DEG and waist_home("looking for the caller"):
voice = None if voice is None else voice + w # the cameras turn with the waist: a caller on the
gaze = 0.0 # other side of it was in no view; again from the front
log(f" look me: waist from {w:+.0f} deg to the front")
found, why = sweep(0.0 if voice is None else voice)
if found is None and voice is not None and abs(voice) <= head.YAW_LIMIT: # nobody where the head looked: the
voice = (180.0 - abs(voice)) * (1.0 if voice >= 0 else -1.0) # array mixes front and back
if found is None and voice is not None:
@@ -2024,6 +2032,10 @@ class Lumi:
elif kind == "refuse":
if not (what == brain_mod.REFUSE_OPEN and self.release_giving()):
self.fetch_say(*what)
elif kind == "release": # "I've got it", "내가 잡고 있어": they hold it, open
if not self.release_giving():
self.fetch_say("Okay, I'm letting go.", "네, 놓을게요.")
safe(fetch.let_go)
elif not held:
mouth.say(EMPTY_HAND_SAY[self.lang])
else:
@@ -2086,7 +2098,7 @@ class Lumi:
safe(fetch.stop)
self.act("stop", "")
self.fetch_say("Okay, I stopped.", "네, 멈췄어요.")
elif (FETCH_THANKS.search(text) and fetch.state().get("step") == "giving") or \
elif ((FETCH_THANKS.search(text) or brain_mod.person_holds(text)) and fetch.state().get("step") == "giving") or \
(RECEIVE_OK.search(text) and fetch.state().get("step") == "receiving: waiting for okay"):
safe(fetch.release_now) # the person has taken it
elif status == "holding" and not (brain_mod.direct_order(text) and not brain_mod.not_an_order(text)):
@@ -2217,7 +2229,8 @@ class Lumi:
person (the tracked one, else the one the voice came from, else the voice's direction): further than
REACH_COME_M the base comes to them first (come_to); the head turns to them; the hand further from them than
REACH_FRONT_DEG: the waist turns first, until the hand (not the waist's front) points at them (reach_turn, Greeter only too: the base
stays); then fetch.reach (give pose along the graph, a short checked move toward their hand). The arm folds back on "thanks" / "okay" or after REACH_HOLD_S (reach_done).
stays); then fetch.reach (give pose along the graph, a short checked move toward their hand). The arm folds back on the next words that
are no arm order or after REACH_HOLD_S (reach_done).
True when started, None when refused or handed over (said)."""
from tasks import fetch
if held:
@@ -2275,15 +2288,21 @@ class Lumi:
return True, track
def reach_done(self, text=None):
"""The hand is held out (reach_out) and the reach has ended: "thanks" / "okay" / "고마워" / "됐어" (`text`) or
REACH_HOLD_S without one folds the arm back to look. True when it folded."""
if not getattr(self, "reached_at", 0.0) or self.fetch_status() == "running":
"""The empty hand is held out (reach_out): whatever is said next that is no arm order (thanks, a question,
another order; the caller leaves arm orders out) or REACH_HOLD_S without a word folds the arm back to look
first, also while the reach still goes toward their hand (it is stopped) or after it failed (the hand stayed
out in give, 2026-10-30). After a stop word the arm stays where it is. True when it folded."""
from tasks import fetch
if not getattr(self, "reached_at", 0.0):
return False
if text is None and time.time() - self.reached_at < REACH_HOLD_S or text is not None and not REACH_DONE.search(text):
if text is None and time.time() - self.reached_at < REACH_HOLD_S:
return False
if self.fetch_status() != "done": # the reach failed or was stopped: the arm stays as it is
self.reached_at = 0.0
status = self.fetch_status()
if status == "stopped" or status == "running" and safe(fetch.state, default={}).get("step") != "reaching out":
self.reached_at = 0.0 # stopped by a word, or another task has the arm now
return False
if status == "running":
safe(fetch.stop)
log(f" reach over ({'said ' + repr(text) if text else 'timeout'}): the arm back to look")
return bool(self.arm_pose("fold"))
@@ -2771,9 +2790,18 @@ class Lumi:
def who_spoke(self, u, text=None):
"""Use the sound direction: pick the visible person who spoke; meanwhile collect calibration samples. Someone
else near the voice takes the talk over (and the head) only with a call, a stop word or an order in `text`;
other words keep the focus on the person talked with."""
other words keep the focus on the person talked with. Then the head turns to the one it talks with (else the
only one in view), sure voice or not: it answered people a little to the side looking ahead (2026-10-30). A
held look ("look left") and a task's aim keep the head (turn_head)."""
if not self.vision or u is None:
return
if self._who_spoke(u, text): # someone else took over: face() turned to them
return
t = self.current if self.current is not None and self.vision.present(self.current) else self.vision.only_person()
if t is not None and abs(t.angle - HEAD_SIGN * self.det_yaw()) > FOCUS_DEG:
self.turn_head(HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, t.angle)))
def _who_spoke(self, u, text):
self.voice_trusted = False # set again below only from this turn's own sound
self.voice_guess = None # this turn's direction, sure or not
yaw = self.det_yaw()
@@ -2810,6 +2838,7 @@ class Lumi:
if getattr(self, "look_me", None) is not None: # a "look at me" hold was for the one before
self.looked_at, self.look_me = 0.0, None
self.face(t)
return True
def det_yaw(self):
"""Current head yaw (deg), read from the body every 0.3 s (the torso camera does not know it)."""
@@ -3098,7 +3127,9 @@ class Lumi:
if NAME_ONLY.match(text): # just "Lumi?": they want attention, the head turns to them
look = threading.Thread(target=self.look_at_speaker, daemon=True) # while it answers
look.start()
mouth.say(random.choice(NAME_REPLY["en" if self.lang == "en" else "ko"]))
reply = random.choice(NAME_REPLY["en" if self.lang == "en" else "ko"])
log(f" name call: {reply!r}") # every call is answered: the log shows it was
mouth.say(reply)
look.join()
self.keep_listening()
return
@@ -3142,7 +3173,7 @@ class Lumi:
if self.fetch_voice(text): # before the closing words: "thank you" while giving
return
if not (kind == "quick" and data and data[0] == "arm"):
self.reach_done(text) # "okay, thanks" with the hand held out: the arm back to look
self.reach_done(text) # "okay, thanks", any other words: a held-out hand to look
place = consent_place(text, self.brain, self.markers)
if place: # "p3로 갈 수 있어요?" ... "그럼 가 보세요."
self.go_offered(place)
@@ -3303,7 +3334,10 @@ class Lumi:
if follow.running(): # following: talk_turn listens to the followed person only
return False
u = self.mic.next(0.0)
if u is None or not (0.3 <= u.seconds <= WAKE_MAX_S):
if u is None or u.seconds < 0.3:
return False
if u.seconds > WAKE_MAX_S: # logged: a call lost in a long sound shows up in the log
log(f" {u.seconds:.1f} s of sound: too long to be a call, not checked")
return False
during = getattr(u, "during_speech", False) # said while Lumi talks: only a stop word counts
text = ears.transcribe(u.mono)
@@ -3312,6 +3346,8 @@ class Lumi:
self.stop_all()
return True
if during:
if text and WAKE.search(text):
log(f" heard {text!r} while I talked: not taken as a call (it could be my own voice)")
return False
m = WAKE.search(text or "")
if not m and HELLO_ONLY.match(text or ""): # a plain "Hi!" / "Hey" said on its own
@@ -3342,7 +3378,9 @@ class Lumi:
look = threading.Thread(target=self.look_at_speaker, daemon=True) # as "look at me": the cameras, the
look.start() # voice's side, behind; turns while it answers
if not command: # just "Hi Lumi": a short answer, then listen
mouth.say(random.choice(WAKE_REPLY[lang]))
reply = random.choice(WAKE_REPLY[lang])
log(f" wake reply: {reply!r}")
mouth.say(reply)
look.join()
self.voice_until = time.time() + VOICE_SESSION_S
self.last_activity, self.prompts = time.time(), 0
@@ -4015,7 +4053,8 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses
if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1)
return arm_quick(arm_rule, holding)
if hold and not ((brain_mod.held_give(text, markers) or brain_mod.held_place(text, markers)) and
if hold and not ((brain_mod.held_give(text, markers) or brain_mod.held_place(text, markers) or
brain_mod.person_holds(text, b)) and
(holding() if callable(holding) else holding)): # "테이블에 놔 줄래? 영상 찍고 있어": the hand's
rule = brain_mod.intent(text, markers) # weather / search are no motion: "Weather outside?"
return (("end", None) if talk_fate(text) == "end" else ("sing", None) if sing.asked(text, last) else