Keep head moves from hanging, check a shut hand with the camera and follow round tight spots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 20:55:05 +09:00
co-authored by Claude Opus 5.5
parent 9b239c8b89
commit 8ec328f9da
18 changed files with 458 additions and 79 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ ARM = re.compile(r"^(?:wave|reach|hand|arm|give|take|put|waist)") # intents of
# ---------- fakes: nothing moves, nothing is written ----------
HAND = {"held": False}
fetch.check_hand = lambda: HAND["held"]
fetch.check_hand = fetch.look_at_hand = lambda: HAND["held"]
fetch.held_name = lambda lang="en": "the cup" if lang == "en" else "컵"
fetch.state = lambda: {"holding": HAND["held"]}
fetch.log = lumi.log = lambda *a, **k: None
+1 -1
View File
@@ -50,7 +50,7 @@ fake = types.SimpleNamespace(
quick_command=lambda w, rule=None: done.append(("quick", w)), answer=lambda w, part=False: done.append(("talk", w)),
fetch_say=lambda en, ko: said.append(en), chain_wait=lambda: None, base_off=lambda *a, **k: False,
stay=lambda: None)
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
runs = []
fetch.run_steps = lambda s, say=None, sender=None: runs.append(s)
fetch.state = lambda: {"status": "failed" if runs and runs[-1][0].get("to") == "p5" else "done"}
+1 -1
View File
@@ -74,7 +74,7 @@ def come_to(track, say=False):
L.come_to = come_to
L.end_run = lambda text: events.append("end run")
hand = {"held": True}
L.held_now = lambda: hand["held"]
L.held_now = lambda look=False: hand["held"]
# the hand-over by voice goes to the person who asked: far -> comes to them first, near -> at once
for text in ["Give me a cup.", "give it to me", "hand it over", "컵 줘", "이리 줘", "나한테 주세요"]:
+2 -2
View File
@@ -80,7 +80,7 @@ def hand(text):
return rec("talk")
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
lumi.log = fetch.log = lambda *a: None
lumi.mouth = types.SimpleNamespace(say=lambda *a, **k: None, lang_of=lambda t: "ko" if brain.HANGUL.search(t) else "en",
recent_speech=lambda s=30.0: "")
@@ -150,7 +150,7 @@ assert not bad
# ---------- what the box plans: one short line per reading ----------
HELD = [False]
fetch.check_hand = lambda: HELD[0]
fetch.check_hand = fetch.look_at_hand = lambda: HELD[0]
fetch.state = lambda: {"holding": HELD[0]}
fetch.held_name = lambda lang="en": "the white cup"
+1
View File
@@ -110,6 +110,7 @@ for name in ("_drive_pose", "_waist_front", "head_ahead", "_lift_to", "_line_hol
fetch.skills.moved = lambda: None
fetch.gripper.state = lambda: {"holding": True}
fetch._in_hand = lambda: False
fetch._to_check_pose = lambda: None # the hand check pose (a shut hand) is not this test's
fetch._launch = lambda fn, *a: fn(*a) # in this thread: the test reads the end at once
say = lambda en, ko=None: said.append(en)
+5 -3
View File
@@ -168,7 +168,8 @@ skills.home_joints = lambda: [0.0] * 6
up_rpy = list(skills.GRASP_RPY)
tilt = {"rpy": up_rpy}
skills._ask = lambda name, **a: {"errorCode": "0", "cartPosition": [0, 0, 0] + tilt["rpy"]}
fetch.gripper.state = lambda: {**hand, "ai": [3500 if hand["holding"] else 160], "di": [int(hand["holding"])]}
fetch.gripper.state = lambda: {**hand, "ai": [3500 if hand["holding"] else 4150 if hand["closed"] else 160],
"di": [int(hand["holding"])]}
fetch.gripper.open_ = lambda: (calls.append(("open",)), hand.update(holding=False, closed=False), fetch.gripper.state())[-1]
def in_room(obj):
"""A fake camera's object that stays put in the room: seen where it is from the base pose now (the CALIB_FILE yaw
@@ -479,15 +480,16 @@ except fetch.FetchError:
pass
fetch._set(holding=False, status="idle")
hand.update(holding=False, closed=False)
# the camera sees an empty hand while AI_1 still says holding (the fingers shut on nothing): believed, fetch starts
# the state says holding, the fingers shut on nothing (no close on a thing seen, tasks/fetch.close_hand): fetch starts
reset()
fetch._set(holding=True, status="holding")
hand.update(holding=True, closed=True)
hand.update(holding=False, closed=True)
eye["hand"] = "empty"
st = run(fetch.start, {**ok, "source": "here", "dest": "here"})
assert st["status"] == "holding" and ("open",) in calls, st["log"] # started, and opened the hand first
# ... and place / give with an empty hand are refused, the state forgets it
fetch._set(holding=True, status="holding")
hand.update(holding=False, closed=True)
for fn in (fetch.place, fetch.give):
try:
fn()
+3 -3
View File
@@ -36,7 +36,7 @@ assert brain.held_command("bring it to p5 and put it on the white chair") == "pl
from api import server
server.agv.markers = lambda: ["p1", "p8", "home"]
for holding in (True, False):
fetch.check_hand = lambda: holding
fetch.check_hand = fetch.look_at_hand = lambda: holding
fetch._state.update(holding=holding, held_object={"object": "cup", "colour": "white"} if holding else None)
for text, said in (("put it on the grey table", "Put the white cup on the grey table."),
("put on the gray table", "Put the white cup on the grey table."),
@@ -242,7 +242,7 @@ assert got["colour"] == "white" and said[-1] == "I couldn't see a blue cup, so I
fetch._look_around, fetch._look_at, fetch._fitted, fetch._go_to = real_around, real_look_at, real_fitted, real_go_to
# ---------- the dialog's sentence says what was understood ----------
fetch.check_hand = lambda: True
fetch.check_hand = fetch.look_at_hand = lambda: True
fetch._state.update(holding=True, held_object={"object": "cup", "colour": "grey"})
for text, said in (("put the cup on the white dinning table or chair", "Put the grey cup on the white dining table or chair."),
("put it on the white tabel", "Put the grey cup on the white table."),
@@ -253,7 +253,7 @@ for text, said in (("put the cup on the white dinning table or chair", "Put the
fetch._state.update(holding=False, held_object=None)
# ---------- "take the smaller cup": typed, the sentence says it, the task carries it; fetch takes the smaller one ----
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
for text, said, prefer in (("take the smaller cup to p1", "Take the smaller cup from here, bring it to p1 and hold it.",
"small"),
("bring me the cup on the left", "Take the cup on the left from here, bring it here and "
+89 -9
View File
@@ -28,6 +28,7 @@ def forbid(*a, **k):
fetch.motion.go = fetch.skills._ask = motion._ready = forbid
follow.torso_people = lambda: [] # never the real camera service's file (World.torso_view below)
fetch._charging = lambda: False
fetch._at_pose = lambda name: True # the arm is in look already
fetch._pose = lambda name, speed=None: None
@@ -50,7 +51,7 @@ class Body:
def call(self, path, body=None, timeout=2):
if path == "status":
return [{"enable": True, "pos": p} for p in self.pos]
return [{"enable": True, "pos": p, "vel": 0.0} for p in self.pos] # still (robot/head.py waits on vel)
if path != "moveto":
forbid()
with self.lock:
@@ -132,6 +133,12 @@ class World:
look = None
def torso_view(self):
"""follow.torso_people: the torso camera turns with the waist, sees +-HALF_FOV of its front."""
d, a = self.sight(self.person_at())
a -= body.pos[1]
return [(d, a, 0.0, None)] if abs(a) <= HALF_FOV else []
def sight(self, p):
"""(distance, angle deg + left) of the map point p from the base now."""
x, y, th = self.pose()
@@ -526,7 +533,8 @@ def person_deg(w):
def watch(w, secs):
"""[(t, waist, head yaw, base deg, gaze off the person deg)] every 20 ms; the angle of every forward command."""
"""[(t, waist, head yaw, base deg, gaze off the person deg, s since follow last had a sighting of them)] every
20 ms; the angle of every forward command."""
samples, ahead, request = [], [], w.request
def req(cmd):
@@ -540,7 +548,9 @@ def watch(w, secs):
while time.time() < t0 + secs:
_, waist, yaw, _ = body.pos
b = person_deg(w)
samples.append((time.time() - t0, waist, yaw, math.degrees(w.th), (b - waist - yaw + 180.0) % 360.0 - 180.0))
seen = follow._followed[0]
samples.append((time.time() - t0, waist, yaw, math.degrees(w.th), (b - waist - yaw + 180.0) % 360.0 - 180.0,
time.time() - seen[1] if seen else 0.0))
time.sleep(0.02)
return samples, ahead
@@ -555,7 +565,8 @@ assert wait_end(0.5)
moves = [m for m in body.moves if m[1] == "follow head"]
first = moves[0]
assert first[3] == 0.0 and first[4] > 90.0 and abs(first[4] - 170.0) < 10.0, first # the head alone on them
assert max(abs(s[4]) for s in samples[5:]) < 15.0, max(abs(s[4]) for s in samples[5:]) # gaze on them
late = [s for s in samples if s[0] > 0.1 + head.STILL_S] # the first move (head.moveto waits
assert max(abs(s[4]) for s in late) < 15.0, max(late, key=lambda s: abs(s[4])) # STILL_S first): gaze on them
assert all(m[3] == 0.0 for m in moves), moves # the waist stays
assert w.cmds[0][2] > 0.0 and w.cmds[0][0] - w.t0 < 0.5, w.cmds[:2] # turning at once
assert max(b[0] - a[0] for a, b in zip(w.cmds, w.cmds[1:])) < 0.2 # no tick waits
@@ -598,12 +609,15 @@ print("stopped turned: waist back to the front")
# the real one the head alone must stay on them: the gaze within 25 deg (the camera sees +-47), the waist never out.
HEAD_DEG_S = [70.0] # the fake head's speed (the real one ~40, audio/sing.py)
def real_body(path, b=None, timeout=2):
"""The body API as slow as live: ~0.45 s a move + the travel (head ~70, waist ~15 deg/s), moving all along."""
if path != "moveto":
return body.call(path, b, timeout)
start, goal, t0 = list(body.pos), list(b["pos"]), time.time()
dur = 0.45 + max(abs(goal[2] - start[2]) / 70.0, abs(goal[1] - start[1]) / 15.0)
dur = 0.45 + max(abs(goal[2] - start[2]) / HEAD_DEG_S[0], abs(goal[1] - start[1]) / 15.0)
while time.time() - t0 < dur:
body.pos = [a + (g - a) * (time.time() - t0) / dur for a, g in zip(start, goal)]
time.sleep(0.02)
@@ -638,7 +652,7 @@ turn_hits = fetch.turn_hits
for why in ("sweep", "not look"):
body.moves.clear()
if why == "sweep":
fetch.turn_hits = lambda d: (1.0, 1.0) if threading.current_thread().name == "follow head" else None
fetch.turn_hits = lambda d, pose=None: (1.0, 1.0) if threading.current_thread().name == "follow head" else None
else:
calls = iter([True]) # ready() sees it in look, then
fetch._at_pose = lambda name: next(calls, False) # it is moved out (by hand)
@@ -672,13 +686,13 @@ time.sleep(0.6)
follow.stop()
assert wait_end(0.5)
yaws = [m[4] for m in body.moves if m[1] == "follow head"]
assert yaws and all(y > 0 for y in yaws[1:]), yaws
assert len(yaws) > 1 and all(y * yaws[1] > 0 for y in yaws[1:]), yaws # which side depends on the first sighting
print("right behind: one side")
# right behind beside a wall (live 2026-10-30): the arm blocked turning left, the base turns right round to them
# (head ahead, out of view a while), never back the blocked way; blocked both ways: it stops and says so
blocked_dir = [1.0]
fetch.turn_hits = lambda d: (-5.08, 11.54) if d * blocked_dir[0] > 0 or not blocked_dir[0] else None
fetch.turn_hits = lambda d, pose=None: (-5.08, 11.54) if d * blocked_dir[0] > 0 or not blocked_dir[0] else None
said.clear()
body.pos = [50.0, 0.0, 180.0, follow.HEAD_PITCH] # "look at the back side": the head right behind
head._call = real_body
@@ -702,9 +716,75 @@ w = World(person=(1.3 * math.cos(math.radians(186.0)), 1.3 * math.sin(math.radia
follow.start(w.see, say)
assert wait_end(3.0) and any("can't turn" in x for x in said), said
assert all(c[2] == 0.0 for c in w.cmds), w.cmds
fetch.turn_hits = turn_hits
print("right behind, both ways blocked: stops, says so")
# the same turn round with a head as slow as the real one (~40 deg/s): it swings through the front to meet them at
# once, the torso camera watches meanwhile; the time without the head on them stays short, never lost
blocked_dir[0] = 1.0
said.clear()
body.pos = [50.0, 0.0, 180.0, follow.HEAD_PITCH]
head._call, HEAD_DEG_S[0] = real_body, 40.0
w = World(person=(1.3 * math.cos(math.radians(186.0)), 1.3 * math.sin(math.radians(186.0))), fov=True)
follow.torso_people = w.torso_view
samples, _ = watch(w, 8.0)
follow.stop()
assert wait_end(3.0) and not said, said
head._call, HEAD_DEG_S[0], follow.torso_people = body.call, 70.0, (lambda: [])
head_blind = sum(b[0] - a[0] for a, b in zip(samples, samples[1:]) if abs(a[4]) > HALF_FOV)
unseen = max(s[5] for s in samples) # longest without a sighting
assert head_blind < 4.0 and unseen < 2.5, (head_blind, unseen)
assert abs(samples[-1][4]) < 15.0, samples[-1] # on them at the end
print(f"turn round, real head speed: head off them {head_blind:.1f} s, without a sighting at most {unseen:.1f} s")
fetch.turn_hits = turn_hits
# an ordinary turn (the person standing 120 deg to the left, the head on them, a head as slow as the real one): the
# base turns at up to joy_control's 1.0 rad/s but never faster than the head keeps them in its camera's view
said.clear()
body.pos = [50.0, 0.0, 120.0, follow.HEAD_PITCH]
head._call, HEAD_DEG_S[0] = real_body, 40.0
w = at(120.0)
w.fov = True
samples, _ = watch(w, 7.0)
follow.stop()
assert wait_end(3.0) and not said, said
head._call, HEAD_DEG_S[0] = body.call, 70.0
off = max(abs(s[4]) for s in samples)
top = max(abs(c[2]) for c in w.cmds)
assert follow.TURN_MAX_RS == 1.0 and top > 0.6, top # faster than before (0.6)
assert off < HALF_FOV - 7.0, max(samples, key=lambda s: abs(s[4])) # in view all along (their width)
assert abs(math.degrees(w.th) - 120.0) < 10.0, math.degrees(w.th)
print(f"ordinary turn, real head speed: top {top:.2f} rad/s, gaze off at most {off:.0f} deg")
# beside the charger wall (live 2026-10-30), both ways blocked on the spot: the finger tips would sweep into two
# corners 0.64 m out. Room behind: it backs up a little (the way checked), turns from there and follows; no room
# (a wall 0.35 m behind too): it says it can't turn and never drives
CORNERS = [(0.5, 0.4), (0.5, -0.4)]
said.clear()
body.pos = [50.0, 0.0, 180.0, follow.HEAD_PITCH]
P186 = (2.0 * math.cos(math.radians(186.0)), 2.0 * math.sin(math.radians(186.0)))
w = World(person=P186, obstacles=CORNERS, fov=True)
assert fetch.turn_hits(186.0) is not None and fetch.turn_hits(-174.0) is not None # blocked both ways here
follow.start(w.see, say)
t = time.time()
while time.time() - t < 15.0 and not (abs(w.sight(w.person_at())[1]) < follow.TURN_DEAD_DEG + 1.0 and w.cmds
and w.cmds[-1][2] == 0.0):
time.sleep(0.05)
follow.stop()
assert wait_end(3.0) and not said, said
backed = -sum(c[1] * min(n[0] - c[0], 0.5) for c, n in zip(w.cmds, w.cmds[1:]) if c[1] < 0.0)
assert 0.05 < backed < follow.SHIFT_MAX_M + 0.05, backed # backed up a little, straight
assert abs(w.sight(w.person_at())[1]) < follow.TURN_DEAD_DEG + 1.0, w.sight(w.person_at())
assert not any(c[1] < 0.0 and c[2] != 0.0 for c in w.cmds), "backed and turned at once"
print(f"both ways blocked, room behind: backed {backed:.2f} m, turned {math.degrees(w.th):.0f} deg to them")
said.clear()
body.pos = [50.0, 0.0, 180.0, follow.HEAD_PITCH]
WALL = [(-0.35, 0.05 * k) for k in range(-10, 11)]
w = World(person=P186, obstacles=CORNERS + WALL, fov=True)
follow.start(w.see, say)
assert wait_end(3.0) and any("can't turn" in x for x in said), said
assert all(c[1:] == (0.0, 0.0) for c in w.cmds), w.cmds
print("both ways blocked, no room: says so, never drives")
# lumi: act("stop") ends following; follow_me locks onto the person talking, refuses when it must
lumi.agv.cancel = lumi.skills.cancel = lumi.motion.stop = lambda: None
w = World(person=(3.0, 0.0))
+103
View File
@@ -0,0 +1,103 @@
"""A fully shut hand is looked at before it is called empty. Live 2026-10-30 18:26-18:30: "give me your hand", "open
your hand", the owner put a cup between the fingers, "close your hand" (AI_1 4143: the cup narrower than the belly's
closed gap, AI_1 read as on nothing), then "put the cup on the table" and "you are holding the cup" were answered
"my hand is empty". Replayed with fakes: the close counts the cup the camera saw between the open fingers, an order
that needs the hand takes a shut hand to carry and lets the torso camera decide, and a close on nothing (or the
person's hand seen after the close, 2026-10-23) stays empty. No robot.
.venv/bin/python tests/test_hand_check.py
"""
import tempfile
import time
import types
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import fetch
fetch.STATE_FILE = Path(tempfile.mkdtemp()) / "lumi_task.json"
OPEN = {"ai": [160.0, 489.0], "closed": False, "holding": False}
SHUT = {"ai": [4143.0, 489.0], "closed": True, "holding": False} # the live close of 18:27:03
grip, eye, arm, moves, put = dict(OPEN), {"sees": "object"}, {"pose": "give"}, [], []
fetch.gripper.state = lambda: dict(grip)
fetch.gripper.close = lambda: grip.update(SHUT) or dict(grip)
fetch.skills.hand_sees = lambda: eye["sees"]
fetch.motion.poses = lambda: {"look": [0] * 6, "carry": [1] * 6, "give": [2] * 6}
fetch._at_pose = lambda name: arm["pose"] == name
fetch.arm_route.goto = lambda target, holding=False, **kw: moves.append((target, holding)) or arm.update(pose=target)
fetch._scene = lambda fn, *a: None # the owner's hand was gone: no name for it
fetch._put_down = lambda say, on=None: put.append(on)
fetch._lift_to = fetch.head_ahead = lambda *a, **k: None
L = lumi.Lumi.__new__(lumi.Lumi)
L.fetch_status = lambda: fetch.state().get("status")
B = types.SimpleNamespace(history=[])
def reset(sees, pose="give"):
fetch._set(status="idle", step="", holding=False)
fetch.skills._held.clear()
fetch._last_held.clear()
grip.clear(), grip.update(OPEN)
eye["sees"], arm["pose"] = sees, pose
moves.clear(), put.clear()
def routed(text):
return lumi.route(text, ["home", "p1"], B, lambda: L.held_now(look=True))
# ---------- the cup put between the open fingers, then "close your hand" ----------
reset("object")
assert L.arm_pose("close") # the camera saw it between the open fingers
assert fetch.state()["holding"] and fetch.held_name() == "something", fetch.state()
assert fetch.check_hand() and not moves # "go to look position": still held, nothing moved
arm["pose"] = "look"
assert fetch.check_hand() and fetch.state()["holding"]
kind, data = routed("Put the cup on the table.") # an order that needs the hand: looked at from carry
assert kind == "hand" and data[0][0] == "place" and data[1] is True, (kind, data)
assert moves == [("carry", True)], moves # slowly, as with a cup in the hand
fetch.place()
fetch._thread.join(2)
assert put == [{"name": "dining table", "colour": None}] or put == [None], put # it went on to put it down
for t in ["You are holding the cup.", "You are holding cup.", "Look at your hand. You have a cup.", "손에 컵 있잖아"]:
assert lumi.HAND_FULL_SAID.search(t), t
for t in ["are you holding anything?", "you are holding me back", "give me your hand", "what's in your hand"]:
assert not lumi.HAND_FULL_SAID.search(t), t
# ---------- the cup taken out of the shut hand: the camera at carry sees it empty ----------
eye["sees"] = "empty"
assert not fetch.look_at_hand() and not fetch.state()["holding"]
# ---------- "close your hand" on nothing: empty; told "you are holding a cup": looked at, still empty ----------
reset("empty")
assert L.arm_pose("close") and not fetch.state()["holding"]
assert not fetch.check_hand() and not moves
assert routed("Put the cup on the table.")[0] != "hand" and moves == [("carry", True)] # looked at, then empty
try:
fetch.place()
raise AssertionError("put down with an empty hand")
except fetch.FetchError as e:
assert "empty" in e.args[0], e.args
assert not L.held_now(look=True)
# ---------- shut, the state forgot it, the person insists: the camera at carry finds it ----------
reset("object", pose="look")
grip.update(SHUT)
assert not fetch.check_hand() and not moves # from look nothing is seen there: shut = empty
assert L.held_now(look=True) and moves == [("carry", True)] and fetch.state()["holding"]
arm["pose"] = "look" # still held away from carry (the next words' check)
assert fetch.check_hand() and fetch.state()["holding"]
# ---------- 2026-10-23: closed on nothing, the person's hand by the held-out fingers after the close ----------
reset("unknown")
L.arm_pose("close")
eye["sees"] = "object"
fetch._set(holding=True, status="holding") # a stale "holding" (no close on a seen thing)
assert not fetch.check_hand() and not fetch.state()["holding"]
# ---------- AI_1 stopped on something: held, whatever the camera says ----------
reset("empty")
grip.update(ai=[3500.0, 489.0], closed=True, holding=True)
assert fetch.check_hand() and not moves
print("hand check ok (narrow cup closed on, looked at from carry, closed on nothing, the 2026-10-23 case)")
+1 -1
View File
@@ -38,7 +38,7 @@ fetch.end = lambda timeout=5.0: (done.append("end"), run.update(status="stopped"
fetch.replace = lambda steps, say=None: done.append(("replace", steps))
fetch.proceed = lambda: done.append("proceed")
fetch.run_steps = lambda steps, say=None, sender=None: done.append(("run", steps))
fetch.check_hand = lambda: run["holding"]
fetch.check_hand = fetch.look_at_hand = lambda: run["holding"]
fetch.held_name = lambda lang="en": "the cup" if lang == "en" else "컵"
lumi.agv.cancel = lambda: done.append("agv cancel")
lumi.mouth.say = lambda text, **k: done.append(("say", text))
+1 -1
View File
@@ -64,7 +64,7 @@ L.keep_listening = lambda: None
L.fetch_say = lambda en, ko=None: said.append(en)
L.fetch_status = lambda: None
L.modes = types.SimpleNamespace(greeter=True, patrol=False, drive=True, wave=True)
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
lumi.fetch_dialog = types.SimpleNamespace(run_steps=lambda s, hear, say, describe, start: started.append(s) or "started")
for text in ("take the cup, go to booth two, give it to James and come back", "스테이지 갔다 와",
"go to the stage, wait 10 seconds, then come back"):
+1 -1
View File
@@ -91,7 +91,7 @@ def through_answer():
mouth.say = lambda text, lang=None, abort=None: said.append(text)
lumi.ears.understood = lambda *a: True
lumi.ears.last_stt = {"language": "english", "logprob": -0.1}
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
L = lumi.Lumi.__new__(lumi.Lumi)
L.lang, L.current, L.closing_pending, L.markers = "en", None, None, ["home", "stage"]
+7
View File
@@ -102,6 +102,13 @@ L.reached_at, folds[:] = time.time(), []
assert not L.reach_done() and not folds # nothing said yet: the hand stays out
L.reached_at = time.time() - lumi.REACH_HOLD_S - 1 # nobody said anything: the timeout folds
assert L.reach_done() and folds == ["fold"]
status["now"] = "running" # still on its way after REACH_HOLD_S: no timeout
L.reached_at, folds[:] = time.time() - lumi.REACH_HOLD_S - 1, []
assert not L.reach_done() and not folds
status["now"] = "done" # the hand got there only now: the hold counts
fetch.state = lambda: {"step": "", "since": time.time()} # from then, not from the order
assert not L.reach_done() and not folds
fetch.state = lambda: {"step": "reaching out"}
status["now"] = "running" # still going toward their hand: stopped, folded
L.reached_at, folds[:] = time.time(), []
assert L.reach_done("okay thanks") and folds == ["fold"] and stops, (folds, stops)
+1 -1
View File
@@ -23,7 +23,7 @@ server.MODES_FILE = tmp / "lumi_modes.json" # never the real /dev/shm f
fetch.STATE_FILE = tmp / "lumi_task.json"
server.agv.request = server.agv.cancel = server.skills.cancel = server.arm.cmd = forbid
server.agv.markers = lambda: M
fetch.check_hand = lambda: False
fetch.check_hand = fetch.look_at_hand = lambda: False
fetch.log = lambda *a: None
done = []
server.send_to_assistant = lambda cmd, **a: done.append(cmd)