Missions: any stop word ends any task; questions answered while paused; a new command from anyone replaces the task; only go on resumes; one more after a look

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 17:22:46 +09:00
co-authored by Claude Opus 5.5
parent fc73a90208
commit 53a8edc13f
7 changed files with 234 additions and 60 deletions
+8 -3
View File
@@ -61,7 +61,7 @@ _FILLER = (r"please|pls|lumi|hey|hi|okay|ok|so|um+|uh+|well|now|then|just|can|co
r"루미야|루미|좀|조금|조금만|더|약간|살짝|이제|그냥|너무|가|가줘|가 ?줘|가요|가세요|줘|주세요|줄래|줄래요|"
r"줄래\?|주실래요|주시겠어요|해|해줘|해요|해 ?줘|움직여|요|좀더|조금더|자|볼래|봐|볼까|좀만|해봐")
FILL = re.compile(rf"(?:^|\s)(?:{_FILLER})(?=\s|$)")
AGAIN = re.compile(r"^(?:(?:just|a|an|bit|little|tiny|some|even|one|once|the|same|do|it|that|go|please|lumi|ok|"
AGAIN = re.compile(r"^(?:(?:just|a|an|bit|little|tiny|some|even|one|1|once|the|same|do|it|that|go|please|lumi|ok|"
r"okay|yeah|yes|and|then|now)\s+)*(?:more|again|once more|one more time|same again|"
r"the same again|more please|again please|1 more time)(?:\s+(?:please|lumi|then))?$|"
r"^(?:루미야\s+)?(?:조금만?|좀|살짝|약간|한 ?번|1 ?번|아까처럼|똑같이)?\s*더"
@@ -131,7 +131,8 @@ def speed(t):
def read(t, last=None, talking=False):
"""What a sentence asks of the base, or None (not about driving):
("move", "back 0.2", exact) | ("turn", "left 90") | ("speed", +1 | -1) | ("refuse", "back 5") | ("ask", "back" | "").
("move", "back 0.2", exact) | ("turn", "left 90") | ("speed", +1 | -1) | ("refuse", "back 5") | ("ask", "back" | "")
| ("look" / "lift", "left small"): "one more" after a look or a lift.
`last` is the move / speed just before (last_command(history)): "more" / "again" repeat it. With none and
`talking` (the turn before was conversation) "more" is left to the conversation, else it is asked about."""
t = clean(t)
@@ -165,9 +166,13 @@ def _checked(d, n, exact):
def last_command(history):
"""The move, turn or speed change of the turn just before, from brain history ("ACTION: move back 0.2"), else None."""
"""The move, turn, speed change, look or lift of the turn just before, from brain history ("ACTION: move back
0.2", "ACTION: look left" -> ("look", "left small")), else None."""
if not history:
return None
m = re.match(r"ACTION: (look|lift) (left|right|up|down)\b", history[-1][1] or "")
if m: # "look left" then "one more": a little further that way
return (m.group(1), f"{m.group(2)} small")
m = re.match(r"ACTION: (move|speed|turn) (\S+)(?: (\S+))?", history[-1][1] or "")
if not m:
return None
+59 -45
View File
@@ -183,6 +183,9 @@ DONE_TALK = re.compile(r"\b(bye+|goodbye|see you|never ?mind|nothing|that'?s (al
r"okay|ok|fine|alright|cool|whatever)\b|안녕히|잘 ?가|됐어|괜찮아|아니야|고마워|감사|그래|네|수고|알았어|"
r"그게 ?다|빠이|바이|나중에|안녕\s*[.!]?$", re.I)
TALK_RECENT_S = 20.0 # s; someone spoke with Lumi this recently: what they say next is to Lumi too
ENOUGH = re.compile(r"\b(enough|no more)\b|그만해|됐어 ?그만", re.I) # with stop_order: ends a mission at once
ASK_NOT_ORDER = re.compile(r"\b(can|could|would|will) you\b|\bplease\b|줄래|줄 ?수|해 ?줘|주세요|(?<!뭐 )줘", re.I) # a request
LOOK_KEEP_S = 60.0 # s after a "look left" the head is not turned back ahead when the person leaves the view
COMPANY_Q = re.compile(r"\b(cutshion|barista robot|drawing robot|your (maker|makers|company|ceo|price)|(this|the|that|what|which) company|"
r"ceo of (it|this|the company)|founder of (it|this)|mega ?coffee|"
r"sonovictus|omron|borgwarner|bogate|cnt tech|seed round|target market|business model|(your|cutshion'?s?) awards?|how much (do|does) (you|it|this|lumi) cost)\b|"
@@ -229,7 +232,7 @@ NOT_KNOWN = {"en": ["I'm sorry, I don't have that information. A staff member ca
def not_known(lang):
return random.choice(NOT_KNOWN[lang])
TALK_ASK_S = 15.0 # s of silence while halted for someone -> "Can I go on with my task?", again -> go on
TALK_ASK_S = 15.0 # s of silence while halted for someone -> "Can I go on with my task?" (asked once)
RELEASE = re.compile(r"^\s*(?:(?:ok(?:ay)?|alright|lumi|루미야?)[\s,.!]+)?(?:you can go(?: now)?|take care|가 ?보세요|가세요|가도 ?돼요?)"
r"[\s.!~]*$", re.I) # said alone: the visitor lets Lumi go
THANKS = re.compile(r"\bthank(?:s| you)\b|\bthanx\b|\bcheers\b|고마워|고맙|감사|땡큐", re.I)
@@ -851,6 +854,7 @@ class Lumi:
cur = safe(head.status)
if cur is None:
return None
self.looked_at = time.time()
yaw, pitch, limited = brain_mod.head_goal(target, cur[2], cur[3], LOOK) # the body's full range (AXIS_LIMITS):
threading.Thread(target=lambda: safe(head.moveto, [cur[0], cur[1], yaw, pitch]), # head.turn() keeps
daemon=True).start() # to YAW_LIMIT
@@ -925,8 +929,8 @@ class Lumi:
hist = self.brain.history
t = brain_mod._norm(text)
got = driving.read(t, driving.last_command(hist), driving.talking(hist))
if not got or got[0] != "speed" and (self.mission_running() or got == driving.read(t, None, True)
and got[0] == "move"):
if not got or got[0] not in ("speed", "look") and (self.mission_running() or got == driving.read(t, None, True)
and got[0] == "move"):
return False
lang = "en" if self.lang == "en" else "ko"
if got[0] == "speed":
@@ -957,6 +961,11 @@ class Lumi:
return True
else:
say = "Okay." if lang == "en" else "네."
elif got[0] in ("look", "lift"): # "one more" / "더" after a look or a lift: further that way
hist.append((text, f"ACTION: {got[0]} {got[1]}"))
log(f" action {got[0]} {got[1]} (again)")
limited = self.look(got[1]) if got[0] == "look" else "lift" if self.lift(got[1]) else None
say = LIMIT_SAY[limited][lang != "en"] if limited else "Okay." if lang == "en" else "네."
elif got[0] == "refuse":
d, n = got[1].split()
say = driving.say_refused(d, float(n), lang)
@@ -1042,8 +1051,7 @@ class Lumi:
self.fetch_say(f"I'm holding {fetch.held_name()}, where should I put it first?", "뭔가 들고 있어요. 먼저 어디에 둘까요?")
return
if status == "running":
self.fetch_say("I'm still doing a task. Say stop to cancel it.", "아직 일하는 중이에요. 멈추려면 멈춰라고 하세요.")
return
self.end_run(text)
from tasks import fetch
task, problems = brain_mod.parse_fetch(text, self.markers)
log(f" fetch parsed: {task} problems {problems}")
@@ -1105,7 +1113,8 @@ class Lumi:
def sing_song(self, text):
"""Sing a song for these words, the head moving with it. Blocks like speech; "stop" ends it at once, any
other request ends it and is answered next ("sing another song" sings a different one)."""
if self.skill_busy() or self.mission_running(): # the head and the speaker belong to the task now
self.end_run(text) # a running task ends for the song
if self.skill_busy() or self.mission_running(): # the head and the speaker belong to the arm task now
self.fetch_say("Sorry, I'm on a task right now. I can sing when I've finished.",
"죄송해요, 지금 다른 일을 하고 있어요. 끝나면 불러 드릴게요.")
return
@@ -1152,8 +1161,9 @@ class Lumi:
def mission_talk(self, text):
"""Something said while a mission runs (docs/17 §6). Addressed speech halts it (fetch.pause) and Lumi talks;
a stranger's new task is refused; the person the mission is for ("I'm James") gets it here or changes it;
"go on" / goodbye / no answer go on. True if handled here; False: answer it as a question (still halted)."""
anyone's stop word ends it at once; anyone's new command ends it with one line and is then done as usual
(False); the person the mission is for ("I'm James") gets it here or changes it; only an explicit "go on" (or
a yes to "Can I go on?") goes on. True if handled here; False: answered or done as usual."""
from assistant import steps
from tasks import fetch
st = safe(fetch.state) or {}
@@ -1164,13 +1174,17 @@ class Lumi:
FETCH_THANKS.search(text) and st.get("step") == "giving":
safe(fetch.release_now) # the person let go of it / has taken it
return True
if stop_order(text, self.markers) or ENOUGH.search(text) and "?" not in text:
log(f" mission: stop word ({text!r}) - mission ended") # running or paused: ended, never "going on"
self.mission_hold, self.asked_go_on = None, False
self.stop_all()
return True
recipient = next((s.get("person") for s in task_steps if s.get("do") == "give" and s.get("person")), None)
name = claimed_name(text)
owner = next((p for p in (recipient, task.get("sender")) if p and name and same_name(name, p)), None)
mine = owner is not None # the person it is for, or who sent it
if mine:
name = owner # as the mission writes it ("James", not "james")
was_halted = bool(self.mission_hold)
addressed = WAKE.search(text) or TALK_WORDS.search(text) or SAFETY.search(text) or mine or name or \
STATUS_Q.search(text) or \
REQUEST.search(text) or GIVE_ME.search(text) or self.mission_hold or self.current is not None or \
@@ -1208,12 +1222,6 @@ class Lumi:
safe(fetch.proceed) # "go on" ends a wait step
self.resume_mission(say=True)
return self.keep_listening() or True
if was_halted and self.mission_hold == "talk" and DONE_TALK.search(text) and not name and \
not steps.read(text, self.markers, llm=False)[0] and not REQUEST.search(text) and not GIVE_ME.search(text) \
and not lumi_question(text):
self.fetch_say("Okay, see you! I'll go on with my task.", "네, 안녕히 계세요! 하던 일 계속할게요.")
self.resume_mission()
return self.keep_listening() or True
if waiting == "instruction": # "do what they tell you": the person here may give one task
got, unread, _ = steps.read(WAKE.sub(" ", text).strip(" ,.!?"), self.markers)
if got and not unread:
@@ -1255,24 +1263,20 @@ class Lumi:
self.fetch_say(f"Hi {name}, this is for you. Here you go.", f"{name}님, 이거 드릴게요.")
self.replace_mission([{"do": "give", "person": recipient}])
return self.keep_listening() or True
if name and recipient and not mine and (REQUEST.search(text) or CHANGE_WORDS.search(text)) or \
name and recipient and not mine and re.search(r"\b(give|hand|mine|for me|my name is)\b|주세요|줘|제 거|내 거", text, re.I):
log(f" mission: {name} is not {recipient}")
self.fetch_say(f"Sorry, this is for {recipient}, I have to bring it to them.",
f"죄송해요, 이건 {recipient}님께 가져가는 거예요.")
return self.keep_listening() or True
got, unread, _ = steps.read(text, self.markers, llm=False)
if lumi_question(text) and not ASK_NOT_ORDER.search(text) and not (got and not unread) and not REQUEST.search(text):
return False # "what is my hand?": a question, answered as usual (still halted)
rule = brain_mod.intent(text, self.markers)
insist = time.time() - getattr(self, "refused_at", 0.0) < TALK_RECENT_S and not lumi_question(text) and \
not DONE_TALK.search(text)
if CANCEL_TASK.search(text) or (got and not unread) or REQUEST.search(text) or GIVE_ME.search(text) or insist or \
(rule and rule[0] in ("go_to", "come", "fetch", "move", "turn", "pick", "put", "move_object")):
what = steps.describe(task_steps)
log(f" mission: a new task from someone else refused ({text!r})")
self.refused_at = time.time()
self.fetch_say(f"Sorry, I'm doing a task for someone: {what[0].lower() + what[1:]} I can help you when "
"I've finished.", "죄송해요, 지금 다른 분의 일을 하고 있어요. 끝나면 도와드릴게요.")
order = (got and not unread) or REQUEST.search(text) or GIVE_ME.search(text) or rule and rule[0] in MOVING_ACTIONS
if CANCEL_TASK.search(text) and not order:
log(f" mission cancelled ({text!r})")
safe(fetch.end)
self.mission_hold, self.asked_go_on = None, False
self.fetch_say("Okay, I've cancelled my task.", "네, 하던 일을 취소했어요.")
return self.keep_listening() or True
if order: # anyone's new command: the mission ends, the command is done
self.end_run(text)
return False
if FETCH_STOP.search(text) and len(re.findall(r"\w+", text)) <= 3 or NAME_ONLY.match(text) or HELLO_ONLY.match(text) \
or (WAKE.search(text) and len(WAKE.sub("", text).strip(" ,.!?")) < 3):
self.fetch_say("Hi, I'm Lumi. I stopped for you. How can I help you?",
@@ -1280,6 +1284,17 @@ class Lumi:
return self.keep_listening() or True
return False # a question: answered as usual, still halted
def end_run(self, text):
"""Anyone's new command while the task runner runs (a mission, a fetch): end it with one short line; the
command is then done. Nothing held is forgotten (a "holding" state is no run)."""
from tasks import fetch
if self.fetch_status() != "running":
return
log(f" task ended for a new command ({text!r})")
safe(fetch.end)
self.mission_hold, self.asked_go_on = None, False
self.fetch_say("Okay, I've stopped my task.", "네, 하던 일을 멈췄어요.")
def instruction(self, got):
"""The person at the place a mission waits at says what to do: read back, a spoken yes, then it is done
there and the mission goes on (fetch.instruct; docs/17 §4)."""
@@ -1315,15 +1330,12 @@ class Lumi:
self.fetch_say(str(e), "죄송해요, 지금은 할 수 없어요.")
def mission_wait(self):
"""Halted for someone and nobody speaks: ask once whether to go on, then go on (never after a safety stop)."""
if self.mission_hold != "talk" or time.time() - self.last_activity < TALK_ASK_S:
"""Halted for someone and nobody speaks: ask once whether to go on. It goes on only when told ("go on", a yes
to that question, the dashboard), never by itself."""
if self.mission_hold != "talk" or self.asked_go_on or time.time() - self.last_activity < TALK_ASK_S:
return
if not self.asked_go_on:
self.asked_go_on = True
self.fetch_say("Can I go on with my task?", "하던 일 계속해도 될까요?")
else:
log(" no answer - going on with the mission")
self.resume_mission(say=True)
self.asked_go_on = True
self.fetch_say("Can I go on with my task?", "하던 일 계속해도 될까요?")
self.last_activity = time.time()
def now_doing(self):
@@ -1470,9 +1482,7 @@ class Lumi:
if not self.modes.drive:
self.fetch_say("Sorry, driving is switched off.", "죄송해요, 지금은 이동할 수 없어요.")
return True
if self.fetch_status() == "running":
self.fetch_say("I'm still doing a task. Say stop to cancel it.", "아직 일하는 중이에요. 멈추려면 멈춰라고 하세요.")
return True
self.end_run(text)
from tasks import fetch
problems = steps.check(got, fetch.check_hand(), self.markers)
if problems:
@@ -1736,6 +1746,10 @@ class Lumi:
elif cmd == "route":
self.start_trip(d["markers"], d.get("pause", 1.0))
elif cmd == "cancel":
if self.mission_running(): # running or paused: never goes on after a cancel
from tasks import fetch
safe(fetch.stop)
self.mission_hold, self.asked_go_on = None, False
if self.patrol:
self.patrol.pause()
self.patrol = None
@@ -2104,8 +2118,6 @@ class Lumi:
self.current, self.voice_until, self.closing_pending = None, 0.0, None
self.brain.reset()
self.turn_head(0, 0)
if self.mission_hold == "talk": # halted for this talk: go on with the mission
self.resume_mission()
if self.traveling():
log(" conversation over - driving on")
self.patrol.wait_until = time.time() + 0.5
@@ -2577,6 +2589,7 @@ class Lumi:
if not self.modes.drive:
mouth.say("Sorry, driving is switched off." if en else "죄송해요, 지금은 이동할 수 없어요.")
return
self.end_run(getattr(self, "heard", "") or "follow me")
if self.skill_busy():
self.fetch_say("Sorry, I'm on a task right now.", "죄송해요, 지금 다른 일을 하고 있어요.")
return
@@ -2663,8 +2676,9 @@ class Lumi:
self.turn_head(HEAD_SIGN * self.current.angle)
else:
# often still there, out of the frame (beside the arm): keep listening without the wake word
# for a while, like a conversation started by voice
self.turn_head(0, 0)
# for a while, like a conversation started by voice. After "look left" the head stays there
if time.time() - getattr(self, "looked_at", 0.0) > LOOK_KEEP_S:
self.turn_head(0, 0)
self.voice_until = time.time() + VOICE_SESSION_S
self.last_activity, self.prompts = time.time(), 0
return
+7
View File
@@ -2361,6 +2361,13 @@ def stop():
log("stopped")
def end(timeout=5.0):
"""stop() and wait until the run has ended, so a new task can start right after."""
stop()
if _thread is not None:
_thread.join(timeout)
# ---------- measuring the arm's yaw on the base ----------
def _straight(dist_m, speed=None):
"""Drive straight by dist_m (+ forward) at `speed` m/s (AXIS_SPEED; a function: read again every 0.1 s, so a
+2 -1
View File
@@ -57,7 +57,8 @@ def rules(text, state, marks, b):
drive = driving.read(t, driving.last_command(b.history), driving.talking(b.history))
if drive and (drive[0] != "move" or drive != driving.read(t, None, True)):
return {"speed": lambda d: f"speed {'faster' if d[1] > 0 else 'slower'}", "move": lambda d: f"action:move {d[1]}",
"turn": lambda d: f"action:turn {d[1]}",
"turn": lambda d: f"action:turn {d[1]}", "look": lambda d: f"action:look {d[1]}",
"lift": lambda d: f"action:lift {d[1]}",
"refuse": lambda d: "refuse", "ask": lambda d: "ask"}[drive[0]](drive)
if lumi.NAME_ONLY.match(text):
return "talk"
+149
View File
@@ -0,0 +1,149 @@
"""Self-check of stop words, questions and new commands on a running or paused mission, replaying the owner's live
test of 2026-10-22 16:56-16:59 (logs/lumi_console.log) in order; fake mission runner, nothing reaches the robot:
python tests/test_mission_stop.py"""
import json
import os
import tempfile
import threading
import time
from assistant import lumi
from tasks import fetch
M = ["home", "dock2"] + [f"p{i}" for i in range(1, 11)]
BACK = [{"do": "move", "dir": "back", "m": 1.0}]
DELIVERY = [{"do": "pick", "object": "cup", "colour": None}, {"do": "go", "to": "p6"}, {"do": "give", "person": "James"}]
done, run = [], {"status": "running", "paused": False, "steps": BACK}
def _stop():
done.append("stop")
run["status"] = "stopped"
fetch.state = lambda: {"status": run["status"], "task": {"steps": run["steps"]}, "holding": False}
fetch.pause = lambda: (done.append("pause"), run.update(paused=True), True)[-1] if run["status"] == "running" else False
fetch.paused = lambda: run["paused"]
fetch.resume = lambda: (done.append("resume"), run.update(paused=False))
fetch.stop = _stop
fetch.end = lambda timeout=5.0: (done.append("end"), run.update(status="stopped"))
fetch.replace = lambda steps, say=None: done.append(("replace", steps))
fetch.proceed = lambda: done.append("proceed")
lumi.agv.cancel = lambda: done.append("agv cancel")
lumi.mouth.say = lambda text, **k: done.append(("say", text))
class Track: # a vision track: the id changes, the re-id person stays
def __init__(self, tid, person):
self.id, self.person = tid, person
OWNER, OTHER = object(), object() # reid.Person stand-ins: who it is makes no difference
def fresh(steps=BACK, paused=False, hold=None, current=None):
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers, L.lang, L.current, L.mission_hold, L.asked_go_on = M, "en", current, hold, False
L.patrol, L.chain_stop = None, threading.Event()
L.last_activity, L.said = time.time(), []
L.fetch_say = lambda en, ko: L.said.append(en)
L.keep_listening = lambda: None
L.act = lambda action, target: done.append(("act", action)) # stop_all's motion stop: not to the robot
done.clear()
run.update(status="running", paused=paused, steps=steps)
return L
def halted(L): # the mission paused for a talk, as at 16:56:07 on the old code
run["paused"], L.mission_hold = True, "talk"
return L
# 16:56:07 "Stop it." while the 1 m drive back runs: stopped and ended at once, not paused
L = fresh(current=Track(21, OWNER))
assert L.mission_talk("Stop it.") and "stop" in done and "pause" not in done, done
assert run["status"] == "stopped" and L.mission_hold is None and L.said[-1] == "Okay, I stopped.", (run, L.said)
for word in ("stop", "Okay, stop it.", "enough", "that's enough", "그만", "멈춰", "정지", "그만해"): # running or paused
for p in (False, True):
L = fresh(paused=p, hold="talk" if p else None)
assert L.mission_talk(word) and "stop" in done and "resume" not in done, (word, p, done)
assert not L.mission_running(), word
# no mission (a fetch, follow, a song, the arm): the same words are a stop order (route -> stop_all, fetch.stop)
for word in ("Stop it.", "Okay, stop it.", "stop", "그만", "멈춰", "정지"):
assert lumi.stop_order(word, M), word
# 16:56:52 "What is my hand?" (same person #21) on the paused mission: a question, answered as usual
for q in ("What is my hand?", "What is it my hand?", "내 손에 뭐 있어?"):
L = halted(fresh(current=Track(21, OWNER)))
assert L.mission_talk(q) is False and not any("doing a task" in s for s in L.said), (q, L.said)
assert "stop" not in done and "end" not in done, (q, done)
# 16:57:02 "Okay, stop it." after "Can I go on with my task?": ended, never "going on"
L = halted(fresh(current=Track(21, OWNER)))
L.asked_go_on = True
assert L.mission_talk("Okay, stop it.") and "stop" in done and "resume" not in done, done
# 16:57:09 "Okay." on a paused mission: not a go-on
L = halted(fresh(current=Track(21, OWNER)))
L.mission_talk("Okay.")
assert "resume" not in done, done
# only an explicit go-on resumes it
for go in ("go on", "continue", "계속해"):
L = halted(fresh())
assert L.mission_talk(go) and done[-1] == "resume", (go, done)
# silence while paused: asked once, never goes on by itself (16:59:36 "no answer - going on with the mission")
L = halted(fresh())
for _ in range(3):
L.last_activity -= 100
L.mission_wait()
assert "resume" not in done and L.said.count("Can I go on with my task?") == 1, (done, L.said)
# 16:58:25 / 16:58:41 "Let's follow me." from #27 (the owner again, a new track): the paused mission is ended
# with one line, the command then taken as usual
L = halted(fresh(current=Track(27, OWNER)))
assert L.mission_talk("Let's follow me.") is False and "end" in done, done
assert L.said == ["Okay, I've stopped my task."] and not L.mission_running(), L.said
# 16:58:59 "Come to me." by voice only (nobody in view) on a paused mission: also taken
L = halted(fresh(current=None))
assert L.mission_talk("Come to me.") is False and "end" in done, done
# the same person on a new track while it runs: taken
L = fresh(current=Track(24, OWNER))
assert L.mission_talk("Lumi, come to me") is False and "end" in done, done
# anyone else, while it runs or paused, also on a delivery for James: the task ends with one line, the command is done
for steps_, p in ((BACK, False), (BACK, True), (DELIVERY, False), (DELIVERY, True)):
L = fresh(steps_, current=Track(30, OTHER))
if p:
halted(L)
assert L.mission_talk("Lumi, take me to p2") is False and "end" in done, (steps_, p, done)
assert L.said == ["Okay, I've stopped my task."] and not any("doing a task" in x for x in L.said), L.said
# 16:59:07 dashboard cancel on the paused mission: it ends (it went on again at 16:59:39)
L = halted(fresh())
L.cmd_id = 0
fd, lumi.CMD_FILE = tempfile.mkstemp(suffix=".json")
with os.fdopen(fd, "w") as f:
json.dump({"id": 1, "time": time.time(), "cmd": "cancel"}, f)
L.poll_commands()
os.remove(lumi.CMD_FILE)
assert "stop" in done and run["status"] == "stopped" and L.mission_hold is None, done
# 16:56:38 "One more." right after "look left": further left; also "a bit more", "더", after a lift
class Brain:
def __init__(self, last):
self.history = [("before", last)]
looked = []
for said, last, want in (("One more.", "ACTION: look left\nOkay, I am looking to the left.", ("look", "left small")),
("a bit more", "ACTION: look right\nOkay.", ("look", "right small")),
("조금 더", "ACTION: look up\n네.", ("look", "up small")),
("one more", "ACTION: look left small", ("look", "left small")),
("again", "ACTION: lift up\nOkay.", ("lift", "up small"))):
for paused in (False, True):
if paused and want[0] == "lift":
continue # the lift is not moved on a mission
L = halted(fresh()) if paused else fresh()
if not paused:
run["status"] = "idle"
L.brain = Brain(last)
L.look = lambda target: looked.append(("look", target))
L.lift = lambda target: looked.append(("lift", target)) and False
looked.clear()
assert L.drive_words(said) and looked == [want], (said, paused, looked)
print("mission stop ok")
+6 -9
View File
@@ -14,6 +14,7 @@ fetch.pause = lambda: (done.append("pause"), run.update(paused=True), True)[-1]
fetch.paused = lambda: run["paused"]
fetch.resume = lambda: (done.append("resume"), run.update(paused=False))
fetch.stop = lambda: done.append("stop")
fetch.end = lambda timeout=5.0: done.append("end")
fetch.replace = lambda steps, say=None: done.append(("replace", steps))
lumi.brain_mod.intent.__globals__ # the real rules
@@ -38,18 +39,18 @@ assert talk(L, "the weather is nice today")[0] and not done and not L.said
L = fresh()
ok, said = talk(L, "Hi Lumi!")
assert ok and done == ["pause"] and "How can I help you" in said, (done, said)
ok, said = talk(L, "go to p3") # a stranger's task: refused
assert ok and "doing a task for someone" in said and not any(isinstance(d, tuple) for d in done), said
ok, said = talk(L, "what are you doing?") # a question: answered as usual
assert not ok
ok, said = talk(L, "okay, you can go")
assert ok and done[-1] == "resume" and L.mission_hold is None, done
ok, said = talk(L, "go to p3") # anyone's new task: the mission ends with one line, then it is done
assert ok is False and done[-1] == "end" and said == "Okay, I've stopped my task.", (done, said)
L = fresh()
ok, said = talk(L, "Lumi, I'm James, give it to me") # the person it is for
assert ok and done[-1] == ("replace", [{"do": "give", "person": "James"}]) and "James" in said, (done, said)
L = fresh()
ok, said = talk(L, "Lumi, I'm Tom, give it to me")
assert ok and "this is for James" in said and not any(isinstance(d, tuple) for d in done), (done, said)
ok, said = talk(L, "Lumi, I'm Tom, give it to me") # done for Tom, as anyone's
assert ok is False and done[-1] == "end", (done, said)
L = fresh()
ok, said = talk(L, "Hey Lumi, I'm James. Take it to p3 and put it on the table")
assert ok and done[-1] == ("replace", [{"do": "go", "to": "p3"}, {"do": "place", "on": {"name": "dining table",
@@ -72,11 +73,7 @@ L.mission_wait()
assert L.said[-1] == "Can I go on with my task?" and "resume" not in done
L.last_activity -= 100
L.mission_wait()
assert done[-1] == "resume", done
L = fresh()
talk(L, "Lumi, stop")
ok, said = talk(L, "can you take me to p2?")
assert "doing a task for someone" in said, said
assert "resume" not in done, done # never goes on by itself
L = fresh()
ok, said = talk(L, "루미야, 제가 제임스예요") # 제임스 is not matched to "James" (another script): nothing given
assert not any(isinstance(d, tuple) for d in done) and "this is for James" not in said, (done, said)
+3 -2
View File
@@ -17,6 +17,7 @@ fetch.pause = lambda: (done.append("pause"), True)[-1]
fetch.paused = lambda: "pause" in done and "resume" not in done
fetch.resume = lambda: done.append("resume")
fetch.stop = lambda: done.append("stop")
fetch.end = lambda timeout=5.0: done.append("end")
fetch.proceed = lambda: done.append("proceed")
fetch.release_now = lambda: done.append("release")
fetch.instruct = lambda steps: done.append(("instruct", steps))
@@ -53,10 +54,10 @@ assert L.mission_talk("go to the kitchen and dance") and "didn't understand" in
L = fresh(ORDER)
assert not L.mission_talk("what are you doing?") # a question: answered as usual
assert L.now_doing()[0] == "I'm waiting at p6 for an instruction.", L.now_doing()
# a mission waiting for go on / a time: someone else's task is still refused; "go on" ends the wait
# a mission waiting for go on / a time: anyone's new task ends it with one line (then it is done); "go on" ends the wait
for w in ({"at": "exit", "for": "go on", "end": None}, {"at": "p3", "for": "time", "end": time.time() + 25}):
L = fresh(w)
assert L.mission_talk("Lumi, take me to p2") and "doing a task for someone" in L.said[-1], L.said
assert L.mission_talk("Lumi, take me to p2") is False and "end" in done and "stopped my task" in L.said[-1], L.said
L = fresh(w)
assert L.mission_talk("okay, you can go now") and "proceed" in done and done[-1] == "resume", done
L = fresh({"at": "exit", "for": "go on", "end": None}, step="waiting at exit")