Search toward an unsure voice first and find far callers on look at me
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+26
-20
@@ -386,6 +386,7 @@ FOCUS_REFIND_DEG = 15.0 # a lost track's person is found again as the
|
||||
LOOK_ME_PITCH = 0.0 # deg, head pitch of the first turn to a person ("look at me"): level, a far person
|
||||
# fits whole; the head camera then tilts it to their height (look_me_pitch)
|
||||
LOOK_ME_SETTLE_S = 0.6 # s after a head move before its camera is asked who is there
|
||||
LOOK_ME_MAX_M = 6.0 # m; "look at me" finds callers up to this far (others count only within STAY_MAX)
|
||||
LOOK_ME_TOP_ROW = 0.08 # share of the image height from the top where the person's head should be
|
||||
LOOK_ME_EDGE_PX = 8 # a box edge this near the frame edge is cut by it
|
||||
LOOK_ME_UP_STEP = 10.0 # deg up when the person's head is cut by the frame top (how much is cut is unknown)
|
||||
@@ -689,18 +690,19 @@ class Vision(threading.Thread):
|
||||
best = min(self.tracks, default=None, key=lambda t: abs(t.angle - angle))
|
||||
return best if best is not None and abs(best.angle - angle) <= max_diff else None
|
||||
|
||||
def seen(self):
|
||||
"""Everyone in view as (waist-frame angle, distance): this camera's people and, while the head camera is in
|
||||
use, the torso camera's fresh ones too (someone beside Lumi is often outside the turned head camera's view)."""
|
||||
def seen(self, max_m=STAY_MAX):
|
||||
"""Everyone in view as (waist-frame angle, distance) up to max_m: this camera's people and, while the head
|
||||
camera is in use, the torso camera's fresh ones too (someone beside Lumi is often outside the turned head
|
||||
camera's view)."""
|
||||
with self.lock:
|
||||
out = [(t.angle, t.distance) for t in self.tracks if t.distance <= STAY_MAX]
|
||||
out = [(t.angle, t.distance) for t in self.tracks if t.distance <= max_m]
|
||||
if self.camera != "torso":
|
||||
camview.want("torso")
|
||||
try:
|
||||
d = json.loads(camview.det_path("torso").read_text())
|
||||
if time.time() - d["time"] <= TORSO_FRESH_S:
|
||||
out += [(p["angle_deg"], p["distance_m"]) for p in d["people"]
|
||||
if p["distance_m"] is not None and p["distance_m"] <= STAY_MAX]
|
||||
if p["distance_m"] is not None and p["distance_m"] <= max_m]
|
||||
except (FileNotFoundError, ValueError, KeyError):
|
||||
pass
|
||||
return out
|
||||
@@ -1133,14 +1135,14 @@ class Lumi:
|
||||
self.fetch_finish(action)
|
||||
|
||||
def look_at_speaker(self):
|
||||
""""Look at me": the cameras first, the voice direction only to choose. Someone seen (both cameras): the one
|
||||
near the voice, else the person talked with, else the one nearest where the head looks; the body never turns
|
||||
then (a sure voice read 90 deg off in the median and put a person in front behind, 2026-10-28/29, so a repeat
|
||||
"look at me" flipped the base from side to side). Nobody seen: the head sweeps the voice's side, then the
|
||||
other side; nobody there either and a sure voice past the head's reach: the body turns to it (turn_body_to)
|
||||
and the head looks there. Then the head tilts until the head camera sees the person from their head down
|
||||
(look_me_pitch). That person becomes the one talked with, and while the look is held the head follows them
|
||||
(look_me, keep_focus)."""
|
||||
""""Look at me": the cameras first, the voice direction only to choose. Someone seen (both cameras, up to
|
||||
LOOK_ME_MAX_M): the one near the voice, else the person talked with, else the one nearest where the head
|
||||
looks; the body never turns then (a sure voice read 90 deg off in the median and put a person in front
|
||||
behind, 2026-10-28/29, so a repeat "look at me" flipped the base from side to side). Nobody seen: the head
|
||||
sweeps the voice's side (sure or not), then the other side; nobody there either and a sure voice past the
|
||||
head's reach: the body turns to it (turn_body_to) and the head looks there. Then the head tilts until the
|
||||
head camera sees the person from their head down (look_me_pitch). That person becomes the one talked with,
|
||||
and while the look is held the head follows them (look_me, keep_focus)."""
|
||||
if not self.vision:
|
||||
return
|
||||
self.head_busy = True # keep_focus waits: the head is turned here
|
||||
@@ -1160,7 +1162,7 @@ class Lumi:
|
||||
recent = time.time() - getattr(self, "voice_at", 0.0) <= VOICE_KEEP_S # this turn's sound too weak: the
|
||||
voice = self.voice_angle if self.voice_trusted or recent else None # caller's last sure direction
|
||||
gaze = HEAD_SIGN * self.det_yaw()
|
||||
seen = self.vision.seen()
|
||||
seen = self.vision.seen(LOOK_ME_MAX_M)
|
||||
found, why = (near(seen, voice), "nearest the voice") if voice is not None else (None, "")
|
||||
if found is None and seen:
|
||||
cur = self.current if self.current and self.vision.present(self.current) else None
|
||||
@@ -1170,23 +1172,25 @@ class Lumi:
|
||||
found = min(seen, key=lambda s: abs(s[0] - gaze))
|
||||
why = "nearest where the head looks" + ("" if voice is None else f", none at the voice {voice:+.0f} deg")
|
||||
if found is None: # nobody in view: the head camera looks around first
|
||||
first = gaze if voice is None else max(-head.YAW_LIMIT, min(head.YAW_LIMIT, voice))
|
||||
guess = voice if voice is not None else getattr(self, "voice_guess", None) # an unsure voice still
|
||||
first = gaze if guess is None else max(-head.YAW_LIMIT, min(head.YAW_LIMIT, guess)) # picks the side
|
||||
side = 1.0 if first >= 0 else -1.0
|
||||
for a in (side * head.YAW_LIMIT, -side * head.YAW_LIMIT):
|
||||
log(f" look me: nobody seen, looking at {a:+.0f} deg")
|
||||
face(a)
|
||||
time.sleep(LOOK_ME_SETTLE_S) # new head camera frames from there
|
||||
seen = self.vision.seen()
|
||||
seen = self.vision.seen(LOOK_ME_MAX_M)
|
||||
if seen:
|
||||
found, why = min(seen, key=lambda s: abs(s[0] - a)), "found looking around"
|
||||
break
|
||||
if found is None and voice is not None and abs(voice) > head.YAW_LIMIT:
|
||||
voice = self.turn_body_to(voice) # behind: the head alone can't get there
|
||||
self.voice_angle, self.voice_trusted, self.voice_at = voice, False, 0.0 # measured before the turn:
|
||||
log(f" look me: turned toward the voice, looking at {voice:+.0f} deg") # never used again
|
||||
self.voice_guess = None # never used again
|
||||
log(f" look me: turned toward the voice, looking at {voice:+.0f} deg")
|
||||
face(voice)
|
||||
time.sleep(LOOK_ME_SETTLE_S)
|
||||
seen = self.vision.seen()
|
||||
seen = self.vision.seen(LOOK_ME_MAX_M)
|
||||
found, why = min(seen, key=lambda s: abs(s[0] - voice), default=None), "after turning to the voice"
|
||||
if found is None:
|
||||
log(" look me: nobody seen, the head goes back")
|
||||
@@ -2279,7 +2283,7 @@ class Lumi:
|
||||
person in view is the one, 2026-10-27)."""
|
||||
ears.last_stt.clear()
|
||||
ears.last_stt.update(language="korean" if brain_mod.HANGUL.search(text) else "english", logprob=0.0, text=text)
|
||||
self.voice_trusted = False
|
||||
self.voice_trusted, self.voice_guess = False, None
|
||||
self.typed_now = True # to Lumi, name or not (mission_talk)
|
||||
try:
|
||||
self.answer(text)
|
||||
@@ -2761,6 +2765,7 @@ class Lumi:
|
||||
if not self.vision or u is None:
|
||||
return
|
||||
self.voice_trusted = False # set again below only from this turn's own sound
|
||||
self.voice_guess = None # this turn's direction, sure or not
|
||||
yaw = self.det_yaw()
|
||||
only = self.vision.only_person()
|
||||
if only is not None and only is self.current and only.distance <= 1.6 and u.seconds >= 0.8:
|
||||
@@ -2774,6 +2779,7 @@ class Lumi:
|
||||
return
|
||||
ang, conf, _ = doa.estimate(u.mics, cal, doa.clip_ref(u)) # with the clip mic: its wearer's voice
|
||||
trusted = conf >= voice_min_conf(u)
|
||||
self.voice_guess = HEAD_SIGN * yaw + ang
|
||||
log(f" voice at {HEAD_SIGN * yaw + ang:+.0f} deg (confidence {conf:.2f}{doa.clip_note(u.mics, doa.clip_ref(u))}"
|
||||
f"{'' if trusted else ', not trusted'})")
|
||||
if not trusted:
|
||||
@@ -3308,7 +3314,7 @@ class Lumi:
|
||||
ang, conf, raw = doa.estimate(u.mics, cal, doa.clip_ref(u)) # with the clip mic: its wearer's voice
|
||||
trusted = cal["fitted"] and conf >= voice_min_conf(u)
|
||||
robot_angle = HEAD_SIGN * self.det_yaw() + ang
|
||||
self.voice_angle, self.voice_trusted = robot_angle, trusted
|
||||
self.voice_angle, self.voice_trusted, self.voice_guess = robot_angle, trusted, robot_angle
|
||||
if trusted:
|
||||
self.voice_at = time.time()
|
||||
log(f"WAKE {text!r}: voice at {robot_angle:+.0f} deg (confidence {conf:.2f}, "
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class Vision:
|
||||
def nearest_greeted(self):
|
||||
return next((t for t in self.tracks if t.greeted), None)
|
||||
|
||||
def seen(self):
|
||||
def seen(self, max_m=None):
|
||||
return [(t.angle, t.distance) for t in self.tracks]
|
||||
|
||||
def head_person(self, angle, since):
|
||||
|
||||
@@ -44,7 +44,7 @@ class Vision: # someone at -60 deg besides the
|
||||
def present(self, t):
|
||||
return True
|
||||
|
||||
def seen(self):
|
||||
def seen(self, max_m=None):
|
||||
return [(self.stranger.angle, 1.0)]
|
||||
|
||||
def head_person(self, angle, since):
|
||||
|
||||
@@ -14,7 +14,7 @@ class Vision:
|
||||
def __init__(self, before, after=None):
|
||||
self.views = [before, before if after is None else after]
|
||||
|
||||
def seen(self):
|
||||
def seen(self, max_m=None):
|
||||
return self.views.pop(0) if len(self.views) > 1 else self.views[0]
|
||||
|
||||
def present(self, t):
|
||||
@@ -56,6 +56,13 @@ assert look([], voice=-55.0, after=[(-50.0, 0.9)]) == [-60, -50], turns
|
||||
assert look([], voice=-55.0) == [-60, 60, 0], turns
|
||||
# nobody seen, no voice: looks around and back
|
||||
assert look([], gaze=10.0) == [60, -60, 10], turns
|
||||
# nobody seen, the voice unsure but on the right: the right first, not the side the head happens to face (2026-10-30)
|
||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||
L.vision, L.current, L.voice_angle, L.voice_trusted, L.voice_guess = Vision([], [(-50.0, 2.0)]), None, 0.0, False, -64.0
|
||||
L.det_yaw = lambda: 0.0
|
||||
turns.clear()
|
||||
L.look_at_speaker()
|
||||
assert turns == [-60, -50], turns
|
||||
|
||||
# "Lumi" with the voice read on the left, nobody there: the head turns there, then to the person seen, else back
|
||||
heads = []
|
||||
|
||||
Reference in New Issue
Block a user