From b4ab7c71b14056e096ea4ec2a583ba4c33195d3a Mon Sep 17 00:00:00 2001 From: Cutshion Date: Fri, 30 Oct 2026 18:22:45 +0900 Subject: [PATCH] Turn to the caller while answering and turn the waist faster Co-Authored-By: Claude Opus 5.5 --- assistant/lumi.py | 17 ++++++++++++----- audio/mouth.py | 4 +++- docs/TUNING.md | 1 + tasks/fetch.py | 2 +- tasks/follow.py | 2 +- tests/blind_check.py | 2 +- tests/test_wake.py | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/assistant/lumi.py b/assistant/lumi.py index 655ae32..08372f6 100644 --- a/assistant/lumi.py +++ b/assistant/lumi.py @@ -131,7 +131,9 @@ WAKE = re.compile(rf"\b(hi|hey|hello|okay|ok|hai|high|{WAKE_UP_EN})?[\s,.!]*(lum 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": "네? 무엇을 도와드릴까요?"} +WAKE_REPLY = {"en": ["Yes? How can I help?", "I'm here. How can I help?", "Yes, I'm listening.", "Hi! What can I do for you?"], + "ko": ["네? 무엇을 도와드릴까요?", "네, 말씀하세요.", "네, 듣고 있어요.", "안녕하세요! 무엇을 도와드릴까요?"]} # one at random +NAME_REPLY = {"en": ["Yes?", "I'm listening.", "Yes, I'm here."], "ko": ["네?", "네, 말씀하세요.", "네, 듣고 있어요."]} # "Lumi?" in a talk NAME_ONLY = re.compile(r"^\s*(?:(?:hi|hey|hello|헤이|하이)[\s,]+)?(?:lumi|loomi|rumi|루미|누미)(?:야|아)?[\s,.!?~]*$", re.I) # ^ only the name, also "루미야" / "헤이 루미" (went to the LLM: "안녕하세요! 제 이름 불러 주셔서 기뻐요." after 2.3 s) 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|" @@ -3093,8 +3095,11 @@ class Lumi: return if self.resume_stopped(text): # "Lumi, keep going" after a stop word ended a mission return - if NAME_ONLY.match(text): # just "Lumi?": they want attention - mouth.say("Yes?" if self.lang == "en" else "네?") + 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"])) + look.join() self.keep_listening() return from tasks import fetch # the way it goes: route(), as the dashboard's Command box @@ -3334,9 +3339,11 @@ class Lumi: self.brain.reset() self.closing_pending = None command = rest if len(rest) > 2 else text if re.search(r"how are you", text, re.I) else "" # answered - self.look_at_speaker() # as "look at me": the cameras, the voice's side, behind + 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(WAKE_REPLY[lang]) + mouth.say(random.choice(WAKE_REPLY[lang])) + look.join() self.voice_until = time.time() + VOICE_SESSION_S self.last_activity, self.prompts = time.time(), 0 if command: # "Hi Lumi, go home": do it at once, no greeting diff --git a/audio/mouth.py b/audio/mouth.py index f6c6196..edac111 100644 --- a/audio/mouth.py +++ b/audio/mouth.py @@ -42,7 +42,9 @@ CACHED = ["Hi, I'm Lumi, the assistant robot. How can I help you?", "안녕하 "Sorry, I can't get closer from here.", "How can I help you?", "무엇을 도와드릴까요?", "Let me check.", "확인해 볼게요.", "Okay, I'll be quiet.", "네, 조용히 할게요.", "Sorry, I'm not connected to the internet right now, so I can't look that up.", - "Yes? How can I help?", "네? 무엇을 도와드릴까요?", + "Yes? How can I help?", "네? 무엇을 도와드릴까요?", "I'm here. How can I help?", "Yes, I'm listening.", + "Hi! What can I do for you?", "네, 말씀하세요.", "네, 듣고 있어요.", "안녕하세요! 무엇을 도와드릴까요?", + "I'm listening.", "Yes, I'm here.", "Welcome back! How can I help you?", "다시 오셨네요, 무엇을 도와드릴까요?", "Okay, I'm going to my charging dock.", "네, 충전소로 갈게요."] + [f"Okay, I'm going to p{i}." for i in range(1, 11)] _tts = None diff --git a/docs/TUNING.md b/docs/TUNING.md index 5b0060c..4e4fbd3 100644 --- a/docs/TUNING.md +++ b/docs/TUNING.md @@ -76,6 +76,7 @@ Every value here is a constant at the top of its file, with a comment on what it | File | Name | Default | What it does | |---|---|---|---| | `tasks/fetch.py` | `VIEW_STEPS` | 60°, 120°, 180° | Search: after ahead, both cameras look this far to the busier side step by step, then to the other side | +| `tasks/fetch.py` | `WAIST_VEL` | 30 % | Speed of the waist's turns (search, reach, "look at me", turning to a caller); the arm sweeps sideways with it, so it stays low | | `tasks/fetch.py` | `WAIST_SCAN_MAX` | 120° | The waist turns up to this in the search (body limit ±140° absolute), the head turns the rest | | `tasks/fetch.py` | `SEARCH_BASE_DEG` | 180°, 90° | Then the base turns towards the busier side, the first of these whose sweep is clear, and all again | | `tasks/fetch.py` | `LIFT_TRIES` | 0, 105 mm (`LIFT_RANGE`) | Nothing found: all of it again at the other end | diff --git a/tasks/fetch.py b/tasks/fetch.py index 99544fd..cae3017 100644 --- a/tasks/fetch.py +++ b/tasks/fetch.py @@ -150,7 +150,7 @@ HEAD_SIDE_DEG = 60.0 # head yaw (+ left) towards the side of a turn, to HEAD_LOW_PITCH = -5.0 # head pitch for those checks and the search: its lowest, where the camera is calibrated HEAD_READS = 4 # head camera frames read per view (10 a second) ... HEAD_SAME_MM = 120.0 # ... an object counts when seen at least twice within this distance -WAIST_VEL = 20 # % of the waist's speed: the arm sweeps sideways +WAIST_VEL = 30 # % of the waist's speed: the arm sweeps sideways WAIST_STEP_DEG = 10.0 # deg; a waist turn made together with an arm move goes in moves this long: the body API # cannot stop a moveto, so a STOP ends the turn after the move it is in (_give_turning) HEAD_AHEAD = (0.0, head.HEAD_REST_PITCH) # head (yaw, pitch) deg before a drive to a place and after every task: ahead, at rest diff --git a/tasks/follow.py b/tasks/follow.py index 0951db2..501376f 100644 --- a/tasks/follow.py +++ b/tasks/follow.py @@ -68,7 +68,7 @@ WAIST_STEP_DEG = 8.0 # deg; one body move turns the waist at most this fa WAIST_FOLLOW_VEL = 50 # speed ratio % of a move that turns the waist (the head in it too). The waist's deg/s at # this ratio is not measured; estimate ~40 deg/s as the head's (audio/sing.py), about the # base's own TURN_MAX_RS turn that sweeps the arm the same way. Lower it if the arm swings - # too hard (fetch.WAIST_VEL 20 is the search's long turns) + # too hard (fetch.WAIST_VEL 30 is the search's long turns) WAIST_DRIVE_DEG = 15.0 # deg; the base drives forward only with the waist this near the front: navigation does not # know the arm, blocked() checks it turned (estimate) WAIST_RETRY_S = 1.0 # s; a waist turn found blocked is not tried again for this long (each try probes the map) diff --git a/tests/blind_check.py b/tests/blind_check.py index db5e55a..4f702f0 100644 --- a/tests/blind_check.py +++ b/tests/blind_check.py @@ -619,7 +619,7 @@ def score_silence(c, old, use_llm): outcome, said = "silent", "" else: rest = text[m.end():].strip(" ,.!?") - outcome, said, text = ("greet", lumi.WAKE_REPLY["en"], "") if len(rest) <= 2 else ("talk", "", rest) + outcome, said, text = ("greet", lumi.WAKE_REPLY["en"][0], "") if len(rest) <= 2 else ("talk", "", rest) else: outcome, said = "talk", "" with mock.patch.object(lumi.mouth, "recent_speech", lambda s=30.0: x["lumi_said"] or ""): diff --git a/tests/test_wake.py b/tests/test_wake.py index 25b5e10..e1b053b 100644 --- a/tests/test_wake.py +++ b/tests/test_wake.py @@ -141,7 +141,7 @@ assert not lumi.WAKE.search("I wake up at 7 every day") and not lumi.WAKE.search L = fresh() # "How are you?" is answered, not "Yes? How can I help?" L.mic = Mic(U("How are you?")) L.check_wake() -assert ("answer", "How are you?") in done and lumi.WAKE_REPLY["en"] not in said(), done +assert ("answer", "How are you?") in done and not set(lumi.WAKE_REPLY["en"]) & set(said()), done L = fresh() # "Hi Lumi, go home": done at once L.mic = Mic(U("Hi Lumi, go home.")) L.check_wake()