Improve arm motion resilience and test isolation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,13 @@ def _guard(real):
|
||||
socket.socket.connect = _guard(socket.socket.connect)
|
||||
socket.socket.connect_ex = _guard(socket.socket.connect_ex)
|
||||
|
||||
# the running assistant's blocked-drive state (/dev/shm): a test must not read it (after a live STUCK, "look at that"
|
||||
# became "go around" and the intents test failed, 2026-10-28)
|
||||
from assistant import detour as _detour # noqa: E402
|
||||
import tempfile as _tempfile # noqa: E402
|
||||
from pathlib import Path as _Path # noqa: E402
|
||||
_detour.STATE_FILE = _Path(_tempfile.mkdtemp()) / "lumi_stuck.json"
|
||||
|
||||
|
||||
@atexit.register
|
||||
def _report():
|
||||
|
||||
+2
-2
@@ -115,7 +115,7 @@ lumi.doa.estimate = lambda mics, cal, ref=None: (-40.0, 0.9, 0.0)
|
||||
lumi.waist_turned = lambda: 0.0
|
||||
from tasks import fetch as _fetch # noqa: E402
|
||||
_fetch._waist_to = lambda rel, in_place=False, look=None: True # "look at me" past the head turns the waist
|
||||
lumi.waist_home = lambda why: True
|
||||
lumi.waist_home = lambda why, fold=False: True
|
||||
lumi.agv.turn_by = lambda rad: None # "look at me" past the head with Patrol turns the base
|
||||
lumi.agv.status = lambda: {"move_status": "succeeded"}
|
||||
U = types.SimpleNamespace(mics=None, seconds=1.0, source="clip")
|
||||
@@ -165,7 +165,7 @@ lumi.agv.go_point = lambda *a: (True, "")
|
||||
lumi.agv.turn_by = lambda a: (_ for _ in ()).throw(AssertionError("the base turned away from the caller"))
|
||||
lumi.nav.person_on_map = lambda *a: (3.0, 0.0)
|
||||
lumi.nav.approach = lambda *a: (2.0, 0.0, 0.0)
|
||||
lumi.waist_home = lambda why: True
|
||||
lumi.waist_home = lambda why, fold=False: True
|
||||
L = fresh(a := Track(5, -19.0, 2.5), Track(8, 30.0, 2.4))
|
||||
L.current, L.look_me, L.looked_at = a, a, time.time()
|
||||
L.voice_angle, L.voice_trusted = -107.0, True # the voice read far off (19:24:22): the focus wins
|
||||
|
||||
@@ -101,4 +101,22 @@ assert not L.reach_done("thanks") and not folds and not L.reached_at
|
||||
L.reached_at = 0.0
|
||||
status["now"] = "done"
|
||||
assert not L.reach_done("thanks") and not folds # no reach out: "thanks" moves nothing
|
||||
|
||||
# an arm left half way (a reach stopped by a lost state reply) and the waist turned: an order to drive folds the empty
|
||||
# arm along the checked route, then the waist comes to the front; a conversation's end or a held thing never folds it
|
||||
# (live 2026-10-28 19:08-19:13: every "come here" said "I can't turn back to the front")
|
||||
route, waist = [], {"turn": 26.0}
|
||||
real = (fetch._waist_turn, fetch.state, fetch._at_pose, fetch._waist_to, lumi.arm_route.plan, lumi.arm_route.move)
|
||||
fetch._waist_turn = lambda: waist["turn"]
|
||||
fetch._at_pose = lambda name: bool(route)
|
||||
fetch._waist_to = lambda deg, in_place=False, look=None: waist.update(turn=deg) or True
|
||||
lumi.arm_route.plan = lambda target, holding=False: [(target, [0] * 6)]
|
||||
lumi.arm_route.move = lambda seq, speed=None, holding=False: route.append(seq[-1][0])
|
||||
fetch.state = lambda: {"status": "failed", "holding": False}
|
||||
assert not lumi.waist_home("the conversation is over") and not route and waist["turn"] == 26.0
|
||||
assert lumi.waist_home("coming to a person", fold=True) and route == ["look"] and waist["turn"] == 0.0
|
||||
route.clear(), waist.update(turn=26.0)
|
||||
fetch.state = lambda: {"status": "failed", "holding": True} # something in the hand: never moved for a drive
|
||||
assert not lumi.waist_home("coming to a person", fold=True) and not route
|
||||
(fetch._waist_turn, fetch.state, fetch._at_pose, fetch._waist_to, lumi.arm_route.plan, lumi.arm_route.move) = real
|
||||
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move, held state, auto fold)")
|
||||
|
||||
@@ -22,7 +22,7 @@ lumi.motion.stop = lambda: done.append("arm stop")
|
||||
follow.stop = lambda: done.append("follow stop")
|
||||
fetch.stop = lambda: done.append("fetch stop")
|
||||
fetch.state = lambda: {"status": "idle"}
|
||||
lumi.waist_home = lambda why: True # the waist at the front before a drive (it reads the body and arm)
|
||||
lumi.waist_home = lambda why, fold=False: True # the waist at the front before a drive (it reads the body and arm)
|
||||
lumi.waist_turned = lambda: 0.0
|
||||
lumi.mouth.say = lambda text, **k: done.append(("say", text))
|
||||
lumi.mouth.own_voice = lambda u: False
|
||||
|
||||
@@ -217,10 +217,15 @@ assert L.reach_out(False) is None and not reached and not came and said == [lumi
|
||||
L.modes.drive, person.distance = True, 1.0
|
||||
fetch.give_bearing = lambda: 0.0
|
||||
L.turn_head = lambda *a, **k: moved.append("head")
|
||||
L.vision = None # nobody seen, the voice's direction not trusted: ask
|
||||
seen_vision, L.vision = L.vision, None # nobody seen, the voice's direction not trusted: ask
|
||||
reached.clear(), said.clear()
|
||||
assert L.reach_out(False) is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]]
|
||||
L.voice_trusted, L.voice_angle, L.modes.patrol = True, -50.0, True # heard from the right: turn to the voice
|
||||
L.voice_trusted, L.voice_angle, L.modes.patrol = True, -50.0, True # heard from the right, nobody seen there:
|
||||
L.find_caller = lambda angle, trusted: None # no reach to a bare voice direction (it was
|
||||
reached.clear(), said.clear() # 166 deg off, 2026-10-28)
|
||||
assert L.reach_out(False) is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]]
|
||||
L.find_caller = lambda angle, trusted: person # someone seen there: to them
|
||||
person.angle, L.vision = -50.0, seen_vision
|
||||
assert L.reach_out(False) and reached == [-50.0]
|
||||
moved.clear(), reached.clear(), said.clear()
|
||||
L.fetch_status = lambda: "holding"
|
||||
@@ -259,7 +264,7 @@ for n, f in real.items():
|
||||
# ---------- every drive and base turn starts with the waist at the front ----------
|
||||
order = []
|
||||
real_home = lumi.waist_home
|
||||
lumi.waist_home = lambda why: order.append("waist") or True
|
||||
lumi.waist_home = lambda why, fold=False: order.append("waist") or True
|
||||
lumi.agv.status = lambda: {"move_status": "idle", "power_percent": 90}
|
||||
lumi.agv.go = lambda m: order.append(("go", m)) or (True, "OK")
|
||||
lumi.agv.go_point = lambda x, y, th: order.append(("go", (x, y, th))) or (True, "OK")
|
||||
@@ -278,7 +283,7 @@ real_turned, lumi.waist_turned = lumi.waist_turned, lambda: 30.0 # turned 30 l
|
||||
order.clear()
|
||||
L.look_toward(150.0) # a voice behind: the base turns to it from the base's front
|
||||
assert order == ["waist", ("turn", 180)], order
|
||||
lumi.waist_home = lambda why: order.append("waist") or False # it can't come back: no drive, no turn, said why
|
||||
lumi.waist_home = lambda why, fold=False: order.append("waist") or False # it can't come back: no drive, no turn, said why
|
||||
order.clear()
|
||||
P = lumi.Patrol(["p3"], once=True)
|
||||
P.tick(force=True)
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ lumi.ears.transcribe = lambda mono: mono
|
||||
lumi.ears.understood = lambda lp: True
|
||||
lumi.time.sleep = lambda s: None
|
||||
lumi.waist_turned = lambda: 0.0 # the waist at the front (it reads the body)
|
||||
lumi.waist_home = lambda why: True
|
||||
lumi.waist_home = lambda why, fold=False: True
|
||||
M = ["home", "dock2"]
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ assert "head" in done and L.voice_until == 0.0, done # end_conversation: yaw 0
|
||||
# a held look keeps both (the waist waits like the head)
|
||||
homed, back = [], threading.Event()
|
||||
real_home, real_turned = lumi.waist_home, lumi.waist_turned
|
||||
lumi.waist_home = lambda why: homed.append(why) or back.set() or True
|
||||
lumi.waist_home = lambda why, fold=False: homed.append(why) or back.set() or True
|
||||
for patrol in (False, True):
|
||||
L = fresh(a := Track(33, 40))
|
||||
a.greeted, L.current, L.modes.patrol = True, a, patrol
|
||||
@@ -336,7 +336,7 @@ for turned, homes, want in ((30.0, True, -20.0), (30.0, False, -50.0), (0.0, Tru
|
||||
heads, back = [], threading.Event()
|
||||
L.turn_head = lambda yaw=None, *r, **k: heads.append(yaw) or back.set()
|
||||
lumi.waist_turned = lambda w=turned: w
|
||||
lumi.waist_home = lambda why, ok=homes: homed.append(why) or ok
|
||||
lumi.waist_home = lambda why, ok=homes, fold=False: homed.append(why) or ok
|
||||
homed.clear()
|
||||
lumi.Lumi.who_spoke(L, U("Lumi, stop.", seconds=1.0))
|
||||
assert back.wait(2) and L.current is b and heads == [lumi.HEAD_SIGN * want], (turned, homes, heads)
|
||||
|
||||
Reference in New Issue
Block a user