Improve head resting pose and keep the head where it was asked to look
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,7 @@ fetch.head_cam.base_from_head = lambda yaw, pitch: None #
|
||||
fetch.objects.latest = lambda camera="torso": {"age_s": None, "objects": [], "head_pose": None}
|
||||
fetch.camview.want = lambda name: None
|
||||
fetch.head.moveto = lambda *a, **kw: (_ for _ in ()).throw(AssertionError("real head / lift move in a test"))
|
||||
fetch.head.status = lambda: [75.0, -15.0, 0.0, 0.0]
|
||||
fetch.head.status = lambda: [75.0, -15.0, *fetch.HEAD_AHEAD] # the head at rest
|
||||
skills.arm.cmd = lambda *a, **kw: (_ for _ in ()).throw(AssertionError(f"real arm command in a test: {a}"))
|
||||
say = lambda en, ko: said.append(en)
|
||||
P = lambda **k: k
|
||||
|
||||
@@ -304,7 +304,8 @@ yaws = [m[4] for m in body.moves if m[1] == "follow head"]
|
||||
assert body.overlaps == 0 and len(yaws) >= 3, (body.overlaps, len(yaws))
|
||||
assert max(yaws) > 20.0 and min(yaws) >= -follow.HEAD_STEP_DEG, yaws # left, toward them
|
||||
assert abs(yaws[-1]) < 15.0, yaws[-1] # back toward 0
|
||||
assert math.degrees(w.th) > 120.0 and all(m[5] == follow.HEAD_PITCH for m in body.moves), math.degrees(w.th)
|
||||
assert math.degrees(w.th) > 120.0 and all(m[5] == follow.HEAD_PITCH for m in body.moves[:-1]), math.degrees(w.th)
|
||||
assert body.moves[-1][4:] == (0.0, head.HEAD_REST_PITCH), body.moves[-1] # after it: back to rest
|
||||
print(f"walk behind: head up to {max(yaws):.0f} deg, base turned {math.degrees(w.th):.0f} deg, {len(yaws)} head moves")
|
||||
|
||||
# live 2026-10-21: "follow me" from a person at 0.54 m, -80 deg, the head turned to them; prepare() turned the head
|
||||
|
||||
@@ -52,7 +52,7 @@ def fresh(said, deg, yaw=10.0):
|
||||
L.patrol, L.chain_stop, L.sorry_at = None, threading.Event(), 0.0
|
||||
L.warm_llm = lambda: None
|
||||
L.det_yaw = lambda: yaw
|
||||
L.turn_head = lambda *a: done.append(("head", a))
|
||||
L.turn_head = lambda *a, **k: done.append(("head", a))
|
||||
L.answer = lambda text: heard.append(text)
|
||||
L.fetch_say = lambda en, ko: done.append(("say", en))
|
||||
L.keep_listening = lambda: None
|
||||
|
||||
@@ -237,4 +237,34 @@ for text in ("I am standing or sitting.", "Am I sitting or standing?", "It looks
|
||||
assert lumi.claimed_name("I'm James.") == "james"
|
||||
assert "only when they clearly tell you their name" in brain_mod.SYSTEM
|
||||
|
||||
# the head rests looking down (lowest pitch): every "head back" sends HEAD_REST_PITCH, never pitch 0
|
||||
src = open(lumi.__file__).read()
|
||||
assert "turn_head(0, 0)" not in src and "head.HEAD_REST_PITCH" in src
|
||||
assert lumi.LOOK["center"] == (0, lumi.head.HEAD_REST_PITCH) and lumi.head.HEAD_REST_PITCH == lumi.head.PITCH_RANGE[0]
|
||||
|
||||
# a look asked for is held: automatic head moves wait until LOOK_HOLD_S of silence, a goodbye or a stop word
|
||||
moves = []
|
||||
real_status, real_turn = lumi.head.status, lumi.head.turn
|
||||
lumi.head.status = lambda: [50.0, 0.0, 0.0, 20.0]
|
||||
lumi.head.turn = lambda yaw, pitch=None, **k: moves.append((yaw, pitch))
|
||||
H = lumi.Lumi.__new__(lumi.Lumi)
|
||||
H.looked_at, H.last_activity = time.time(), time.time() # "look up" just now
|
||||
H.turn_head(30.0) # toward a speaker: waits
|
||||
H.turn_head(0, lumi.head.HEAD_REST_PITCH) # back to rest: waits
|
||||
H.looked_at = H.last_activity = time.time() - lumi.LOOK_HOLD_S + 1 # still inside the hold
|
||||
H.turn_head(0, lumi.head.HEAD_REST_PITCH)
|
||||
time.sleep(0.2)
|
||||
assert moves == [] and H.look_held(), moves
|
||||
H.turn_head(10.0, 10, force=True) # an order still moves it
|
||||
H.looked_at = H.last_activity = time.time() - lumi.LOOK_HOLD_S - 1 # 35 s of silence: rest
|
||||
H.turn_head(0, lumi.head.HEAD_REST_PITCH)
|
||||
time.sleep(0.2)
|
||||
assert moves == [(10.0, 10), (0, lumi.head.HEAD_REST_PITCH)] and not H.look_held(), moves
|
||||
moves.clear()
|
||||
H.looked_at = H.last_activity = time.time()
|
||||
H.head_rest() # a goodbye / stop word ends the hold
|
||||
time.sleep(0.2)
|
||||
assert moves == [(0, lumi.head.HEAD_REST_PITCH)] and H.looked_at == 0.0, moves
|
||||
lumi.head.status, lumi.head.turn = real_status, real_turn
|
||||
|
||||
print("ok: wake words, waves, no greeting to passers-by or during tasks, answers never cut, names")
|
||||
|
||||
Reference in New Issue
Block a user