Improve command, cup task and talk understanding in English and Korean

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 15:30:06 +09:00
co-authored by Claude Opus 5.5
parent e3a1c123c9
commit e3fcfd30ab
23 changed files with 1380 additions and 167 deletions
+72 -22
View File
@@ -123,8 +123,14 @@ CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE on
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
r"|루미|누미", re.I)
WAKE_UP_EN = r"wake up|wakey wakey|time to wake up"
WAKE_UP_KO = r"(?:일어나|깨어나)(?:요|세요|십시오|라|봐|봐요)?|기상"
WAKE = re.compile(rf"\b(hi|hey|hello|okay|ok|hai|high|{WAKE_UP_EN})?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
rf"(?:[\s,.!]*(?:{WAKE_UP_EN})\b)?"
rf"|(?:(?:{WAKE_UP_KO})[\s,.!~]*)?(?:헤이 ?|하이 ?)?(?:루미|누미)(?:야|아)?(?:[\s,.!~]*(?:{WAKE_UP_KO}))?"
rf"|^\W*(?:(?:hey|ok|okay|come on)\W+)?(?:{WAKE_UP_EN})\W*$|^\W*(?:(?:자|이제|얼른)\s+)?(?:{WAKE_UP_KO})[\s.!~]*$", re.I)
# ^ "Hey Lumi", "Lumi", "wake up (Lumi)", "Lumi, wake up", "루미야", "헤이 루미", "루미야 일어나", "일어나세요";
# a bare "wake up" / "일어나" only as the whole utterance ("I wake up at 7" is no call)
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
@@ -313,7 +319,7 @@ HELLO_ONLY = re.compile(r"^(?=\W*\w)\s*(?:(?:hi|hey|hello|hiya|hai|hallo|helo|hi
r"(?:how are you(?: doing)?(?: today)?[\s,.!?]*)?$|" # "how are you?"
r"^\s*(?:안녕|안녕하세요|안녕하십니까|하이)[\s.!~?]*$", re.I) # "안녕하세요", "하이"
CALL_REST = re.compile(r"^(?:[\W_]|\b(?:hi|hey|hello|hiya|hai|ok|okay|there|how are you(?: doing)?(?: today)?)\b|"
r"안녕(?:하세요|하십니까)?|하이|야|아)*$", re.I) # what is left of a call without the name
r"안녕(?:하세요|하십니까)?|하이|헤이|야|아)*$", re.I) # what is left of a call without the name
CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera)
WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word
BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0)
@@ -3255,35 +3261,53 @@ STOP_UNSAID = re.compile( # a stop that is taken back, for later, said about t
r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I)
STOP_LATER = re.compile( # a stop for later ("내일 그만하시게", "행사가 끝난 후에 멈춰 주세요") or reported ("아까 직원분이
# 그만하라고 지시했습니다"); "내가 멈추라고 했지!" is said now
r"(?:^|\s)(?:나중에|이따가?|있다가|내일|모레|다음에|다음 ?번에)\s|(?:끝난|끝나고|마친|마치고|끝내고) ?(?:후|뒤|다음)?에?\s|"
r"[가-힣]고 ?나서\s|(?<!내가 )(?<!제가 )(?<!내가)(?:그만하|멈추|멈춰 ?달|정지하|서)라고\s*(?:\S+\s+)?"
r"(?:했|하셨|그랬|말했|말씀|지시|하더|하던|한다|하네)")
STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|"
r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|"
r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|"
r"right|already|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I)
r"right|already|lumi|robot|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I)
STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay (after calls and fillers): stop at once
r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|kill it|abort|"
r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|knock it off|whoa,? there|whoa(?:,? whoa)+|kill it|abort|"
r"stop (?:everything|driving|moving|it|that|the robot|right there|right now)|enough (?:music|of that)|"
r"hold it|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|"
r"hold it(?: (?:right )?(?:there|here))?|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|"
r"그만해 ?주세요|그마내|그만둬|멈춰|멈쳐|멈처|멈추라고|멈춰 ?봐|거기까지|고마 ?(?:서라|해라|해|하이소)|서|don'?t go|가지 ?마|그마+안|"
r"얼음|cut it|노래 ?꺼|음악 ?꺼|stop the (?:music|song)|music off|stay|stay (?:here|there|put|right there)|"
r"(?:just )?wait there|stop following(?: me)?|finish follow|(?:여기|거기)(?:서)? ?(?:그대로 ?)?(?:있어|있어요|계세요|stay|서|서세요|"
r"기다려)|그대로 있어|가만히 있어|stay 해|wait 해)\W*){1,3}", re.I)
STOP_POLITE = re.compile( # a stop asked politely, after wording.ko_plain: "멈춰 주시겠어요?" -> "멈춰 줘?", "can you stop for me?"
r"\W*(?:(?:좀|지금|당장|잠깐|잠시|거기서?|이제)\s*)*(?:멈춰|멈춰 서|정지해|그만해|스톱해|스탑해|서)(?: ?줘)?\W*|"
r"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:can|could|would|will) (?:you|u) (?:please |just |kindly )?(?:stop|halt|freeze)"
r"(?: (?:right )?(?:now|here|there|please))?(?: for (?:me|us|a (?:second|sec|moment|bit|minute)))?(?:,? please)?\W*|"
r"\W*(?:would|do) you mind stopping(?: (?:now|here|there))?(?: for (?:me|us|a (?:second|moment)))?(?:,? please)?\W*", re.I)
def stop_order(text, markers):
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare
stop word always stops (also stretched: "stooop", "머엄춰")."""
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:lumi|robot|hey|okay|ok)\W+)*(?:would|do) you mind stopping"
r"(?:,? (?:now|here|there|please|for (?:me|us|a (?:second|moment))))*\W*", text, re.I) \
and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
return False
if STOP_UNSAID.search(text):
return False
if STOP_UNSAID.search(text) or STOP_LATER.search(text):
return False # "이따가 멈춰 주세요": a stop for later
bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~")
if bare and STOP_ONLY.fullmatch(bare):
return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait"
# (watch out / 위험해 / "Lumi, wait" / hold on: on a mission these halt it (mission_talk), never end it)
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or
from assistant import wording
plain = brain_mod.CALLING.sub("", wording.ko_plain(text)).strip()
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or STOP_POLITE.fullmatch(plain) or
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
@@ -3299,14 +3323,16 @@ HAND_STATE_Q = re.compile( # how the hand is now (A1): "is your hand open?", "
r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|"
r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|"
r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|"
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|오픈|클로즈|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
r"쥐어져)\s*(?:있|상태|이야|인가)", re.I)
def status_question(text):
""""What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거
줘" is a request)."""
return bool(HAND_STATE_Q.search(text)) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
hand = HAND_STATE_Q.search(text) and not re.search(r"\b(?:stretch|stick|hold|put|reach|extend|get|move|bring)\b", text, re.I)
return bool(hand) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
# hand: not "may I ask you to stretch your arm out?" (an order)
def says_goodbye(text):
@@ -3338,6 +3364,11 @@ NOT_A_STEP = re.compile(r"^\W*(?:(?:please|and|then|also)\s+)*(?:dance|jump|fly|
r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked
CAN_TOLD = re.compile(r"\b(?:you|u) (?:can|could|are able to|know how to)\b|(?<!줄 )(?<!주실 )(?<!줄)(?<!주실)수 ?(?:도 ?)?있(?:지|죠|잖|겠지|겠죠|을 ?걸)|"
r"줄 ?(?:도 ?)?알(?:지|죠|잖)", re.I) # with a tag: Lumi's ability said back, a question (TAG)
MYEOT_SLIP = re.compile(r"(?<![가-힣])멸(?=\s*(?:센티|센치|미터|밀리|키로|킬로|그램|개|번|도|시|분|초|명|살|층|cm|mm|kg|m\b))", re.I)
def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
"""Which way a command goes, the same for voice (Lumi.answer), the dashboard's Command box (/tasks/parse) and
tests/command_check: (kind, data). Kinds in this order: "stop"; "detour" (data: assistant/detour.read's
@@ -3348,10 +3379,15 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
reading: assistant/intent_bank.py); (None, None): the LLM reads
it. seen: seeing.answer or a stand-in; chain_ok: False on a mission or while a chain runs."""
from assistant import chain, intent_bank
text = MYEOT_SLIP.sub("몇", text or "") # whisper's 멸 for 몇: "멸 센티까지 잡아?" asks, orders nothing
text = re.sub(r"(?<=[가-힣])(?=[a-zA-Z]{2})", " ", text) # "원래 자리에put back": the English word apart
text = re.sub(r"\bcome on back\b", "come back", text, flags=re.I) # not 1 m back
text = re.sub(r"(?<![\d.])360(?= ?돌아)", "360도", text) # "루미 360 돌아 봐": a full turn, not "turn round"
if stop_order(text, markers):
return "stop", None
told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or
intent_bank.past_ko(text)) # "you went to P5 earlier, right?": asked
intent_bank.past_ko(text) or CAN_TOLD.search(text))
# "you went to P5 earlier, right?", "you can lift your arm, right?", "너 팔 접을 수 있지?": asked, no order
text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1)
if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby"
return "sing", None
@@ -3371,15 +3407,18 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM
if plan:
return "chain", plan
got = seen(text) if seen else None
held_order = (holding() if callable(holding) else holding) and not hold and \
(brain_mod.held_place(text, markers) or brain_mod.held_give(text, markers)) # "put it down ok?" with a cup:
got = seen(text) if seen and not held_order else None # the hand, not "I put it down, now?"
if got:
return "seeing", got
if status_question(text):
return "status", None
if (holding() if callable(holding) else holding) and brain_mod.held_put_back(text, markers):
if (holding() if callable(holding) else holding) and not brain_mod.held_back(text) and \
not brain_mod.ARM_TALK.search(text) and brain_mod.held_put_back(text, markers):
return "quick", ("put", "back") # "it's my birthday, put that back where you found it!"
song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1)
if hold and not song: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
if hold and not song and not told: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
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)
@@ -3392,7 +3431,9 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
cor = brain_mod.correction(text, b.history)
if cor:
return "correction", cor
if not song and (brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
if not song and not brain_mod.ARM_TALK.search(text) and not brain_mod.held_back(text) and \
(brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
# not "it'd be cool if you could hand it over someday", "I heard you can take things from people"
held = holding() if callable(holding) else holding
hand = brain_mod.hand_request(text, held, b, markers)
if hand:
@@ -3408,12 +3449,16 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
if sing.asked(text, last):
return "sing", None
rule = brain_mod.intent(text, markers)
if rule and rule[0] in QUICK_RULES - {"come_back", "weather", "search"} and brain_mod.ARM_TALK.search(text):
return None, None # "자네 컵 잡는 거 제법이더군", "do you know how to drive right 30 cm?",
# "70센티 앞으로 움직일 리가 있나": a remark or an ability, no motion
if rule and rule[0] in QUICK_RULES:
return "quick", rule
if not rule:
from assistant import intent_bank
rule = intent_bank.read(text, markers, holding) # the same request in other words, by meaning
if rule and rule[0] in ("wave", "arm") and brain_mod.ARM_TALK.search(text):
rule = None if brain_mod.GREET_ONLY.match(text or "") else \
intent_bank.read(text, markers, holding) # the same request in other words, by meaning ("hello robot": no wave)
if rule and rule[0] not in ("come_back", "weather", "search") and brain_mod.ARM_TALK.search(text):
rule = None # "it'd be cool if you could take your hand back someday": talk (A1)
if rule:
return arm_quick(rule, holding)
@@ -3436,7 +3481,7 @@ ARM_AGAIN = re.compile(r"^\W*(?:(?:okay|ok|yes|yeah|lumi|please|robot|루미야?
FILLER_PART = re.compile(r"\W*(?:(?:hey|yo|hi|okay|ok|excuse me|um+|uh+|so|now|please|thanks|thank you|real quick|quick|"
r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미야?|로봇아?|당장|지금|빨리|"
r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미 ?씨|루미야?|로봇아?|당장|지금|빨리|"
r"얼른|어서|끝까지|이제|좀|제발)\W*)+", re.I) # a part of the words that is no step: a call, "now"
@@ -3445,7 +3490,10 @@ def read_mission(text, markers):
A single move / turn / arm / go, or words that are only partly a plain command, stay with the other paths."""
from assistant import steps
got, unread, by = steps.read(text, markers, llm=False)
unread = [u for u in unread if not FILLER_PART.fullmatch(u)] # "팔 접어, 당장", "hey robot, fold your arm"
from assistant import chain
unread = [u for u in unread if not FILLER_PART.fullmatch(u) and # "팔 접어, 당장", "hey robot, fold your arm"
not chain._restated(u, text.lower().replace(u, " "))] # "컵 잡아!, 아 잡아 줄 수 있어요?": said again
# (the parts come lower-cased: "부스 B로 가서" is the part itself, not said twice)
rule = brain_mod.intent(text, markers) or ("", "")
if unread and rule[0] == "look" and rule[1].endswith(f" {brain_mod.HEAD_YAW[1]:g}"):
return None # "turn around and look": the head looks behind (brain.BEHIND_WORDS)
@@ -3462,7 +3510,9 @@ def read_mission(text, markers):
return None
if len(got) > 1 and all(st == got[0] for st in got) and got[0]["do"] in ("arm", "wave", "look", "lift"):
got = got[:1] # "reach out, reach out to me": one reach, said twice
plain = not steps.is_mission(got) and (len(got) == 1 or (brain_mod.intent(text, markers) or ("",))[0] == "fetch")
one_part = len(steps._split(steps._norm(steps._cut_says(text)[0], markers), markers)) == 1
plain = not steps.is_mission(got) and (len(got) == 1 or one_part or (brain_mod.intent(text, markers) or ("",))[0] == "fetch")
# ^ "컵 가져와 주셨으면 해요": one part a plain fetch can do stays the fetch, not a mission
if not unread and (plain or (len(got) == 1 and got[0]["do"] in ("move", "turn", "arm"))): # "take the cup and put
return None # it on the chair": two steps, not a pick
return got, unread, by