Follow me: steady 10 Hz control with prediction between sightings, one kept-open base connection, head tracks on its own thread, the followed person kept by position and clothes; Lumi: no fate error, cut-off sentences joined, no promise without its action, song bank only on song words
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-1
@@ -1398,13 +1398,23 @@ PROMISE = { # Lumi's own sentence saying it does this now ("Okay! I'll sing a
|
||||
"sing": re.compile(r"\b(?:i'll|i will|let me|i'm going to) sing\b|\bhere(?:'s| is| comes| goes) (?:a |my |one |the )?song\b|"
|
||||
r"(?:불러|들려)\s*(?:드릴게요|드리겠습니다|줄게|볼게요)|부를게요", re.I),
|
||||
"wave": re.compile(r"\b(?:i'll|i will|let me) wave\b|흔들어\s*(?:드릴게요|볼게요|줄게)|흔들게요", re.I),
|
||||
# any other motion: never done on the reply alone (the action line said none), lumi.answer() asks instead
|
||||
"motion": re.compile(r"\b(?:i'll|i will|let me|i'm going to|i am going to)\s+(?:now\s+)?(?:follow|come|go(?! ahead)|drive|"
|
||||
r"head (?:to|over|back)|move|turn (?:around|left|right|to)|look (?:at|left|right|down|around|behind)|"
|
||||
r"pick|grab|bring|fetch|lift|raise|lower|reach out)\b|"
|
||||
r"\b(?:i'm|i am) (?:coming|following|on my way)\b|\bhere i come\b|"
|
||||
r"따라\s*(?:갈게요|가\s*볼게요|갈게|가겠습니다)|(?<![가-힣])(?:갈게요|가겠습니다|올게요|갈게)|가져다\s*드릴게요|"
|
||||
r"가져올게요|집어\s*(?:드릴게요|볼게요)|집을게요|돌게요|돌아\s*(?:볼게요|갈게요)|쳐다\s*볼게요|"
|
||||
r"움직일게요|올릴게요|내릴게요|건네\s*드릴게요|내려\s*놓을게요", re.I),
|
||||
}
|
||||
NOT_NOW = re.compile(r"\b(?:if|when|later|after|once|next time)\b|나중에|끝나면|으면|다면", re.I) # "... if you'd like"
|
||||
|
||||
|
||||
def promised(sentence):
|
||||
"""'sing' / 'wave' when Lumi's sentence says it does that now, else None: lumi.answer() then does it although the
|
||||
model's action line was none ("Start with one." -> "Okay! I'll sing a song for you." and silence, 2026-10-22)."""
|
||||
model's action line was none ("Start with one." -> "Okay! I'll sing a song for you." and silence, 2026-10-22).
|
||||
'motion' for any other move it says it makes ("Yeah." -> "Okay, I'll follow you!" and no follow, 2026-10-22):
|
||||
not done on a guess, Lumi asks what to do."""
|
||||
s = sentence or ""
|
||||
return None if NOT_NOW.search(s) else next((a for a, r in PROMISE.items() if r.search(s)), None)
|
||||
LOOK_MORE = re.compile(r"^\W*(?:and|now|then|and now)?\s*(up|down|left|right)\W*$|"
|
||||
|
||||
+21
-8
@@ -107,7 +107,9 @@ LOST_S = 2.0 # s not seen -> the person is gone (detection
|
||||
PROMPT_S = 12.0 # s of silence before "How can I help you?"
|
||||
MAX_PROMPTS = 2
|
||||
TOO_CLOSE = 0.45 # m, a running wave is stopped
|
||||
MATCH_DEG = 12.0 # a detection belongs to the track with the closest angle within this
|
||||
MATCH_DEG = 12.0 # a detection belongs to the track with the closest angle within this ...
|
||||
MATCH_DEG_PER_M = 10.0 # ... where each m of distance difference counts as this many deg: two people at
|
||||
# about the same angle (one passing the followed person) keep their own tracks (estimate)
|
||||
OCCLUSION_DROP = 0.3 # m; while the arm moves, a sudden drop in distance is the arm in front of
|
||||
# the person, not the person moving: ignore it
|
||||
CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE only if the box is this tall (frame part)
|
||||
@@ -450,7 +452,8 @@ class Vision(threading.Thread):
|
||||
with self.lock:
|
||||
free = list(self.tracks)
|
||||
for p in sorted(people, key=lambda p: p["distance_m"]):
|
||||
best = min(free, default=None, key=lambda t: abs(t.angle - p["angle_deg"]))
|
||||
best = min(free, default=None, key=lambda t: abs(t.angle - p["angle_deg"])
|
||||
+ MATCH_DEG_PER_M * abs(t.distance - p["distance_m"]))
|
||||
if best and abs(best.angle - p["angle_deg"]) < MATCH_DEG:
|
||||
best.update(p, now, self.arm_watch, self.near_max)
|
||||
free.remove(best)
|
||||
@@ -541,15 +544,16 @@ class Vision(threading.Thread):
|
||||
return min(here, key=lambda t: t.distance, default=None)
|
||||
|
||||
def follow_view(self, track):
|
||||
"""(distance m, angle deg, age s) of the person being followed (tasks/follow.py), None once the track is
|
||||
gone. The distance is the nearer of the median and the newest reading: the median lags when they stop."""
|
||||
"""(distance m, angle deg, age s, clothes signature or None) of the person being followed (tasks/follow.py),
|
||||
None once the track is gone. The distance is the nearer of the median and the newest reading: the median lags
|
||||
when they stop."""
|
||||
with self.lock:
|
||||
if track not in self.tracks:
|
||||
return None
|
||||
return min(track.distance, track.history[-1]), track.angle, time.time() - track.last_seen
|
||||
return min(track.distance, track.history[-1]), track.angle, time.time() - track.last_seen, track.look
|
||||
|
||||
def follow_views(self):
|
||||
"""[(see, distance m, angle deg, age s)] of everyone in view: tasks/follow.py re-locks onto one of them."""
|
||||
"""[(see, distance m, angle deg, age s, look)] of everyone in view: tasks/follow.py re-locks onto one of them."""
|
||||
with self.lock:
|
||||
tracks = list(self.tracks)
|
||||
return [(lambda t=t: self.follow_view(t),) + v for t in tracks if (v := self.follow_view(t))]
|
||||
@@ -2302,6 +2306,7 @@ class Lumi:
|
||||
return
|
||||
# fate "close" ("okay", "thanks", "됐어요"): the LLM below reads it with the talk before (its action end ends
|
||||
# the talk); when the talk goes on, silence ends it (closing_pending, set after the reply)
|
||||
fate = talk_fate(text)
|
||||
if kind == "sing": # "sing a song", "노래 불러 줘", after a song "another one"
|
||||
self.sing_song(text)
|
||||
return
|
||||
@@ -2388,6 +2393,14 @@ class Lumi:
|
||||
self.sing_song(text)
|
||||
return
|
||||
self.act("wave", "")
|
||||
if promise == "motion": # "Okay, I'll follow you!" under the action none: ask
|
||||
gen.close()
|
||||
log(f" the reply promises a move the action line did not ({first[:60]!r}): asked")
|
||||
say = "Sorry, what would you like me to do?" if self.lang == "en" else "죄송해요, 무엇을 해 드릴까요?"
|
||||
self.brain.history.append((text, f"ACTION: none -\n{say}"))
|
||||
mouth.say(say)
|
||||
self.keep_listening()
|
||||
return
|
||||
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")
|
||||
@@ -2636,7 +2649,7 @@ class Lumi:
|
||||
|
||||
if self.current and not self.vision.present(self.current):
|
||||
log(f"person #{self.current.id} left - stop talking")
|
||||
self.current = self.vision.nearest_greeted() # someone else still here?
|
||||
self.current = None if following else self.vision.nearest_greeted() # someone else still here?
|
||||
if self.current:
|
||||
self.turn_head(HEAD_SIGN * self.current.angle)
|
||||
else:
|
||||
@@ -2678,7 +2691,7 @@ class Lumi:
|
||||
|
||||
if self.talk_turn():
|
||||
self.last_activity, self.prompts = time.time(), 0
|
||||
elif (not self.interrupted() and time.time() - self.last_activity > PROMPT_S and self.prompts < MAX_PROMPTS):
|
||||
elif (not following and not self.interrupted() and time.time() - self.last_activity > PROMPT_S and self.prompts < MAX_PROMPTS):
|
||||
log(f"silent for {PROMPT_S:.0f} s - prompt")
|
||||
mouth.say(PROMPT[self.lang], abort=self.interrupted)
|
||||
self.last_activity, self.prompts = time.time(), self.prompts + 1
|
||||
|
||||
@@ -358,6 +358,9 @@ LIST = [
|
||||
]
|
||||
|
||||
NO = [
|
||||
# cut-off starts (whisper heard only the beginning): never a song
|
||||
"let's", "let's go", "can you", "could you", "please", "can you please", "lumi, can you", "wait", "hmm", "so",
|
||||
"루미야 저기", "저기요", "루미야", "혹시", "그럼", "잠깐만", "있잖아",
|
||||
# liking music, favourites
|
||||
"do you like singing?",
|
||||
"do you like music?",
|
||||
|
||||
Reference in New Issue
Block a user