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:
+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
|
||||
|
||||
Reference in New Issue
Block a user