Commands: full turn as two checked half turns, 'let's go p5' rule, dashboard Command box applies corrections, put it back, pairs of non-task commands asked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 10:16:29 +09:00
co-authored by Claude Opus 5.5
parent d8b11176fe
commit 8a81979bad
14 changed files with 151 additions and 37 deletions
+34 -13
View File
@@ -261,7 +261,7 @@ You can also move. Decide if the visitor asks you to do something:
"go back a little" -> move back 0.5, "move left two metres" -> move left 2, "let's back 1 meter" / "back up one
metre" / "1미터 뒤로 가" / whisper's "let's bake one meter" -> move back 1: straight back, no turning). At most 3 metres.
- turn <left|right|around> <degrees>: turn the whole body ("turn around" -> turn around 180,
"turn left" -> turn left 90).
"turn left" -> turn left 90, "spin around" / "한 바퀴 돌아" -> turn left 360).
- arm <reach|fold|open|close>: stretch your arm forward ("reach out your hand"), fold it back, or open / close
your hand (the gripper: "open your hand", "grab it", "let go").
- wave: wave your hand ("wave", "shake your hand", "say hi with your hand"). "Hello Lumi!" said to you or "say
@@ -505,15 +505,19 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
r"주라|주시면 감사하겠습니다|줬으면 좋겠어요?|주면 좋겠어요?)|요|자|야 ?해요?|면 안 ?돼요?)?\s*[.!?]*$"
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:point\s+)?([a-z][a-z0-9_]*)\s*(?:으로|로)\s*(?:좀\s*)?"
r"(?:가십시오|가시겠어요|가시죠|가실래요)\s*[.!?]*$"
r"|^\W*(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|well|now|lumi)\W+)*(?:go|drive|head)\s+([a-z][a-z0-9_]*)"
r"\W*(?:(?:please|now|for me|thanks)\W*)*$"), # whisper drops the "to": "go stage"
r"|^\W*(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|well|now|lumi|let'?s|lets)\W+)*(?:go|drive|head)\s+"
r"([a-z][a-z0-9_]*)(?:\W+point)?\W*(?:(?:please|now|for me|thanks)\W*)*$"), # whisper drops the "to": "go
# stage"; the owner: "let's go p5 (point)"
("sing", r"\bsing\b|\ba song\b|노래"),
("look", HEAD_WORDS), # head_target() reads the direction and amount
("wave", r"(?:^|[,.!?]\s*)(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|now|lumi|and|then)\W+)*(?:(?:can|could|would|will) you "
r"(?:please )?|please |let'?s |go ahead and |i'?d like you to |i want you to )?wave\b(?!s)|"
r"\bwave (?:at|to|your|hello|hi|bye|goodbye|back|again|for)\b|\bgimme a wave\b|\b(?:why don'?t you|if you (?:could|can|would)|"
r"you (?:could|should|can|might)|could you|would you|can you|will you) (?:please |just )?wave\b(?!s)|\bgive (?:(?:them|him|her|us|me|everyone|the \w+) )?"
r"a (?:little |quick |big |friendly )?wave\b|\bwave\s?(?:해|좀)|\bshake (?:your |a |my )?hands?\b(?! with\b)|\bsay (?:hi|hello|bye) with your hand\b|손 ?(?:을 |좀 |도 )?흔들|손 ?인사"),
r"a (?:little |quick |big |friendly )?wave\b|\b(?:wave|웨이브)\s?(?:해|하고|좀)|\bshake (?:your |a |my )?hands?\b(?! with\b)|\bsay (?:hi|hello|bye) with your hand\b|손 ?(?:을 |좀 |도 )?흔들|손 ?인사"),
("spin", r"\bspin (?:yourself )?(?:all the way |completely |fully )?(?:a)?round\b(?! (?:the|a|an|my|your|and look)\b)"
r"|\bturn (?:yourself )?(?:all the way|completely|fully) (?:a)?round\b|\bdo a (?:full )?(?:360|full turn|full circle|spin)\b|\bturn 360\b|\bspin\s*[.!]*$"
r"|한 ?바퀴 ?(?:빙 ?)?(?:돌|회전)(?![았었던은]|고 ?(?:와|오))|360\s*도\s*(?:돌|회전)(?![았었던은])|빙글 ?빙글 ?돌(?![았었던은])"),
("turn", r"\bturn (a)?round\b|(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?도(?:세요|십시오)|\bturn (?:to (?:the |your )?)?(left|right)\b|뒤로 ?돌|돌아 ?봐|"
r"(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?돌"),
("make_way", r"\b(can|could|would) you (please )?move( a bit| a little| please)?\s*[?.!]*$|\bmove (aside|out of the way|over)\b|"
@@ -554,7 +558,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|"
r"please))\b)|\b(?:later|tomorrow|tonight|next time|in an hour)\b|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼)|\byou'?ll (?:find|see)\b|\bat the corner\b|"
r"please))\b)|\b(?:later|tomorrow|tonight|next time|in an hour)\b|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼|좋겠)|\byou'?ll (?:find|see)\b|\bat the corner\b|"
r"\b(?:he|she|they|my \w+|his \w+|her \w+|our \w+|someone) (?:will|'ll|is going to|are going to)\b|"
r"(?:^|\s)(?:나중에|이따가?|내일)\s", re.I) # "after the talk ends, go to p1", "내가 가라고 하면": not now
STOP_ASK = re.compile(r"(?:(?:can|could|would|will) you (?:please |just )?stop(?: (?:now|please|moving|driving|here|there))?|"
@@ -619,10 +623,10 @@ def intent(text, markers=()):
return None if asks or "?" in t else ("look", "away") # "don't look at me", "쳐다보지 마"
if action != "quiet" and re.search(r"(?<!why )\b(don'?t|do not|never)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])", t) and action != "stop":
return None # "don't go to p1", "손 펴지 마": not an order
if asks and action in ("go_home", "go_point", "move", "make_way", "turn", "pick", "put", "move_object", "fetch", "come",
if asks and action in ("go_home", "go_point", "move", "make_way", "turn", "spin", "pick", "put", "move_object", "fetch", "come",
"arm", "grip_open", "grip_close", "wave", "look", "lift", "follow", "come_back"):
return None # "how do you pick up a cup?": a question, not an order
if visitor and action in ("go_home", "go_point", "move", "turn", "come", "wave", "look", "lift", "follow", "come_back"):
if visitor and action in ("go_home", "go_point", "move", "turn", "spin", "come", "wave", "look", "lift", "follow", "come_back"):
return None # "can I come closer?": the visitor asks for themselves
if action == "quiet" and re.search(r"\b(?:don'?t|do not|never) stop\b|그만하지 ?마", t):
return None # "don't stop talking"
@@ -653,6 +657,8 @@ def intent(text, markers=()):
return ("search", text)
if action == "fetch":
return ("fetch", text) # parse_fetch() reads the details
if action == "spin": # all the way round: two checked half turns (lumi.move_by)
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 360")
if action == "turn":
if re.search(r"around|뒤로", t) or not re.search(r"left|right|왼쪽|오른쪽", t): # "왼쪽으로 돌아": left
return ("turn", "around 180")
@@ -912,11 +918,18 @@ def place_said(name):
return re.sub(r"[_-]+", " ", name)
def no_place_say(word, markers):
"""(en, ko): this map has no place called `word`, and the places it has."""
def no_place_say(word, markers, text=""):
"""(en, ko): this map has no place called `word`, and the places it has. Korean words: the place as said in
`text` ("출구로 가" -> 출구), never the model's English for it."""
known = ", ".join(place_said(m) for m in markers) or "none"
said = re.search(r"([가-힣]+?)\s*(?:으로|로|에|까지)\s*(?:좀\s*)?(?:가|와|이동|돌아)", text or "")
ko = said.group(1) if said else None if word == "that" else place_said(word)
if ko is None:
return (f"I don't have a place called that on this map. I know: {known}.",
f"그런 곳은 이 지도에 없어요. 제가 아는 곳은 {known}이에요.")
final = "가" <= ko[-1] <= "힣" and (ord(ko[-1]) - 0xAC00) % 28
return (f"I don't have a place called {place_said(word)} on this map. I know: {known}.",
f"이 지도에는 {place_said(word)}라는 곳이 없어요. 제가 아는 곳은 {known}이에요.")
f"이 지도에는 {ko}{'이라는' if final else '라는'} 곳이 없어요. 제가 아는 곳은 {known}이에요.")
_GO_WORD = re.compile(r"\b(?:go|drive|move|head|come|return|bring it|take it)(?: back)? to (?:the )?(?:point |marker )?"
@@ -1163,6 +1176,9 @@ RECEIVE_KO = re.compile(
r"(?:드릴게|드릴께|줄게|줄께|드리려고|주려고|드릴 ?거|줄 ?거)(?!.*(?:줘|주세요))|"
rf"(?:{_THIS_KO}(?:\s*(?:{_COL}))?(?:\s*(?:{_OBJ}))?(?:을|를)?|(?:내|제) 손에 (?:있는|든) (?:거|것|(?:\S+\s+)?\S+))\s*(?:좀\s*)?"
r"(?:가져가|들고 ?있어|잡아(?!당)|맡아)", re.I)
PAID_Q = re.compile(r"(?<![가-힣])(?:월급|연봉|급여|보너스|월세|세금|전화|문자|메일|연락|칭찬|사랑|상|점수|인기|스트레스|대접|교육|"
r"훈련|충전|수리|검사|업데이트)(?:을|를|은|는|도|이|가)?\s*(?:많이 |잘 |자주 |얼마나 )?받|"
r"^\W*(?:너|넌|너는|루미는?|당신은?)\s.*받(?:아|아요|니|나요|냐|았어|으세요)?\s*\?\s*$") # a question about Lumi
GIVE_EN = re.compile(
rf"\b(?:give|hand|pass|bring)\s+(?:{_IT}|the \w+|that \w+|this \w+)(?:\s+(?:back|over))?(?:\s+(?:to|for)\s+{_WHO})?(?:\s+(?:here|over here|over there|there|back))*{_TAIL}"
rf"|\b(?:give|hand|pass)\s+(?:{_WHO})\s+(?:{_IT}|the \w+|that \w+|that|this \w+|what you(?:'re| are) holding)\b"
@@ -1206,12 +1222,17 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
return None # a marker named: a trip, the mission reader's
if whole:
from assistant import steps
got = [s["do"] for s in steps.rules(text, markers)[0]]
got, unread = steps.rules(text, markers)
got = [s["do"] for s in got]
if len(set(got)) > 1 and got != ["pick", "give"]: # not "give me the cup" (picked first when the hand is empty)
return None # "take the cup, move back half a metre and hold it"
if got and any(intent(u, markers) for u in unread):
return None # "put it down and wave": the mission reader asks, never half done
named = re.search(rf"(?<![a-z])(?:{_OBJ})s?(?![a-z])", t)
if holding and OPEN_HAND.search(t):
return ("refuse", REFUSE_OPEN)
if RECEIVE_KO.search(t) and not RECEIVE_EN.search(t) and PAID_Q.search(t):
return None # "너 월급 받아?": about Lumi, nothing handed over
if RECEIVE_EN.search(t) or RECEIVE_KO.search(t):
if holding and re.search(r"\bhold (?:it|that|on)\s*(?:$|[,.!?]|for\b|please\b|there\b)|^\W*(?:그거\s*)?들고 ?있어", t):
return None # "just hold it": keep holding it
@@ -1827,10 +1848,10 @@ class Brain:
if action == "go_to":
said, target = target, next((mk for mk in markers if mk.lower() == target.lower()), None)
if not target and said.lower() not in ("", "none"):
say = place_problem(f"go to {said}", markers) or no_place_say(said, markers) # "go_to kitchen"
say = place_problem(f"go to {said}", markers) or no_place_say(said, markers, text) # "go_to kitchen"
if target and not named_place(text, target, markers):
target = None # "take me to the meeting room" -> p1: a guess, not driven
say = no_place_say("that", markers)
say = no_place_say("that", markers, text)
action = "go_to" if target else "none"
bare = CALLING.sub("", text)
if action in MOTIONS and (QUESTION_START.search(bare) and not (action in ("give", "receive") and
+20 -6
View File
@@ -863,14 +863,17 @@ class Lumi:
if action == "move" and not driving.MOVE_MIN_M <= amount <= MAX_MOVE_M:
log(f" move {amount:g} m: outside {driving.MOVE_MIN_M:g}..{MAX_MOVE_M:g} m, not driven")
return False
if action == "move" and direction in ("back", "forward"): # straight with joy_control, checked like a
from tasks import fetch # mission's move: navigation may turn round and
log(f" move {direction} {amount:g} m straight") # stops within its own tolerance
self.stay()
full = action == "turn" and amount >= 360 # all the way round: a 360 deg goal is the start
if action == "move" and direction in ("back", "forward") or full: # pose to navigation; fetch turns twice 180
from tasks import fetch # straight with joy_control, checked like a
log(f" {action} {direction} {amount:g} by the task runner") # mission's move: navigation may turn round
self.stay() # and stops within its own tolerance
step = {"do": "turn", "deg": -360.0 if direction == "right" else 360.0} if full else \
{"do": "move", "dir": direction, "m": amount}
try:
fetch.run_steps([{"do": "move", "dir": direction, "m": amount}], say=self.fetch_say)
fetch.run_steps([step], say=self.fetch_say)
except fetch.FetchError as e:
log(f" move {direction} refused: {e}")
log(f" {action} {direction} refused: {e}")
self.fetch_say(str(e), "죄송해요, 지금은 할 수 없어요.")
return False
return True
@@ -1345,6 +1348,9 @@ class Lumi:
if unread:
log(f" mission: unread {unread} ({by})")
problem = brain_mod.place_problem(" ".join(unread), self.markers) # "go to booth" with two booths
if not problem and not got:
problem = ("Sorry, I can do only one of those at a time. Please ask me one thing at a time.",
"죄송해요, 한 번에 하나씩만 할 수 있어요. 하나씩 말씀해 주세요.")
if not problem and all(brain_mod.intent(u, self.markers) for u in unread):
problem = (f"Sorry, I can't do that as part of a task: {', '.join(unread)}. Please ask me one thing at a time.",
"죄송해요, 그건 작업 중에 함께 할 수 없어요. 하나씩 말씀해 주세요.")
@@ -2038,6 +2044,8 @@ class Lumi:
if action == "turn":
say_en = "Okay, turning around." if d == "around" else f"Okay, turning {d}."
say_ko = "네, 뒤로 돌게요." if d == "around" else ("네, 왼쪽으로 돌게요." if d == "left" else "네, 오른쪽으로 돌게요.")
if n == "360":
say_en, say_ko = "Okay, turning all the way around.", "네, 한 바퀴 돌게요."
else:
exact = driving.amount(brain_mod._norm(text))[1] # "about 5 centimetres" for "a tiny bit"
say_en, say_ko = (driving.say_move(d, float(n), exact, lang) for lang in ("en", "ko"))
@@ -2611,6 +2619,8 @@ def talk_fate(text):
return "talk"
KO_ORDER = {"보": "봐", "흔들": "흔들어", "돌": "돌아", "올리": "올려", "내리": "내려", "높이": "높여", "낮추": "낮춰"} # "나 보고 손 흔들어": 나 봐
ONE_AT_A_TIME = {"look", "lift", "wave", "turn", "move", "come", "follow", "go_to", "arm", "pick", "put", "move_object"}
NOT_A_STEP = re.compile(r"^\W*(?:(?:please|and|then|also)\s+)*(?:dance|jump|fly|swim|climb|sit(?: down)?|sleep|cook|draw|"
r"sing|clap|spin|bow|kneel|do a (?:dance|flip|trick)|tell|ask|say|show|call|find|look for|search|"
r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked
@@ -2631,6 +2641,10 @@ def read_mission(text, markers):
elif unread and got and any((brain_mod.intent(u, markers) or ("",))[0] not in ("", "weather", "search", "fetch")
or NOT_A_STEP.match(u) for u in unread):
return got, unread, by # "go to the stage and wave": no task step, asked, never half done
elif unread and not got and len(unread) > 1 and sum((brain_mod.intent(u, markers) or brain_mod.intent(
re.sub(r"(보|흔들|돌|올리|내리|높이|낮추)고$", lambda m: KO_ORDER[m.group(1)], u), markers) or ("",))[0] in ONE_AT_A_TIME
for u in unread) > 1:
return got, unread, by # "look at me and wave", "웨이브 하고 나 봐": asked, not the first only
elif unread:
return None # "come here, I need help": the old paths (rules, the LLM) answer it
if not got:
+16
View File
@@ -53,6 +53,7 @@ def _norm(text, markers=()):
t = re.sub(r"\b(mr|mrs|ms|dr|prof)\. ", r"\1 ", wording.durations(brain.unfill(wording.norm(text, markers))) + " ")
t = re.sub(r"\b(?:take|pick up|pick|grab)\s?(?:해서|하고)", "집어서", t) # "컵 take해서": mixed
t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고"
t = re.sub(r"(?<![가-힣])(집었|잡았)다가(?=[\s,]|$)", lambda m: m.group(1)[0] + "고", t) # "컵 집었다가" = "컵 집고"
for honour, plain in _HON_KO: # "가셔서" = "가서", "받으시고" = "받고"
t = re.sub(rf"(?<![가-힣]){honour}(?=[\s,.!?]|$)", plain, t)
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신|도신)"
@@ -169,7 +170,14 @@ def _move(c):
return None
_SPIN = re.compile(next(p for a, p in brain.INTENTS if a == "spin"), re.I) # "한 바퀴 돌아", "spin around"
_SPIN_REST = re.compile(r"\b(?:to (?:the |your )?)?(?:left|right)\b|\b(?:once|in place|on the spot)\b|제자리에서|그 ?자리에서|"
r"(?:왼쪽|오른쪽)으로|(?<![가-힣])(?:아|고|아서|았다가|아요|해|하고|해서|아 ?봐)(?![가-힣])|\s+")
def _turn(c):
if _SPIN.search(c) and not _SPIN_REST.sub("", _SPIN.sub(" ", c)):
return {"do": "turn", "deg": -360.0 if re.search(r"\bright\b|오른쪽", c) else 360.0} # fetch: two half turns
if re.fullmatch(r"turn(?: around)? 180(?: degrees?)?|(?:180\s*도|뒤로)\s*(?:돌아|돌고|돌아서)", c):
return {"do": "turn", "deg": 180.0}
m = re.fullmatch(r"turn (?:to the |to your )?(left|right|around)(?: by)?(?: {0}(?: degrees?)?)?".format(_NUM), c)
@@ -726,6 +734,10 @@ def _clause_steps(c, markers, after=None):
r"|이리와|come (?:back )?here|come back|(?:come |go |get )?(?:right |straight )?back (?:here|to me)|"
r"come (?:right|straight) back(?: here)?", c):
return [{"do": "go", "to": "here"}]
if after and after["do"] == "pick" and re.fullmatch(
r"put (?:it|that|this|the \w+) back(?: down| there| where it was| on the table)?|"
r"(?:(?:그거|그걸|컵|그 컵)(?:을|를)? )?(?:(?:다시|제자리에|원래 자리에)\s*)+(?:놔|놓아|놓고|둬|두고|내려놔|내려 ?놓아)\s*(?:줘|요)?", c):
return [{"do": "place", "on": None}] # "take the cup and put it back": picked here, put down here
s = _wait(c, markers, after)
if s is not None:
return s
@@ -1253,6 +1265,8 @@ def _en(s, last=False):
if d == "turn":
if abs(s["deg"]) == 180:
return "turn around"
if abs(s["deg"]) == 360:
return "turn all the way around" + (" to the right" if s["deg"] < 0 else "")
side = "left" if s["deg"] > 0 else "right"
return f"turn {side}" + ("" if abs(s["deg"]) == TURN_DEG else f" {abs(s['deg']):g} degrees")
if d == "pick":
@@ -1291,6 +1305,8 @@ def _ko(s, last=False):
side = {"forward": "앞으로", "back": "뒤로", "left": "왼쪽으로", "right": "오른쪽으로"}[s["dir"]]
return f"{side} {s['m']:g}미터 가고"
if d == "turn":
if abs(s["deg"]) == 360:
return "오른쪽으로 한 바퀴 돌고" if s["deg"] < 0 else "한 바퀴 돌고"
return "뒤로 돌고" if abs(s["deg"]) == 180 else ("왼쪽" if s["deg"] > 0 else "오른쪽") + "으로 돌고"
if d == "pick":
from tasks.fetch import OBJECTS as KO, PREFER_SAID