Conversation and web: closings by context, follow-up lookups keep the name and place, office holders and prices looked up; reach toward the person; bottles by their body (belly grasp only); music never a turn (speech detector); songs: a promise is done; two-stop drives in the Command box

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 14:07:56 +09:00
co-authored by Claude Opus 5.5
parent 9cd8e5706b
commit 88a5349b04
34 changed files with 838 additions and 491 deletions
+86 -13
View File
@@ -158,6 +158,17 @@ ARM_TASKS = {"pick", "put", "move_object", "fetch", "give", "place", "receive",
def needs_arm(action, target=""):
"""The action moves the arm (the gripper alone, open / close, does not ask for it)."""
return action in ARM_TASKS or action == "arm" and target not in ("open", "close")
def reach_turn(angle, patrol):
"""Base turn (deg, + left) before "reach out to me" to a person at the waist-frame `angle` (None: nobody seen or
heard): 0 within REACH_FRONT_DEG of the front, the angle with Patrol on, else None (they are asked to stand in
front: Greeter never turns the base or the waist)."""
if angle is None:
return None
if abs(angle) <= REACH_FRONT_DEG:
return 0.0
return float(angle) if patrol else None
LIFT_VEL = 20 # speed ratio % for a lift move asked by voice (head.VEL is 40)
LIMIT_SAY = {"yaw": (f"I can turn my head up to {head.AXIS_LIMITS[2][1]:g} degrees each way.",
f"고개는 좌우로 {head.AXIS_LIMITS[2][1]:g}도까지 돌릴 수 있어요."),
@@ -225,7 +236,7 @@ CLEAR_BYE = re.compile(r"\b(?:bye|bay bay|goodbye|(?<!can't )(?<!cant )(?<!canno
r"take care|i (?:have|need) to go|gotta (?:go|run)|i'?m leaving|i'?m off|have a (?:good|nice|great) (?:one|day)|"
r"nice (?:talking|meeting|chatting)(?: (?:to|with))? you|(?:was|been) nice to meet you)\b|"
r"(?<=\S)[\s.,!]+안녕[\s.!~]*$|안녕히|잘 ?가|잘 ?있어|잘 ?있게|수고하세요|들어가세요|바이바이|빠이|"
r"(?<![가-힣])바이(?![가-힣])|(?<![가-힣])간다[\s.!~]*$|가 ?볼게요|갈게요|가야 ?(?:돼|해|겠|할)|"
r"(?<![가-힣])바이(?![가-힣])|(?<![가-힣])간다[\s.!~]*$|가 ?볼게요|갈게요|(?:나|저|이제) (?:이제 )?가야 ?(?:돼|해|겠|할)|"
r"다음에 (?:또 )?(?:봐|봬|만나|올게)|또 (?:봐|봬|올게)|나중에 봐|좋은 하루|"
r"(^|\s)(나|저|우리|저희) (이제 )?(집에 )?(가|간다|가요|갑니다)[\s.!]*$", re.I)
# a goodbye in any talk: "okay, bye", "I have to go", "수고하세요" (thanks, okay, 됐어: the LLM reads them)
@@ -277,7 +288,10 @@ DOA_MIN_CONF = 0.12 # below this the sound direction is not trust
COME_STOP = 1.1 # m; driving to a person stops when the camera sees them this close
COME_TIMEOUT = 60.0 # s
MAX_MOVE_M = 3.0 # m; "move forward N metres" is limited to this
ARM_REACH_PROGRAM = "arm_reach.jks" # Cobo π program for "reach out your hand" (to be recorded on the robot)
REACH_FRONT_DEG = 20.0 # deg; "reach out to me": a person further to the side than this is turned to first
# (Patrol) or asked to stand in front (Greeter). Estimate: the reach after give
# moves at most fetch.RECEIVE_REACH_MM sideways
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
STUCK_DRIVE_S = 20.0 # s "running" without moving -> the drive is cancelled and Lumi says so
MODES_FILE = "/dev/shm/lumi_modes.json" # written by api/server.py: {"greeter", "patrol", "wave", "drive"}
CMD_FILE = "/dev/shm/lumi_cmd.json" # written by api/server.py: {"id", "cmd": go | go_point | cancel | calibrate
@@ -1624,29 +1638,67 @@ class Lumi:
self.keep_listening()
def arm_pose(self, target):
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once), only from look; 'fold': to look along the
pose graph (arm_route, checked first, moved in the background); 'open' / 'close': the gripper. True when
"""'reach': the hand out to the person (reach_out); 'fold': to look along the pose graph (arm_route, checked
first, moved in the background); 'open' / 'close': the gripper, never opened on something held. True when
started, False when not learned, None when refused (the reason is said)."""
from tasks import fetch
held = target in ("reach", "open") and (self.fetch_status() == "holding" or bool(safe(fetch.check_hand)))
if target == "open" and held: # the model's "let go" while holding: it would fall
log(" open refused: holding something")
self.fetch_say(*brain_mod.REFUSE_OPEN)
return None
if target in ("open", "close"):
st = safe(gripper.open_ if target == "open" else gripper.close)
log(f" gripper {target}: {st}")
return st is not None
if target == "reach":
return self.reach_out(held)
try:
if target == "fold":
holding = self.fetch_status() == "holding"
seq = arm_route.plan(arm_route.HOME, holding=holding)
threading.Thread(target=safe, args=(arm_route.move, seq, None, holding), daemon=True).start()
else:
arm_route.start_program(ARM_REACH_PROGRAM)
holding = self.fetch_status() == "holding"
seq = arm_route.plan(arm_route.HOME, holding=holding)
threading.Thread(target=safe, args=(arm_route.move, seq, None, holding), daemon=True).start()
return True
except arm_route.RouteError as e:
log(f" arm {target} refused: {e.args[0]}")
self.fetch_say(*e.args)
return None
except Exception as e:
log(f" arm {target}: {e}" + (f" (record {ARM_REACH_PROGRAM} in Cobo pi)" if target == "reach" else ""))
log(f" arm {target}: {e}")
return False
def reach_out(self, held):
""""Reach out to me", "give me your hand", "손 내밀어": something in the hand = hand it over. Else toward the
person (the tracked one, else the one the voice came from, else the voice's direction): the head turns to
them; further to the side than REACH_FRONT_DEG the base turns first with Patrol on, Greeter asks them to stand
in front (reach_turn); then fetch.reach (give pose along the graph, a short checked move toward their hand).
True when started, None when refused or handed over (said)."""
from tasks import fetch
if held:
self.fetch_finish("give")
return None
if self.skill_thread is not None and self.skill_thread.is_alive():
self.fetch_say("I'm still busy with my arm.", "아직 팔로 하는 일이 있어요.")
return None
track = None
if self.vision:
track = self.current if self.current and self.vision.present(self.current) else \
self.vision.near_angle(self.voice_angle) if self.voice_trusted else self.vision.only_person()
angle = track.angle if track else self.voice_angle if self.voice_trusted else None
turn = reach_turn(angle, self.modes.patrol)
log(f" reach: person at {'?' if angle is None else f'{angle:+.0f}'} deg, base turn {turn}")
if turn is None:
self.fetch_say(*STAND_IN_FRONT_SAY)
return None
self.turn_head(0 if turn else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)))
self.stay()
try:
fetch.reach(turn, say=self.fetch_say)
except fetch.FetchError as e:
log(f" reach refused: {e}")
self.fetch_say(e.args[0], e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
return None
return True
# ---------- dashboard commands, trips ----------
def poll_commands(self):
try:
@@ -1894,7 +1946,7 @@ class Lumi:
if not text or self.interrupted():
if not self.interrupted():
log(f" heard nothing (mic noise {ears.last.get('noise')}, threshold {ears.last.get('threshold')}, "
f"loudest {ears.last.get('peak')})")
f"loudest {ears.last.get('peak')}{', ' + ears.last_stt['dropped'] if ears.last_stt.get('dropped') else ''})")
return False
self.who_spoke(u)
self.answer(text)
@@ -2305,6 +2357,14 @@ class Lumi:
self.act(head_["action"], head_["target"])
first = next(gen, None)
log(f" first sentence after {time.time() - t:.1f} s")
promise = brain_mod.promised(first) if head_["action"] == "none" else None
if promise == "sing" or promise == "wave" and not self.arm_off(): # the reply says it: Lumi does it
log(f" the reply promises {promise}: done")
if promise == "sing":
gen.close()
self.sing_song(text)
return
self.act("wave", "")
if head_["action"] in ("none", "sing") and not repeating and look_up_unsure(about, first, text):
gen.close() # the model does not know: look it up instead
log(f" not sure ({first[:60]!r}) - looking it up")
@@ -2312,6 +2372,8 @@ class Lumi:
return
said = mouth.say_stream(itertools.chain([first] if first else [], gen), abort=self.speak_abort)
log(f"lumi ({time.time() - t:.1f} s, voice after {mouth.last_voice - t:.1f} s): {said}")
if head_["action"] == "end" and fate == "close" and not kept_goodbye(said):
head_["action"] = "none" # "Okay, thanks." -> "You're welcome.": no goodbye said
if head_["action"] in ("end", "go_to"):
self.current, self.voice_until = None, 0.0 # stay quiet with this person until a new visit
elif self.current is None:
@@ -2696,7 +2758,7 @@ def talk_fate(text):
return "end"
if brain_mod.is_closing(text) and (THANKS.search(text) or not brain_mod.UNDERSTOOD.search(text)) or \
THANKS.search(text) and not THANKS_REST.sub("", THANKS.sub("", text)) or \
DONE_WORDS.search(text) and not ASKS_MORE.search(text) and len(text.split()) <= 8:
DONE_WORDS.search(text) and not ASKS_MORE.search(text) and len(text.split()) <= 8 and not brain_mod.intent(text):
return "close" # "Thanks a bunch.", "Okay, I think that's everything."
return "talk"
@@ -2737,6 +2799,17 @@ def not_online(text):
OUTSIDE_NAME.search(text)))
SAID_BYE = re.compile(r"\b(?:bye|goodbye|see you|take care|have a (?:good|nice|great|lovely) (?:day|one|time|visit)|enjoy (?:the|your)|"
r"next time|come again|good luck)\b|안녕히|다음에|또 (?:봐|봬|만나|오세요|뵙)|좋은 하루|즐거운|조심히|들어가세요",
re.I) # Lumi's own words take leave
def kept_goodbye(said):
"""The model ended the talk on a closing word ("okay", "thanks"): only when its words said goodbye; "You're
welcome." alone keeps the talk open (silence then ends it)."""
return bool(SAID_BYE.search(said or ""))
def lookup_refused(brain, target, about, text=""):
"""not_online for the model's lookup: right after a lookup the words go with the question looked up ("How much
is a ticket?" after Lotte World), Cutshion never goes online."""