Turn the body to face callers past the head's reach and behind

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 13:37:18 +09:00
co-authored by Claude Opus 5.5
parent 3d6dcb9ba7
commit cdd85b6ea9
2 changed files with 49 additions and 12 deletions
+18 -10
View File
@@ -387,6 +387,7 @@ LOOK_ME_PITCH = 0.0 # deg, head pitch of the first turn to a pers
# fits whole; the head camera then tilts it to their height (look_me_pitch) # 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_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_MAX_M = 6.0 # m; "look at me" finds callers up to this far (others count only within STAY_MAX)
LOOK_ME_BODY_DEG = 5.0 # deg past the head's yaw limit before the body turns to face the person
LOOK_ME_TOP_ROW = 0.08 # share of the image height from the top where the person's head should be 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_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) 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)
@@ -1137,12 +1138,13 @@ class Lumi:
def look_at_speaker(self): def look_at_speaker(self):
""""Look at me": the cameras first, the voice direction only to choose. Someone seen (both cameras, up to """"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 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 looks; the voice never turns the body then (it read a person in front as behind, 2026-10-28/29, and a repeat
behind, 2026-10-28/29, so a repeat "look at me" flipped the base from side to side). Nobody seen: the head "look at me" flipped the base from side to side), only someone seen past the head's reach does, so the head
sweeps the voice's side (sure or not), then the other side; nobody there either and a sure voice past the faces them. Nobody seen: the head sweeps the voice's side (sure or not), then the other side; nobody there
head's reach: the body turns to it (turn_body_to) and the head looks there. Then the head tilts until the either: the body turns to the voice, a voice read in front taken as its mirror behind (the array mixes the
head camera sees the person from their head down (look_me_pitch). That person becomes the one talked with, two), and the head looks there (turn_body_to). Then the head tilts until the head camera sees the person
and while the look is held the head follows them (look_me, keep_focus).""" 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: if not self.vision:
return return
self.head_busy = True # keep_focus waits: the head is turned here self.head_busy = True # keep_focus waits: the head is turned here
@@ -1183,7 +1185,11 @@ class Lumi:
if seen: if seen:
found, why = min(seen, key=lambda s: abs(s[0] - a)), "found looking around" found, why = min(seen, key=lambda s: abs(s[0] - a)), "found looking around"
break break
if found is None and voice is not None and abs(voice) > head.YAW_LIMIT: if found is None and voice is None: # an unsure voice still gives the side
voice = getattr(self, "voice_guess", None)
if found is None and voice is not None and abs(voice) <= head.YAW_LIMIT: # nobody where the head looked: the
voice = (180.0 - abs(voice)) * (1.0 if voice >= 0 else -1.0) # array mixes front and back
if found is None and voice is not None:
voice = self.turn_body_to(voice) # behind: the head alone can't get there 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: self.voice_angle, self.voice_trusted, self.voice_at = voice, False, 0.0 # measured before the turn:
self.voice_guess = None # never used again self.voice_guess = None # never used again
@@ -1197,6 +1203,8 @@ class Lumi:
face(gaze) face(gaze)
return return
log(f" look me: person at {found[0]:+.0f} deg, {found[1]:.2f} m ({why})") log(f" look me: person at {found[0]:+.0f} deg, {found[1]:.2f} m ({why})")
if abs(found[0]) > head.YAW_LIMIT + LOOK_ME_BODY_DEG: # past the head's reach: the body turns so the head
found = (self.turn_body_to(found[0]), found[1]) # faces them, not the camera's edge
face(found[0]) face(found[0])
for _ in range(LOOK_ME_TRIES): for _ in range(LOOK_ME_TRIES):
since = time.time() since = time.time()
@@ -1213,8 +1221,8 @@ class Lumi:
t.greeted, self.current, self.look_me = True, t, t t.greeted, self.current, self.look_me = True, t, t
def turn_body_to(self, angle): def turn_body_to(self, angle):
"""A voice past the head's reach (waist-frame deg): with Patrol the base turns to it (look_toward), else the """A voice or a person past the head's reach (waist-frame deg): with Patrol the base turns to it (look_toward),
waist turns in place toward it (the base stays; fetch._waist_to checks the arm's sweep). Returns the voice's else the waist turns in place toward it (the base stays; fetch._waist_to checks the arm's sweep). Returns its
waist-frame angle after the turn (unchanged when nothing could turn).""" waist-frame angle after the turn (unchanged when nothing could turn)."""
from tasks import fetch from tasks import fetch
if self.modes.patrol: if self.modes.patrol:
@@ -1222,7 +1230,7 @@ class Lumi:
return 0.0 return 0.0
w = waist_turned() w = waist_turned()
want = max(-LOOK_WAIST_MAX, min(LOOK_WAIST_MAX, w + angle)) want = max(-LOOK_WAIST_MAX, min(LOOK_WAIST_MAX, w + angle))
log(f" look me: the voice at {angle:+.0f} deg is past the head: waist to {want:+.0f} deg") log(f" look me: {angle:+.0f} deg is past the head: waist to {want:+.0f} deg")
try: try:
fetch._waist_to(want, in_place=True, look=angle) fetch._waist_to(want, in_place=True, look=angle)
except Exception as e: except Exception as e:
+31 -2
View File
@@ -52,8 +52,6 @@ for v in (128.0, -122.0, 120.0, -120.0):
assert look([(-30.0, 1.0), (35.0, 1.0)], voice=150.0, gaze=-25.0) == [-30], turns assert look([(-30.0, 1.0), (35.0, 1.0)], voice=150.0, gaze=-25.0) == [-30], turns
# nobody seen: the head looks to the voice's side first, finds the person there # nobody seen: the head looks to the voice's side first, finds the person there
assert look([], voice=-55.0, after=[(-50.0, 0.9)]) == [-60, -50], turns assert look([], voice=-55.0, after=[(-50.0, 0.9)]) == [-60, -50], turns
# nobody seen on that side either: the other side, then back where it looked when nobody is anywhere
assert look([], voice=-55.0) == [-60, 60, 0], turns
# nobody seen, no voice: looks around and back # nobody seen, no voice: looks around and back
assert look([], gaze=10.0) == [60, -60, 10], turns 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) # nobody seen, the voice unsure but on the right: the right first, not the side the head happens to face (2026-10-30)
@@ -164,3 +162,34 @@ assert waist["calls"] == [(120, True, 170.0)], waist
assert turns == [60, -60, 50, 0], turns # looked around first; 170 - 120 left for the head; nobody: back assert turns == [60, -60, 50, 0], turns # looked around first; 170 - 120 left for the head; nobody: back
assert not L.voice_trusted and L.voice_at == 0.0 # a direction measured before the turn is never used again assert not L.voice_trusted and L.voice_at == 0.0 # a direction measured before the turn is never used again
print("look me behind: ok") print("look me behind: ok")
# someone seen past the head's reach (+101 deg, the owner 2 m to the left, 2026-10-30): the waist turns so the head
# faces them, not with them at the camera's edge
waist.update(at=0.0, calls=[])
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current = Vision([(101.0, 1.9)]), None
L.voice_angle, L.voice_trusted = 0.0, False
L.det_yaw = lambda: 0.0
L.modes = type("M", (), {"patrol": False})()
turns.clear()
L.look_at_speaker()
assert waist["calls"] == [(101, True, 101.0)] and turns == [0], (waist, turns)
print("look me past the head: ok")
# called from behind, nobody in view (2026-10-30): the body turns to the voice even when it is unsure (+150 here) ...
waist.update(at=0.0, calls=[])
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current = Vision([]), None
L.voice_angle, L.voice_trusted, L.voice_guess = 0.0, False, 150.0
L.det_yaw = lambda: 0.0
L.modes = type("M", (), {"patrol": False})()
turns.clear()
L.look_at_speaker()
assert waist["calls"] == [(120, True, 150.0)] and turns == [60, -60, 30, 0], (waist, turns)
# ... and a voice read in front with nobody there is taken as its mirror behind (-55 -> -125)
waist.update(at=0.0, calls=[])
L.voice_angle, L.voice_trusted, L.voice_guess = -55.0, True, -55.0
turns.clear()
L.look_at_speaker()
assert waist["calls"] == [(-120, True, -125.0)] and turns == [-60, 60, -5, 0], (waist, turns)
print("look me from behind, unsure voice: ok")