Improve attention, voice direction, reach, pick and follow from live feedback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 20:22:32 +09:00
co-authored by Claude Opus 5.5
parent 2e8dc226ff
commit e3fa2d95b3
92 changed files with 2183 additions and 307 deletions
+4 -2
View File
@@ -155,7 +155,9 @@ for t, want in [("look at me", "me"), ("look at me please", "me"), ("eyes on me"
("look over your right shoulder", "right 180"), ("뒤 봐", "left 180"), ("뒤를 봐", "left 180"),
("뒤돌아 봐", "left 180"), ("뒤쪽 봐", "left 180"), ("뒤에 봐 줘", "left 180"), ("고개 뒤로 돌려", "left 180"),
("오른쪽 뒤 봐", "right 180"), ("back side 봐", "left 180"), ("뒤 좀 look 해 줘", "left 180"),
("look forward", "center"), ("look ahead", "center")]:
("look forward", "center"), ("look ahead", "center"),
("I am your right side.", "right"), ("I'm on your left side", "left"), ("I'm behind you", "left 180"),
("나 오른쪽에 있어", "right"), ("나 여기 왼쪽이야", "left")]: # where the speaker stands: the head turns there
alts = " | ".join("talk" if w.strip() == "talk" else f"action:look {w.strip()}" for w in want.split("|"))
both("look", [t], alts)
@@ -227,7 +229,7 @@ for t in ["How many people work at Cutshion company?", "how many people work at
"쿳션에는 몇 명이 일해요?"]: # knowledge
both("question", [t], "talk")
for t in ["I'll be back", "I'm behind you", "I'll be right back"]: # "back", "behind": no head turn
for t in ["I'll be back", "I'll be right back"]: # "back": no head turn
both("question", [t], "talk | end")
# ---------- things it can't do: a plain answer, no motion ----------
+37
View File
@@ -0,0 +1,37 @@
"""Import first in a test: any connection to the robot (arm / body controller, AGV base) is refused and the test fails
at exit with where it came from, even when the code under test catches the error. `import tests.no_robot` or
`from tests import no_robot`."""
import atexit
import os
import socket
import sys
import traceback
ROBOT_HOSTS = {"192.168.10.90", "192.168.10.10"} # arm / body controller, AGV base (CLAUDE.md "Addresses")
hits = [] # (host, port, the caller's frame)
def _guard(real):
def connect(sock, address, *a):
if isinstance(address, tuple) and address[0] in ROBOT_HOSTS:
frames = [f for f in traceback.extract_stack()[:-1] if "/tests/no_robot.py" not in f.filename]
ours = [f"{f.filename.rsplit('/', 1)[-1]}:{f.name}:{f.lineno}" for f in frames
if "lumi-wave" in f.filename and "site-packages" not in f.filename]
caller = " < ".join(ours[::-1][:4]) or "?" # innermost first
hits.append((address[0], address[1], caller))
raise ConnectionRefusedError(f"a test reached the robot: {address[0]}:{address[1]} from {caller}")
return real(sock, address, *a)
return connect
socket.socket.connect = _guard(socket.socket.connect)
socket.socket.connect_ex = _guard(socket.socket.connect_ex)
@atexit.register
def _report():
if hits:
for host, port, caller in dict.fromkeys(hits):
print(f"REACHED THE ROBOT: {host}:{port} from {caller}", file=sys.stderr)
sys.stderr.flush()
os._exit(1)
+2
View File
@@ -2,6 +2,7 @@
the rest on "tell me more" / "yes" right after. No robot, no speaker, no LLM. python tests/test_abilities.py"""
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import abilities as ab
from assistant import lumi
from audio import mouth
@@ -39,6 +40,7 @@ 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}
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers = ["home", "p1"] # never the base's marker list
L.lang, L.current, L.closing_pending = "en", None, None
L.brain = types.SimpleNamespace(history=[])
L.follow_stop = lambda text: False
+1
View File
@@ -1,4 +1,5 @@
"""Self-check of robot/arm.py retries, no robot: python tests/test_arm.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import arm
sent = []
+2
View File
@@ -4,6 +4,7 @@ python tests/test_arm_bank.py
Needs the embedding server (assistant/knowledge.embed starts it); nothing moves. Every arm / hand capability said in
new ways (English and Korean at every level) reads as that one motion or as nothing (the LLM then decides); hard
negatives (questions, remarks, past, negations, gestures Lumi has none of) and side words never become another motion."""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import intent_bank as ib
M = ["home", "dock2", "booth_A", "stage", "coffee_corner", "p3"]
@@ -53,6 +54,7 @@ NEVER = [ # no motion at all from the bank
("the kids want to wave at you", False), ("can my son shake your hand", False),
("shaking hands is fun", False), ("you folded your arm earlier", False), ("손 펴도 돼?", False),
("팔 접는 게 좋아", False), ("you're good at opening your hand", False),
("put your arm in tuck position", False), ("move your hand to high position", False), # not taught: the model asks
]
+63
View File
@@ -0,0 +1,63 @@
"""Self-check of the routes to `give` (manipulation/arm_route.py) with the taught poses, the measured head centre and
the offline arm kinematics (robot/kinematics.py), no robot: python tests/test_arm_give_route.py"""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from manipulation import arm_route, skills
from robot import kinematics, motion
from vision import head_cam
POSES = {"ready": [-284.35, -75.43, -52.45, -136.99, 26.46, -278.46], # data/arm_poses.json, 2026-10-27
"carry": [-280.6, -86.13, -2.58, -173.3, 85.86, 119.9],
"give": [-270.97, -86.67, -3.28, -168.9, 56.87, 128.14],
"look": [-239.15, -88.4, -29.48, 199.97, 81.4, 158.35],
"wave_out": [-239.15, -89.88, 0.5, -160.11, 77.47, -201.64],
"wave_start": [-178.86, -77.26, -2.49, -175.06, 38.21, -219.73],
"wave": [-178.86, -77.26, -17.24, -175.06, 38.37, -219.7]}
motion.poses = lambda: dict(POSES)
head_cam.head_centre = lambda: np.array([-93.0, -19.9, 356.1]) # the 2026-10-19 fit
skills._ask = kinematics.ask
arm_route.log = lambda *a: None
def names(target, now, holding=False):
return [n for n, _ in arm_route.plan(target, holding, now=list(now))]
def moved(j, joint, deg):
j = list(j)
j[joint] += deg
return j
# ---------- empty hand: the least joint travel, every move checked ----------
assert names("give", POSES["wave_start"]) == ["give"] # after a wave: straight down to give
assert names("give", POSES["wave"]) == ["give"]
assert names("give", POSES["look"]) == ["give"] # 32 deg, not look -> carry -> give (71)
assert names("look", POSES["give"]) == ["look"]
assert names("look", POSES["wave_start"]) == ["wave_out", "look"] # never look - wave_start in one move
assert names("wave_start", POSES["look"]) == ["wave_out", "wave_start"]
assert names("give", moved(POSES["carry"], 0, -8)) == ["carry", "give"] # near carry: to carry, then on
assert names("give", moved(POSES["carry"], 0, -30)) == ["carry", "give"] # far: the nearest pose first (join)
assert names("give", moved(POSES["look"], 1, 6)) == ["look", "give"]
# ---------- holding: only the EDGES, never a wave pose, the cup upright ----------
assert names("give", POSES["look"], holding=True) == ["carry", "give"]
assert names("look", POSES["give"], holding=True) == ["carry", "look"]
for start in (POSES["wave_start"], moved(POSES["wave_start"], 0, 5), moved(POSES["wave_out"], 2, 4)):
try:
route = names("give", start, holding=True)
except arm_route.RouteError:
continue # refused: nothing moves
assert not set(route) & set(arm_route.WAVE_POSES), route
prev = start
for n in route:
assert arm_route.move_problem(prev, motion.nearest(POSES[n], prev), head_cam.head_centre(), True) is None
prev = POSES[n]
assert arm_route.hops(POSES["look"], "give", leaf=True, holding=True) == ["carry", "give"] # fetch._line_holding
try:
arm_route.plan("wave_start", holding=True, now=POSES["look"])
raise AssertionError("went to a wave pose holding")
except arm_route.RouteError as e:
assert e.args == arm_route.SPILL, e.args
print("arm give route ok")
+33 -11
View File
@@ -7,6 +7,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from manipulation import arm_route, skills
from robot import arm, gripper, motion
from tasks import fetch
@@ -76,19 +77,30 @@ def refused(reason, fn, *a, **k):
edges = {frozenset(e) for e in arm_route.EDGES}
# ---------- every pair of poses: along the graph's edges, one joint move each ----------
# ---------- every pair of poses, empty hand: one checked joint move (all clear here) but look - wave_start ----------
for a in POSES:
for b in POSES:
fake = use(POSES[a])
route = arm_route.goto(b)
assert [a] + route == arm_route._path(a, b, POSES) and fake.sent == [POSES[n] for n in route], (a, b, route)
assert fake.sent == [POSES[n] for n in route] and arm_route.where(fake.j) == b, (a, b, route)
want = [] if a == b else ["wave_out", b] if {a, b} == {"look", "wave_start"} else [b]
assert route == want, (a, b, route) # look - wave_start: wave_out ties wave, EDGES first
# ... holding: along EDGES only, never a wave pose
for a in POSES:
for b in POSES:
if a in arm_route.WAVE_POSES or b in arm_route.WAVE_POSES:
continue
fake = use(POSES[a])
route = arm_route.goto(b, holding=True)
assert [a] + route == arm_route._path(a, b, arm_route.graph(True)), (a, b, route)
assert all(frozenset(p) in edges for p in zip([a] + route, route)), (a, b, route)
assert arm_route.where(fake.j) == b
use(POSES["look"])
refused(arm_route.SPILL, arm_route.goto, "wave_start", holding=True)
use(POSES["give"])
assert arm_route.goto("look") == ["carry", "look"] # after giving: give -> carry -> look
assert arm_route.goto("give") == ["carry", "give"] # to give: look -> carry -> give
use(POSES["wave"])
assert arm_route.goto("look") == ["wave_start", "wave_out", "look"] # fold: down to look
assert arm_route.goto("look", holding=True) == ["carry", "look"] # after giving: give -> carry -> look
assert arm_route.goto("give", holding=True) == ["carry", "give"] # to give: look -> carry -> give
use(POSES["wave_start"])
assert arm_route.goto("give") == ["give"] # empty after a wave: straight to give
assert not any("tuck" in e for e in arm_route.EDGES)
use(POSES["look"])
assert arm_route.goto("wave_start") == ["wave_out", "wave_start"] # up: never look -> wave_start directly
@@ -109,6 +121,8 @@ fake = use(near)
assert arm_route.goto("carry") == ["look", "carry"] and fake.sent == [POSES["look"], POSES["carry"]], fake.sent
fake = use([20.5, 0, 0, 0, 0, 0]) # within EXACT_DEG of carry: straight on
assert arm_route.goto("give") == ["give"]
fake = use([23.0, 0, 3, 0, 0, 0]) # nearer carry than give: carry first
assert arm_route.goto("give") == ["carry", "give"]
# ---------- far from every pose: one checked joint move to the nearest pose, slow; none passes: refused ----------
fake = use([60.0, 60.0, 0, 0, 0, 0])
@@ -128,10 +142,16 @@ assert arm_route.goto("look", leaf=True) == ["look"]
head["centre"] = np.array([300.0, 0.0, 0.0]) # on the way look -> carry (flange x 0 -> 600)
for start in (POSES["look"], near, POSES["give"]):
fake = use(start)
refused(arm_route.NEAR_HEAD, arm_route.goto, "give" if start != POSES["give"] else "look")
refused(arm_route.NEAR_HEAD, arm_route.goto, "give" if start != POSES["give"] else "look", holding=True)
assert fake.sent == [], fake.sent
fake = use(POSES["look"]) # empty: around it, every move checked
assert arm_route.goto("give") == ["ready", "give"], fake.sent # (ready ties wave_out)
fake = use(POSES["look"])
assert arm_route.goto("wave") == ["wave_out", "wave_start", "wave"] # other edges: clear of it
assert arm_route.goto("wave") == ["wave"] # clear of it
head["centre"] = np.array([0.0, -300.0, 300.0]) # on every way out of look: refused, why said
fake = use(POSES["look"])
refused(arm_route.NEAR_HEAD, arm_route.goto, "wave")
assert fake.sent == []
head["centre"] = None # the head not measured: nothing moves
refused(arm_route.UNSURE, arm_route.goto, "look")
head["centre"] = FAR
@@ -141,7 +161,9 @@ refused(arm_route.BLOCKED, arm_route.goto, "give")
assert fake.sent == []
POSES["give"] = [40.0, 0, 0, 0, 0, 0]
del POSES["wave_start"]
refused(arm_route.NOT_TAUGHT, arm_route.goto, "wave") # no way to wave without wave_start
del POSES["wave"]
refused(arm_route.NOT_TAUGHT, arm_route.goto, "wave_start") # not taught
POSES["wave"] = [0.0, -20, 20, 0, 20, 0]
refused(arm_route.NOT_TAUGHT, arm_route.goto, "nowhere")
POSES["wave_start"] = [0.0, -20, 20, 0, 0, 0]
@@ -195,7 +217,7 @@ arrived = [e for e in fake.log if e[0] == "get_data"][0][4]
second = [e for e in fake.log if e[0] == "joint_move"][1][4]
assert second - arrived >= motion.SETTLE_S * 0.9, second - arrived # stood at wave_out first
fake = arm.cmd = QueueArm(POSES["look"])
arm_route.goto("wave_start", holding=True)
arm_route.goto("give", holding=True)
hold = motion.JOINT_SPEED[arm_route.HOLD_SPEED]
assert order(fake) == ["joint_move", "get_data", "joint_move", "get_data"], order(fake)
assert fake.moves() == [(hold, hold * motion.JOINT_ACCEL_FACTOR, keys)] * 2 and hold < route, fake.moves()
+15
View File
@@ -4,6 +4,7 @@ holding = give; the known faults of that day; negations, later times and remarks
.venv/bin/python tests/test_arm_words.py
"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain
from tests import command_check
@@ -50,6 +51,20 @@ CASES = [ # (text, state, route)
('"give it to me" is a nice English phrase', "holding", None), ("몸 5센티만 내려 주세요", "holding", "action:lift"),
("테이블에 놔 줄래? 영상 찍고 있어", "holding", "place"), ("it's my birthday, put that back where you found it!", "holding", "action:put back"),
("Lumi buddy, any chance you could pick up the apple?", "idle", "action:pick apple"),
# 2026-10-27: taught poses by name (look = fold)
("Let's take look position.", "idle", "action:arm fold"), ("Let's put your hand look position.", "idle", "action:arm fold"),
("let's bring your hand look position", "idle", "action:arm fold"), ("let's come your hand look position", "idle", "action:arm fold"),
("look position", "idle", "action:arm fold"), ("go to look", "idle", "action:arm fold"), ("hand to look", "idle", "action:arm fold"),
("bring your hand to look position", "idle", "action:arm fold"), ("carry position", "idle", "action:arm carry"),
("put your arm in carry position", "idle", "action:arm carry"), ("carry", "idle", "action:arm carry"),
("arm to carry", "idle", "action:arm carry"), ("ready position", "idle", "action:arm ready"),
("carry position", "holding", "action:arm carry"), ("룩 포지션", "idle", "action:arm fold"), ("룩 자세로", "idle", "action:arm fold"),
("팔 룩으로", "idle", "action:arm fold"), ("캐리 자세", "idle", "action:arm carry"), ("팔 캐리로 해 줘", "idle", "action:arm carry"),
("팔 원위치", "idle", "action:arm fold"), ("팔 내려", "idle", "action:arm fold"),
("what is the look position?", "idle", None), ("can you carry this?", "idle", None), ("I like your look position", "idle", None),
("캐리 자세가 뭐야?", "idle", None), ("룩 자세로 가지 마", "idle", None), ("don't go to carry position", "idle", None),
("put your arm in tuck position", "idle", None), ("get ready", "idle", None), ("are you ready?", "idle", None),
("what does carry position mean?", "idle", None), ("look at my hand", "idle", None),
]
MOVES = ("action:", "give", "place", "receive", "mission", "chain")
+95
View File
@@ -0,0 +1,95 @@
"""Self-check of a stop word said while Lumi talks or sings (live 2026-10-27 19:21, logs/lumi_console.log): Lumi's own
voice in the clip mic kept the utterance going, so "Stop. Stop. Stop." was heard only when the 17.9 s answer ended.
A fake clip-mic stream goes through the real audio/mic.py detector and assistant/lumi.py barge_in() / song_abort();
whisper is faked (it hears "Stop." where the owner's frames are). No audio device, nothing reaches the robot:
python tests/test_barge_stop.py"""
import time
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from audio import ears, mic, mouth
from tasks import follow
LUMI, OWNER = 2000, 3001 # sample values: Lumi's voice from the speaker, the owner's word
STOP_AT, REACT_S, WHISPER_S = 3.0, 1.5, 0.5 # owner's "stop" s into the answer; allowed; one transcription
acts = []
follow.running = lambda: False
mouth.own_voice = lambda u: False # the sound match is checked in tests/test_mouth.py
lumi.mouth.recent_speech = lambda s: ""
def fake_whisper(owner_said, lumi_said):
def quick(audio):
text = owner_said if (np.abs(audio) == OWNER).any() else lumi_said
ears.last_stt.clear()
ears.last_stt.update(text=text, language="korean" if "그" in text else "english", logprob=-0.1)
return text
ears.quick = quick
def fresh(saying):
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers, L.pending_text, L.mic = ["home", "charge", "dock2"], None, mic.Mic()
L.act = lambda a, t: acts.append(a)
L.song_request = ("sing a song", time.time())
mouth._recent[:] = [(time.time(), saying)]
acts.clear()
return L
def stream(L, abort, owner=True, seconds=7.5):
"""Quiet, then Lumi talks (loud the whole time, the utterance goes on to mic.MAX_UTTERANCE) with the owner's word at STOP_AT.
Returns s from the word to the abort (whisper's time added), or None when nothing stopped Lumi."""
m, t0 = L.mic, 1000.0
frame = np.full(mic.FRAME, LUMI, np.int16)
frame[::2] *= -1
for i in range(100): # 3 s of room noise: the detector learns the floor
m._clip_frame(np.zeros(mic.FRAME, np.int16) + 50, t0 + i * 0.03)
m.speaking(True)
for i in range(int(seconds / 0.03)):
t = i * 0.03
x = frame.copy()
if owner and STOP_AT <= t < STOP_AT + 0.4:
x[x > 0], x[x < 0] = OWNER, -OWNER
m._clip_frame(x, t0 + 3.0 + t)
assert m.utterances.empty(), "Lumi's voice must keep the utterance going (the live case)"
if abort():
return t - STOP_AT + WHISPER_S
return None
# the live case: a long answer, "stop" in the middle -> stopped within REACT_S, the stop handled as before
fake_whisper("Stop. Stop.", "I know home, charge, dock2.")
L = fresh("I don't have a place called that on this map. I know: home, charge, dock2.")
took = stream(L, L.barge_in)
assert took is not None and 0 < took <= REACT_S, took
assert acts == ["stop"] and L.pending_text == "Stop. Stop.", (acts, L.pending_text)
# Lumi's own answer says "stop" and the clip mic hears it: no stop
fake_whisper("", "Stop.")
L = fresh("Press the red button to stop.")
assert stream(L, L.barge_in, owner=False) is None and not acts, acts
# ... but the owner's "stop" during that answer, heard with other words, still stops
fake_whisper("Lumi, stop now.", "Stop.")
L = fresh("Press the red button to stop.")
assert stream(L, L.barge_in) is not None and acts == ["stop"], acts
# Lumi's own words without a stop word: nothing
fake_whisper("", "I know home, charge, dock2.")
L = fresh("I know home, charge, dock2.")
assert stream(L, L.barge_in, owner=False) is None and not acts, acts
# a song, "그만" -> the song ends at once (no act: song_abort only ends the song, as before)
fake_whisper("그만.", "La la la, the sun is up.")
L = fresh("La la la, the sun is up.")
took = stream(L, L.song_abort)
assert took is not None and 0 < took <= REACT_S and not acts, (took, acts)
# a song, only the music: goes on
L = fresh("La la la, the sun is up.")
assert stream(L, L.song_abort, owner=False) is None
print("barge stop ok")
+1
View File
@@ -1,5 +1,6 @@
"""Self-check: battery questions answered from the base's live status (assistant/battery.py), EN + KO; how long it
lasts is left to the LLM (10 hours), how long charging takes is not known. Fake base: python tests/test_battery.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import battery
NOW = ["And charging?", "charging?", "battery?", "Battery", "what's your battery level?", "How much battery do you have?",
+1
View File
@@ -4,6 +4,7 @@ import re
import threading
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import chain, lumi
from tasks import fetch
+1
View File
@@ -3,6 +3,7 @@ python tests/test_come_back.py"""
import tempfile
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain
from assistant import lumi
from assistant import steps
+1
View File
@@ -8,6 +8,7 @@ import types
re._MAXCACHE = 100000 # the readers use more patterns than re's cache holds: 3x faster
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi
from tasks import fetch
+1
View File
@@ -7,6 +7,7 @@ import tempfile
import time
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, detour, lumi
from tasks import fetch
from tests.detour_cases import CASES, GOAL, M, PREFIX_EN, PREFIX_KO
+104
View File
@@ -0,0 +1,104 @@
"""Self-check of the sound direction with the clip mic as reference (audio/doa.py): a voice from one side plus a
louder noise from another, made for the six-mic ring of the calibration geometry. With the clip audio (the voice,
reaching the robot later over the radio) the direction is the voice's; audio without that voice gives the plain estimate;
head-array utterances (no reference) are estimated as before. No hardware: python tests/test_doa_clip.py"""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from audio import doa
CAL = {"radius": 0.045, "offset": 30.0, "sign": -1}
RATE = doa.RATE
rng = np.random.default_rng(1)
def voice(seconds):
"""Speech-like: harmonics of a gliding pitch, in syllables (4 per second) with pauses."""
t = np.arange(int(seconds * RATE)) / RATE
f0 = 140 + 30 * np.sin(2 * np.pi * 0.7 * t)
phase = 2 * np.pi * np.cumsum(f0) / RATE
x = sum(np.sin(k * phase) / k for k in range(1, 20))
return x * np.clip(np.sin(2 * np.pi * 2 * t), 0, None) ** 2
def at_ring(x, deg):
"""The six mics' signals of a far source at deg (head frame), by fractional delays in the spectrum."""
th, phi = np.radians(deg), np.radians(CAL["offset"] + CAL["sign"] * 60.0 * np.arange(6))
tau = -CAL["radius"] * np.cos(th - phi) / doa.SOUND
f = np.fft.rfftfreq(len(x), 1 / RATE)
X = np.fft.rfft(x)
return np.stack([np.fft.irfft(X * np.exp(-2j * np.pi * f * d), len(x)) for d in tau], 1)
def rms(x):
return float(np.sqrt(np.mean(x ** 2)))
def scene(voice_deg, noise_deg, noise_over_voice, seconds=2.5):
v = voice(seconds)
n = rng.standard_normal(len(v))
n *= noise_over_voice * rms(v) / rms(n)
mics = at_ring(v, voice_deg) + at_ring(n, noise_deg) + 0.02 * rms(v) * rng.standard_normal((len(v), 6))
return (mics * 3000 / rms(mics)).astype(np.int16), v
def clip_of(v, delay_ms):
"""What the clip mic gives: the voice, close and clean, delayed by the radio (array sample k = clip k - delay)."""
c = np.roll(v, int(delay_ms * RATE / 1000)) + 0.01 * rms(v) * rng.standard_normal(len(v))
return (c * 3000 / rms(c)).astype(np.int16)
def off(a, b):
return abs((a - b + 180) % 360 - 180)
fails = []
for voice_deg, noise_deg in [(-60, 170), (-30, 180), (-90, 150), (45, -120), (0, 120)]:
mics, v = scene(voice_deg, noise_deg, 2.0) # the noise twice as loud as the voice at the head
for delay_ms in (0, 40, -25):
ang, conf, _ = doa.estimate(mics, CAL, clip_of(v, delay_ms))
print(f"voice {voice_deg:+4d}, noise {noise_deg:+4d}, clip delay {delay_ms:+3d} ms: "
f"{ang:+5.0f} deg (confidence {conf:.2f})")
if off(ang, voice_deg) > 10 or conf < 0.12:
fails.append((voice_deg, noise_deg, delay_ms, ang, conf))
ang, conf, _ = doa.estimate(mics, CAL)
print(f" without the clip: {ang:+5.0f} deg (confidence {conf:.2f})")
assert off(ang, voice_deg) > 30, "the scene must be hard without the clip (else the test proves nothing)"
assert not fails, fails
# the clip wearer's voice is not found in the array audio: the plain estimate, as without the clip
mics, _ = scene(-60, 170, 0.5)
other = clip_of(voice(2.5)[::-1].copy(), 0)
assert doa.clip_lag(mics, other)[1] < doa.CLIP_MIN_SCORE
assert doa.estimate(mics, CAL, other) == doa.estimate(mics, CAL)
assert "clip not found" in doa.clip_note(mics, other)
mics, v = scene(-60, 170, 2.0)
assert "clip score" in doa.clip_note(mics, clip_of(v, 40))
assert doa.clip_note(mics, None) == ""
print(f"clip voice not in the array: plain estimate {doa.estimate(mics, CAL, other)[0]:+.0f} deg")
# head-array utterances: no reference, the voice alone is found as before
mics, _ = scene(-60, 170, 0.1)
ang, conf, _ = doa.estimate(mics, CAL)
assert off(ang, -60) <= 10 and conf > 0.12, (ang, conf)
assert doa.clip_ref(type("U", (), {"source": "head", "mono": "x"})) is None
doa.USE_CLIP_REF = True
assert doa.clip_ref(type("U", (), {"source": "clip", "mono": "x"})) == "x"
# calibration samples (add_sample) in a temporary folder: with the clip the wearer's voice is learnt under louder room
# noise; a clip voice not in the array is no sample; a refit worse than the saved calibration does not replace it
import json, pathlib, tempfile
tmp = pathlib.Path(tempfile.mkdtemp())
doa.CALIB, doa.SAMPLES = tmp / "calib.json", tmp / "samples.npz"
mics, _ = scene(-60, 170, 0.5)
assert doa.add_sample(mics, -60, other) is None and not doa.SAMPLES.exists()
c = None
for deg in (-40, -20, 0, 20, 40, 10):
mics, v = scene(deg, 170, 2.0)
c = doa.add_sample(mics, deg, clip_of(v, 40))
assert c and (c["sign"], c["offset"]) == (CAL["sign"], CAL["offset"]) and c["median_error_deg"] <= 4, c
doa.CALIB.write_text(json.dumps({**c, "median_error_deg": -1.0})) # a saved fit no new one can beat
mics, _ = scene(30, 170, 2.0)
assert doa.add_sample(mics, 30) is None and json.loads(doa.CALIB.read_text())["median_error_deg"] == -1.0
assert len(np.load(doa.SAMPLES)["t"]) == 7 # the sample itself is kept
print("ok")
+1
View File
@@ -1,4 +1,5 @@
"""Self-check of robot/drive_log.py with made-up base status reads, no robot: python tests/test_drive_log.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import drive_log
MARKERS = {"p10": (3.0, 0.0)}
+2
View File
@@ -5,10 +5,12 @@ import threading
import time
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, driving
from manipulation import skills
from tasks import fetch
fetch.head_ahead = lambda: None # never the real head
M = ["home", "p9"]
read = lambda text, last=None, talking=False: driving.read(brain._norm(text), last, talking)
+1
View File
@@ -4,6 +4,7 @@
"""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from audio import ears
ears.ensure_stt_server = lambda: None
+92 -6
View File
@@ -8,6 +8,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import head
assert head.LIFT_MAX_MM == 0.0 # live: the lift stays at the bottom (head camera cable); the cases below are the long cable's
head.LIFT_MAX_MM, head.AXIS_LIMITS = 105.0, ((0.0, 105.0),) + head.AXIS_LIMITS[1:]
@@ -610,8 +611,8 @@ assert fetch.turn_hits(90) is None
real_points, real_extr = skills.surface_points, skills.objects.base_from_camera
skills.objects.base_from_camera = lambda: np.eye(4)
skills.surface_points = lambda pts, guess_z=-400.0, **kw: [tuple(p) for p in pts] # depth right at each point
calls.clear()
assert fetch._turn(30) is False and not any(c[0] == "go_point" for c in calls)
calls.clear() # 40 deg: the toy hand (0.23 m out) sweeps past SELF_MM of itself
assert fetch._turn(40) is False and not any(c[0] == "go_point" for c in calls)
skills.surface_points = lambda pts, guess_z=-400.0, **kw: [tuple(np.array(p) * 3) for p in pts] # only far behind them
assert fetch.depth_hits(30) is None
# only the head camera, turned to the side of the turn, sees something in the arm's way: no turn; the head stays there
@@ -630,8 +631,8 @@ fetch.head.moveto = head_move
fetch.head_cam.base_from_head = lambda yaw, pitch: np.eye(4)
skills.surface_points = lambda pts, guess_z=-400.0, camera="torso", T=None: \
[tuple(p) if camera == "head" else None for p in pts]
calls.clear()
assert fetch._turn(-30) is False and not any(c[0] == "go_point" for c in calls)
calls.clear() # 40 deg, as above: past SELF_MM of the toy hand
assert fetch._turn(-40) is False and not any(c[0] == "go_point" for c in calls)
assert heads == [(-fetch.HEAD_SIDE_DEG, fetch.HEAD_LOW_PITCH)], heads # no move back: the next look turns it
skills.surface_points = lambda pts, guess_z=-400.0, **kw: [None] * len(pts)
@@ -974,7 +975,7 @@ scene["person_in_front"] = {"position_mm": ahead(900.0), "hands": {"left": {"pos
"distance_m": 1.1}, "right": {"position_mm": ahead(400.0), "distance_m": 0.9}}}
turns = []
real_waist_to = fetch._waist_to
fetch._waist_to = lambda deg: turns.append(deg) or deg < 90
fetch._waist_to = lambda deg, in_place=False, look=None: turns.append(deg) or in_place and deg < 90 # in place
def reached(angle=0.0):
@@ -998,8 +999,10 @@ assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, move
scene["person_in_front"] = None # nobody seen: the hand at give
st, moves = reached()
assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, moves)
st, moves = reached(40.0) # to the side (Patrol): the waist turns first, by the
fetch.stay_put = True # Greeter only: the waist still turns (the base stays)
st, moves = reached(40.0) # to the side: the waist turns first, by the
assert turns == [40.0 + fetch._waist_turn()] and poses()[-1] == "give", (turns, poses()) # waist's offset too
fetch.stay_put = False
turns.clear()
said.clear()
st, moves = reached(120.0) # the waist turn refused (sweep): the arm stays
@@ -1008,6 +1011,30 @@ turns.clear()
st, moves = reached(160.0) # past the waist's limit (-15 + 160 > 140): stand in front
assert st["status"] == "failed" and not turns and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, turns)
fetch._waist_to = real_waist_to
# the head on the person through the whole reach (live: the waist turned with the head kept at +46 on it, so the
# head looked 90 deg left, away, until head_ahead at the end): Greeter only, person at -40 deg (waist frame), the
# head on them; the sweep check turns the head to that side (head_hits); every head command looks their way, the
# last one right at them (head yaw = -40 - the waist's turn), and nothing turns it ahead after
real_status, real_move, real_blocked = fetch.head.status, fetch.head.moveto, fetch._sweep_blocked
hp = {"waist": -15.0, "yaw": -40.0, "pitch": 10.0}
gaze = [] # waist-frame (as before the turn) angle of each command
fetch.head.status = lambda: [75.0, hp["waist"], hp["yaw"], hp["pitch"]]
def head_cmd(pos, **kw):
hp.update(waist=pos[1], yaw=pos[2], pitch=pos[3])
gaze.append(pos[1] + 15.0 + pos[2])
fetch.head.moveto = head_cmd
fetch._sweep_blocked = lambda deg, what: head_cmd([75.0, hp["waist"], math.copysign(fetch.HEAD_SIDE_DEG, deg),
fetch.HEAD_LOW_PITCH]) and False
fetch.stay_put = True
st, moves = reached(-40.0)
assert st["status"] == "done" and poses()[-1] == "give", st
assert hp["waist"] == -55.0 and hp["yaw"] == 0.0 and hp["pitch"] == 10.0, hp
assert gaze[-1] == -40.0 and all(g < 0 for g in gaze), gaze
gaze.clear()
st, moves = reached(0.0) # in front: no waist turn, the head left on them
assert st["status"] == "done" and not gaze and hp["yaw"] == 0.0, gaze
fetch.stay_put = False
fetch.head.status, fetch.head.moveto, fetch._sweep_blocked = real_status, real_move, real_blocked
fetch._line_rows, fetch._scene = real_line_rows, real_scene
hand["front"] = False
# the cup is in the hand but nobody says okay: the hand never closes (their fingers may be in it)
@@ -1275,4 +1302,63 @@ fetch._set(holding=False, status="idle")
skills._held.clear()
fetch._scene, skills.on_table = real_scene, real_on_table
# ---------- the voice pick (pick_here): trusted turns only; here, the waist in place, the base with Patrol, or ask ----
real = {k: getattr(fetch, k) for k in ("_waist_to", "waist_for", "turned", "_approach", "pick_goal", "at_edge",
"_see_again")}
yaws = []
def trusted_x(obj, start=None, accept=None, max_yaw=None): # reached only from x > 0 (after the waist turn)
yaws.append(max_yaw)
return (skills.plan_pick(obj), [0.0] * 6) if obj["x"] > 0 or reach["ok"] else None
skills.reachable_pick = trusted_x
fetch._waist_to = lambda rel, in_place=False: calls.append(("waist", in_place)) or in_place or not fetch.stay_put
fetch.waist_for = lambda obj: [40.0]
fetch.turned = lambda obj, deg: {**obj, "x": obj["x"] + 300.0}
fetch._approach = lambda obj, yaw, tried, **kw: calls.append(("approach",)) or False # as near as the base brings it
fetch.pick_goal = lambda obj: fetch.PICK_ZONE_CENTRE
fetch.at_edge = lambda obj: False
fetch._see_again = lambda task, mem, yaw, say: dict(CUP)
fetch.CALIB_FILE.write_text(json.dumps({"arm_yaw_in_base_deg": -86.2}))
base_moves = lambda: [c for c in calls if c[0] in ("approach", "go", "go_point", "joy")]
for patrol in (False, True):
fetch.stay_put = not patrol
reset()
fetch.CALIB_FILE.write_text(json.dumps({"arm_yaw_in_base_deg": -86.2}))
calls.clear(), yaws.clear()
skills.look = lambda frames=None, **kw: []
assert fetch.pick_here("apple", "red", say)["x"] == CUP["x"] # in reach from here: nothing turns
assert ("pick", "apple") in calls and not [c for c in calls if c[0] == "waist"] and not base_moves(), calls
reach["ok"] = False # only after a waist turn
calls.clear(), yaws.clear()
skills.look = lambda frames=None, **kw: [fetch.turned(dict(CUP), 40.0)] if ("waist", True) in calls else []
assert fetch.pick_here("apple", "red", say)["x"] > 0
assert ("waist", True) in calls and ("pick", "apple") in calls and not base_moves(), calls
assert None not in yaws, yaws # never an untrusted grasp turn
fetch.waist_for = lambda obj: [] # no waist turn reaches it either
skills.look = lambda frames=None, **kw: []
for patrol in (True, False):
fetch.stay_put = not patrol
calls.clear(), yaws.clear(), said.clear()
try:
fetch.pick_here("apple", "red", say)
raise AssertionError("picked out of reach")
except fetch.FetchError as e:
assert e.args[0] == "I still can't reach it.", e.args
assert bool(base_moves()) == patrol, (patrol, calls) # Patrol on: the base came closer first
assert said[-1] == "I can't reach it, please move it closer to me." and None not in yaws, (said, yaws)
assert not [c for c in calls if c[0] in ("pick", "line", "waist") or c[0] == "pose" and not patrol], calls
# the arm never moved (to look only before a base move)
fetch.stay_put = False
for k, v in real.items():
setattr(fetch, k, v)
skills.reachable_pick = fake_reachable
reset()
print("fetch ok")
# ---------- STOP after a restart mid-task: the file of a run that is gone says "running", STOP ends it ----------
fetch._state["status"], fetch._thread = "idle", None
fetch.STATE_FILE.write_text(json.dumps({"status": "running", "step": "picking", "holding": False, "log": ["13:07:50 picking"]}))
fetch.skills.cancel = fetch.agv.cancel = lambda: None
fetch.stop()
assert fetch.state()["status"] == "stopped" and fetch.state()["log"][-1].endswith("stopped"), fetch.state()
print("stale run stopped ok")
+1
View File
@@ -5,6 +5,7 @@ import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import no_robot # noqa: F401 any connection to the robot fails the test
from tests import pick_sweep as ps
ps.install()
+1
View File
@@ -1,6 +1,7 @@
"""Self-check of the voice side of fetch tasks (docs/16 §4), no robot, no audio: python tests/test_fetch_intents.py"""
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, fetch_dialog
M = ["p1", "p2", "p3", "home", "final"]
+2
View File
@@ -4,6 +4,7 @@ import math
import tempfile
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain
from manipulation import skills
from tasks import fetch
@@ -12,6 +13,7 @@ from vision import objects
tmp = Path(tempfile.mkdtemp())
fetch.STATE_FILE = tmp / "lumi_task.json" # never the real /dev/shm file
fetch.CALIB_FILE = tmp / "fetch_calib.json"
fetch._charging = lambda: True # on the charger: no backing off to look (never the base)
skills.arm.cmd = lambda *a, **kw: (_ for _ in ()).throw(AssertionError(f"real arm command in a test: {a}"))
fetch.head.moveto = lambda *a, **kw: (_ for _ in ()).throw(AssertionError("real lift move in a test"))
+1
View File
@@ -5,6 +5,7 @@ import threading
import time
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from manipulation import skills
from tasks import fetch
+1
View File
@@ -13,6 +13,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from manipulation import skills
from tasks import fetch
from vision import head_cam
+1
View File
@@ -4,6 +4,7 @@
2. steps.rules: cup tasks of several parts (fetch then more, deliver and come back, put it at a place, wait until
someone takes it, Korean calls / endings of every level, Korean written without spaces).
Notation of tests/test_steps.py."""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, steps
+180
View File
@@ -0,0 +1,180 @@
"""Self-check of the focus on one person (live 2026-10-27 19:22-19:28): once someone calls, gives an order or says
"look at me", the head stays on them as they move; a newcomer (even waving) is not greeted or looked at; someone else
takes over only with a call, a stop word or an order said from their direction. Fake vision, head, base and mic;
nothing reaches the robot: python tests/test_focus.py"""
import threading
import time
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
M = ["home", "dock2"] + [f"p{i}" for i in range(1, 11)]
S = lumi.HEAD_SIGN
moves, said, base = [], [], {"move_status": "idle"}
lumi.head.status = lambda: [0.0, 0.0, 0.0, 20.0]
lumi.head.turn = lambda yaw, pitch=None, **k: moves.append(round(yaw))
lumi.mouth.say = lambda text, **k: said.append(text)
lumi.LOOK_ME_SETTLE_S = 0.0
up = [] # bearings of raised hands the fake pose net sees
lumi.hands_up = lambda frames: list(up)
import vision.scene as scene # noqa: E402
scene.snapshot = lambda cams: []
class Track:
def __init__(self, id, angle, distance=1.2):
self.id, self.angle, self.distance, self.greeted, self.person = id, angle, distance, False, None
class Vision:
camera, pinned = "head", True
def __init__(self, *tracks):
self.tracks = list(tracks)
self.det = types.SimpleNamespace(focus_angle=None)
def near_angle(self, a, d=lumi.SPEAKER_MATCH_DEG):
return min((t for t in self.tracks if abs(t.angle - a) <= d), key=lambda t: abs(t.angle - a), default=None)
def present(self, t):
return t in self.tracks
def to_greet(self):
return next((t for t in self.tracks if not t.greeted), None)
def only_person(self):
return self.tracks[0] if len(self.tracks) == 1 else None
def nearest_greeted(self):
return next((t for t in self.tracks if t.greeted), None)
def seen(self):
return [(t.angle, t.distance) for t in self.tracks]
def head_person(self, angle, since):
return None
def know(self, t):
return types.SimpleNamespace(talking=False), None
def fresh(*tracks):
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers, L.lang, L.current, L.pending_text, L.patrol = M, "en", None, None, None
L.vision, L.mic = Vision(*tracks), types.SimpleNamespace(next=lambda timeout: None)
L.modes = types.SimpleNamespace(greeter=True, patrol=True, drive=True, refresh=lambda: None)
L.voice_until = L.quiet_until = L.calib_until = 0.0
L.last_activity, L.closing_pending, L._yaw, L._yaw_time = time.time(), None, 0.0, time.time() + 1e6
L.skill_thread, L.prompts, L.wave_checked = None, 0, 0.0
L.poll_commands = L.say_stuck = lambda: None
L.reach_done = lambda: False
L.publish_busy = lambda what: None
L.talk_turn = lambda: False
L.brain = types.SimpleNamespace(reset=lambda: None, history=[])
moves.clear(), said.clear(), up.clear()
return L
def settle():
time.sleep(0.2) # turn_head moves the head in a thread
# ---- talking with #1 (right), #2 walks in on the left and waves: no greeting, the head stays on #1 as they move ----
L = fresh(a := Track(1, 30.0))
a.greeted, L.current = True, a
L.vision.tracks.append(b := Track(2, -40.0))
up.append(-40.0)
for _ in range(3):
L.step()
L.wave_checked = 0.0
assert lumi.GREETING not in said and L.current is a and not b.greeted, said
a.angle = 45.0
L.focus_step()
settle()
assert moves == [S * 45], moves # the head follows #1, never #2
moves.clear()
L._yaw = S * 45
L.focus_step() # still on them: no move
settle()
assert moves == [], moves
# ---- the voice near #2: plain words keep the focus on #1; "stop", "Lumi" or an order hand it to #2 ----
lumi.doa.load_calib = lambda: {"fitted": True}
lumi.doa.clip_ref = lambda u: None
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.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")
for text, takes in (("The weather is nice today.", False), ("Stop.", True), ("Lumi, over here.", True),
("Go to p3.", True), ("I like your colour.", False)):
L = fresh(a := Track(1, 30.0), b := Track(2, -40.0))
a.greeted, L.current = True, a
L.who_spoke(U, text)
settle()
assert (L.current is b) == takes and (moves == [S * -40] if takes else moves == []), (text, L.current.id, moves)
# ---- "look at me" (19:24:16): focus on the person found; a newcomer does not take the head; the head follows the
# looked-at person over the held look, also when their track gets a new id (#5 -> #7) ----
L = fresh(a := Track(5, -19.0, 1.15))
L.voice_angle, L.voice_trusted = -62.0, True
L.looked_at = time.time() # act("look", "me") holds the look
L.look_at_speaker()
assert L.current is a and L.look_me is a and a.greeted, (L.current, getattr(L, "look_me", None))
L.vision.tracks.append(b := Track(6, 40.0))
up.append(40.0)
moves.clear()
for _ in range(3):
L.step()
L.wave_checked = 0.0
assert lumi.GREETING not in said and L.current is a, said
L._yaw = S * -19
a.angle = -35.0 # they step aside
L.focus_step()
settle()
assert L.look_held() and moves == [S * -35], moves # over the held look: it was them
L.vision.tracks.remove(a)
L.vision.tracks.append(a2 := Track(7, -33.0, 1.15))
L.step()
assert L.current is a2 and L.look_me is a2, L.current.id
# a "look left" hold is not a person: the head stays where asked
L.look_me, L._yaw = None, S * 60
moves.clear()
L.focus_step()
settle()
assert moves == [], moves
# ---- "come here" with the look held: the head stays on the caller while the base drives ----
lumi.agv.cancel = lambda: None
lumi.agv.status = lambda: dict(base)
lumi.agv.pose = lambda: (0.0, 0.0, 0.0)
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
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
base["move_status"] = "running"
threading.Timer(1.5, lambda: base.update(move_status="succeeded")).start()
L.come_to(L.current, say=True)
settle()
assert moves and set(moves) == {S * -19}, moves
# ---- after turning to the voice: the person nearest its side, not the nearest one far off it ----
heads = []
lumi.time.sleep, real_sleep = (lambda s: None), lumi.time.sleep
L = fresh(Track(9, -50.0, 0.8), Track(10, 38.0, 2.5))
L.vision.near_angle = lambda a, d=lumi.SPEAKER_MATCH_DEG: None
L.vision.seen = lambda: [(-50.0, 0.8), (38.0, 2.5)]
L.det_yaw = lambda: 0.0
L.turn_head = lambda yaw=None, pitch=None, force=False: heads.append((round(yaw), force))
L.find_caller(50.0, True)
lumi.time.sleep = real_sleep
assert heads == [(S * 50, True), (S * 38, True)], heads
print("focus ok")
+117 -7
View File
@@ -10,6 +10,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi
from robot import agv, head, motion
from tasks import fetch, follow
@@ -35,6 +36,7 @@ fetch.head_ahead = lambda: None
fetch.arm_yaw = lambda: -86.0
ARM = [np.array([0.44, 0.0]), np.array([0.52, 0.0]), np.array([0.60, 0.0])] # flange, grasp point, tips (m)
fetch.arm_points = lambda: ARM
fetch._waist_turn = lambda: head.status()[1] # the waist's front reads 0
class Body:
@@ -120,6 +122,7 @@ class World:
return None
d, a = self.sight(self.person_at())
self.dist.append(d)
a -= body.pos[1] # lumi.Vision gives waist-frame angles
if self.fov and abs(a - body.pos[2]) > HALF_FOV:
return None
return d, a, 0.0, self.look
@@ -280,12 +283,12 @@ print("arm off: follows, powered off refuses")
# any other failure in prepare: said, the base at 0, the head free again, the thread ends
said.clear()
fetch._waist_front = lambda: 1 / 0
drive_pose, fetch._drive_pose = fetch._drive_pose, (lambda: 1 / 0)
w = World()
follow.start(w.see, say)
assert wait_end(1.0) and said and "went wrong" in said[0] and w.cmds and w.cmds[-1][1:] == (0.0, 0.0), said
assert head.owners == ()
fetch._waist_front = lambda: None
fetch._drive_pose = drive_pose
print("failure in prepare: said, stopped")
# the person walks around to behind (radius 2 m, 0 -> 150 deg in 6 s), seen by the head camera only: the head turns
@@ -491,13 +494,120 @@ follow.TURN_MAX_RS = turn_max
assert follow.running() and not said, said
follow.stop()
assert wait_end(0.5)
yaws = [m[4] for m in body.moves if m[1] == "follow head"]
assert max(yaws) > 90.0 and all(abs(y) <= 180.0 for y in yaws), yaws # past the side
assert all(abs(b - a) < 90.0 for a, b in zip(yaws, yaws[1:])), yaws # never swung round
moves = [m for m in body.moves if m[1] == "follow head"]
yaws, gaze = [m[4] for m in moves], [m[3] + m[4] for m in moves]
assert max(gaze) > 90.0, gaze # past the side
assert all(abs(b - a) < 90.0 for a, b in zip(gaze, gaze[1:])), gaze # never swung round
assert math.degrees(w.th) > 120.0 and w.dist[-1] < follow.FOLLOW_GAP_M + 0.4, (math.degrees(w.th), w.dist[-1])
print(f"past the side to behind: head up to {max(yaws):.0f} deg, base turned {math.degrees(w.th):.0f} deg, "
print(f"past the side to behind: waist + head up to {max(gaze):.0f} deg, base turned {math.degrees(w.th):.0f} deg, "
f"gap {w.dist[-1]:.2f} m")
# owner, live: the head waited for a slow stepwise waist and lost the person. Now head, waist and base all at once:
# the person right behind (170 deg) -> the first move puts head + waist on them (the head not held to HEAD_REL_MAX),
# the waist keeps turning move after move while the base turns, the base forward only once they are ahead
assert follow.waist_for(10.0) == 0.0 and follow.waist_for(-70.0) == -40.0 and follow.waist_for(170.0) == 90.0
def at(deg, r=2.0):
return World(person=(r * math.cos(math.radians(deg)), r * math.sin(math.radians(deg)))) # seen (torso)
def person_deg(w):
x, y, th = w.pose()
p = w.person_at()
return (math.degrees(math.atan2(p[1] - y, p[0] - x) - th) + 180.0) % 360.0 - 180.0
def watch(w, secs):
"""[(t, waist, head yaw, base deg, gaze off the person deg)] every 20 ms; the angle of every forward command."""
samples, ahead, request = [], [], w.request
def req(cmd):
out = request(cmd)
if w.cmds and w.cmds[-1][1] > 0.0:
ahead.append(person_deg(w))
return out
w.request = agv.request = req
follow.start(w.see, say)
t0 = time.time()
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))
time.sleep(0.02)
return samples, ahead
said.clear()
body.moves.clear()
w = at(170.0)
samples, ahead = watch(w, 8.0)
assert follow.running() and not said, said
follow.stop()
assert wait_end(0.5)
moves = [m for m in body.moves if m[1] == "follow head"]
first = moves[0]
assert 0.0 < first[3] <= follow.WAIST_STEP_DEG and first[4] > 90.0 and abs(first[3] + first[4] - 170.0) < 10.0, first
assert max(abs(s[4]) for s in samples[5:]) < 15.0, max(abs(s[4]) for s in samples[5:]) # gaze on them
turning = [s for s in samples if 10.0 < s[3] < 90.0] # the base turning ...
assert turning and max(s[1] for s in turning) >= 3 * follow.WAIST_STEP_DEG, turning[:3] # ... the waist too
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
assert ahead and max(abs(a) for a in ahead) <= follow.TURN_ONLY_DEG + 5.0, max(abs(a) for a in ahead)
assert abs(body.pos[1]) < 1e-6 and abs(body.pos[2]) <= follow.TURN_DEAD_DEG + follow.HEAD_STEP_DEG, body.pos
assert abs(math.degrees(w.th) - 170.0) < 10.0 and w.dist[-1] < follow.FOLLOW_GAP_M + 0.3, (math.degrees(w.th), w.dist[-1])
print(f"behind 170 deg: first move waist {first[3]:+.0f} head {first[4]:+.0f}, waist up to "
f"{max(s[1] for s in samples):.0f} deg while the base turned, forward only within {max(map(abs, ahead)):.0f} deg")
# "look behind" turned the waist and the head to the owner, then "follow me": nothing turns away from them
said.clear()
body.moves.clear()
body.pos = [50.0, 120.0, 50.0, follow.HEAD_PITCH] # on them at 170 deg
w = at(170.0)
samples, _ = watch(w, 4.0)
follow.stop()
assert wait_end(0.5) and not said, said
assert max(abs(s[4]) for s in samples) < 15.0, max(samples, key=lambda s: abs(s[4])) # from the very start
moves = [m for m in body.moves if m[1] == "follow head"]
assert all(abs(m[3] + m[4] - 170.0) < 60.0 for m in moves[:3]), moves[:3]
print(f"start turned to the owner: gaze off at most {max(abs(s[4]) for s in samples):.0f} deg")
# stopped with the waist turned: it comes back to the front (sweep checked), the head to rest
body.moves.clear()
w = at(70.0)
follow.TURN_MAX_RS, turn_max = 0.05, follow.TURN_MAX_RS # a slow base
follow.start(w.see, say)
time.sleep(0.6)
assert body.pos[1] > 10.0, body.pos
follow.stop()
assert wait_end(1.0)
follow.TURN_MAX_RS = turn_max
assert body.moves[-1][3:] == (0.0, 0.0, head.HEAD_REST_PITCH), body.moves[-1]
print("stopped turned: waist back to the front")
# the arm's sweep blocked for the waist, or the arm not in look: the waist stays, the head alone goes on them
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
else:
calls = iter([True]) # ready() sees it in look, then
fetch._at_pose = lambda name: next(calls, False) # it is moved out (by hand)
w = at(70.0)
follow.TURN_MAX_RS, turn_max = 0.05, follow.TURN_MAX_RS
follow.start(w.see, say)
time.sleep(1.5)
follow.stop()
assert wait_end(1.0)
follow.TURN_MAX_RS = turn_max
moves = [m for m in body.moves if m[1] == "follow head"]
assert all(m[3] == 0.0 for m in moves), moves # the waist stays
yaws = [m[4] for m in moves]
assert max(yaws) > 60.0, yaws # the head alone on them
fetch.turn_hits, fetch._at_pose = turn_hits, (lambda name: True)
print(f"waist {why}: stays at the front, head up to {max(yaws):.0f} deg")
# right behind: the angle flips between +179 and -179; the head and the base keep one side
said.clear()
body.moves.clear()
@@ -518,7 +628,7 @@ assert yaws and all(y > 0 for y in yaws[1:]), yaws
print("right behind: one side")
# lumi: act("stop") ends following; follow_me locks onto the person talking, refuses when it must
lumi.agv.cancel = lumi.skills.cancel = lumi.arm.stop = lambda: None
lumi.agv.cancel = lumi.skills.cancel = lumi.motion.stop = lambda: None
w = World(person=(3.0, 0.0))
follow.start(w.see, say)
time.sleep(0.1)
+27 -7
View File
@@ -3,15 +3,18 @@ no robot, no audio: python tests/test_follow_listen.py"""
import threading
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import follow
from tasks import fetch, follow
done, heard = [], []
fetch.stop = lambda: None # the real one cancels the arm and the base, writes the live task file
fetch._waist_turn = lambda: 0.0 # the waist at the front (the real one asks the body API)
follow.running = lambda: run["on"]
follow.followed_angle = lambda: run["angle"]
follow.stop = lambda: done.append("follow stop")
lumi.doa.load_calib = lambda: {"fitted": True}
lumi.doa.estimate = lambda mics, cal: (mics, 0.5, None) # the fake mics carry the voice angle (head frame)
lumi.doa.estimate = lambda mics, cal, ref=None: (mics, 0.5, None) # the fake mics carry the voice angle (head frame)
lumi.mouth.say = lambda text, **k: done.append(("say", text))
lumi.mouth.recent_speech = lambda s=30.0: ""
lumi.ears.understood = lambda *a: True
@@ -41,6 +44,12 @@ class Vision: # someone at -60 deg besides the
def present(self, t):
return True
def seen(self):
return [(self.stranger.angle, 1.0)]
def head_person(self, angle, since):
return None
def to_greet(self):
return None
@@ -109,16 +118,27 @@ for by_clip in (True, False):
run["on"] = False
L = fresh("What time is it?", -70.0)
assert L.talk_turn() and heard == ["What time is it?"] and L.current is L.vision.stranger, (heard, L.current)
# "look at me" / "이쪽 봐": the head turns to this turn's voice (a person there, or the voice out of view), never the centre
for deg, want in ((40.0, 50.0), (-70.0, -60.0)):
# "look at me" / "이쪽 봐": the head turns to this turn's voice first; nobody there: to the person seen (-60)
lumi.head.turn = lambda yaw, pitch=None: done.append(("head turn", round(yaw)))
lumi.LOOK_ME_SETTLE_S = 0.0
def looked(L, want):
end = time.time() + 2.0 # act() turns the head in a thread
while [d for d in done if d[0] == "head turn"] != want and time.time() < end:
time.sleep(0.01)
return [d for d in done if d[0] == "head turn"] == want
for deg, want in ((40.0, [50, -60]), (-70.0, [-60])):
L = fresh("이쪽 봐 줘", deg)
L.answer = lambda text: lumi.Lumi.act(L, "look", "me")
L.base_off, L.mission_running = (lambda *a, **k: False), (lambda: False)
assert L.talk_turn() and ("head", (want, 10)) in done, (deg, done)
lumi.doa.load_calib = lambda: {"fitted": False} # no sound direction, nobody seen: the head stays
assert L.talk_turn() and looked(L, [("head turn", w) for w in want]), (deg, done)
lumi.doa.load_calib = lambda: {"fitted": False} # no sound direction: the person seen
L = fresh("look at me", 10.0)
L.answer = lambda text: lumi.Lumi.act(L, "look", "me")
L.base_off, L.mission_running = (lambda *a, **k: False), (lambda: False)
assert L.talk_turn() and ("head", (None, 10)) in done, done
assert L.talk_turn() and looked(L, [("head turn", -60)]), done
lumi.doa.load_calib = lambda: {"fitted": True}
print("follow listen ok")
+1
View File
@@ -10,6 +10,7 @@ import re
import sys
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi, seeing, web
from tests.conversation_check import NOW, rules_route
from tests.followup_cases import CASES
+1
View File
@@ -1,4 +1,5 @@
"""Self-check of robot/gripper.py's finger gap from AI_1 (no robot): python tests/test_gripper.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import gripper as g
assert g.gap_mm(g.AI_OPEN) == 96.0 and g.gap_mm(g.AI_SHUT) == 70.0 # belly, open / closed (tape)
+1
View File
@@ -5,6 +5,7 @@ PUT_BACK), the arm words (reach / fold), and the hard negatives that must not mo
"""
import itertools
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain
MARKERS = ["home", "dock2", "p1", "p3", "booth_A", "stage", "Gate_A3"]
+1
View File
@@ -2,6 +2,7 @@
Needs the embedding server (assistant/knowledge.embed starts it); nothing moves. Guards first, then readings on maps
with other marker names (any map, not p1..p10), then words that must never become a motion."""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import intent_bank as ib
EXPO = ["home", "dock2", "booth_A", "booth_B", "entrance", "stage", "coffee_corner", "info_desk"]
+21 -1
View File
@@ -1,9 +1,13 @@
"""Self-check of the keyword rules in brain.intent() for arm and object commands, no robot: python tests/test_intents.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain
CASES = {
"Lumi, pick up the white cup": ("pick", "white cup"),
"take the cup please": ("pick", "cup"),
"Can you take the cup?": ("pick", "cup"), "Let's take the cup.": ("pick", "cup"), "Take the cup.": ("pick", "cup"),
"pick up the cup": ("pick", "cup"), "컵 집어 줘": ("pick", "cup"), "컵 잡아": ("pick", "cup"),
"Can you take a photo?": None, "Take care.": None, "Take a look.": None, "Take a cup of coffee.": None,
"can you hold the mug": ("pick", "cup"),
"pick up the orange": ("pick", "orange"),
"pick up the orange cup": ("pick", "orange cup"),
@@ -76,6 +80,8 @@ CASES.update({ # any wording of the body commands, English, Korean and mixed (
"reach out your hand": ("arm", "reach"), "stretch out your arm": ("arm", "reach"), "fold your arm": ("arm", "fold"),
"put your arm down": ("arm", "fold"), "팔 뻗어": ("arm", "reach"), "팔 접어": ("arm", "fold"), "팔 내려": ("arm", "fold"),
"open your hand": ("arm", "open"), "close your hand": ("arm", "close"), "손 펴": ("arm", "open"), "손 쥐어": ("arm", "close"),
"let's take look position": ("arm", "fold"), "put your arm in carry position": ("arm", "carry"), "캐리 자세": ("arm", "carry"),
"룩 자세로": ("arm", "fold"), "what is the look position?": None, "put your arm in tuck position": None,
# lift
"raise yourself": ("lift", "up"), "lift yourself up": ("lift", "up"), "lower yourself a bit": ("lift", "down small"),
"raise yourself 5 cm": ("lift", "up 50"), "get taller": ("lift", "up"), "make yourself shorter": ("lift", "down"),
@@ -109,8 +115,19 @@ CASES.update({ # looking behind (2026-10-21 live: "look at the back side" was
"look forward": ("look", "center"), "look ahead": ("look", "center"), "turn around and look at me": ("look", "me"),
"turn around": ("turn", "around 180"), "뒤로 돌아 봐": ("turn", "around 180"), "back up 1 m": ("move", "back 1"),
"what's behind you?": None, "who is behind you?": None, "뒤에 뭐 있어?": None, "뒤에 누가 있어?": None,
"I'll be back": None, "I'm behind you": None, "look back at me": None, "look at the back of the box": None,
"I'll be back": None, "look back at me": None, "look at the back of the box": None,
"I'm your backside.": None, "don't look behind": None,
# the speaker says where they stand: the head turns there (live 2026-10-27: "I am your right side." went to the LLM, none)
"I am your left, right side.": ("look", "right"), "I am your right side.": ("look", "right"),
"I am your right side. Look at that.": ("look", "right"), "I'm on your right side": ("look", "right"),
"I'm on your right": ("look", "right"), "I'm here on your left": ("look", "left"), "I'm on your left hand side.": ("look", "left"),
"Lumi, I'm on your right, look at me": ("look", "right"), "I'm behind you": ("look", "left 180"),
"나 오른쪽에 있어": ("look", "right"), "오른쪽에 있어요": ("look", "right"), "나 여기 왼쪽이야": ("look", "left"),
"저 왼쪽에 있어요": ("look", "left"), "뒤에 있어": ("look", "left 180"),
"you are right": None, "right, I see": None, "all right": None, "I'm right here": None, "that's right": None,
"right now": None, "I'm right": None, "I'm on the right track": None, "I'm behind you all the way": None,
"I'm your right hand man": None, "컵 왼쪽에 있어": None, "왼쪽에 있어?": None, "Am I on your right?": None,
"I'm not on your right": None,
})
wrong = {text: (brain.intent(text, []), want) for text, want in CASES.items() if brain.intent(text, []) != want}
@@ -203,6 +220,9 @@ from assistant import lumi # a venue question on
assert lumi.not_online("여기 몇 시까지 해요?") and lumi.not_online("입장료 얼마예요?") and lumi.not_online("what time is the keynote?")
assert not lumi.not_online("루브르 몇 시까지 해?") and not lumi.not_online("How much are tickets for the Louvre?")
assert not lumi.not_online("롯데월드 입장료 얼마야?")
for text, want in (("I am your right side. Look at that.", "right"), ("Lumi, I'm on your right, look at me", "right"),
("나 여기 왼쪽이야", "left"), ("I'm behind you", "left 180")): # one look, never the LLM or a chain
assert lumi.route(text, ["p3"], brain.Brain()) == ("quick", ("look", want)), text
# the model's motion runs only on a direct order (or "yes" to Lumi's own offer, "do it again"); else talk only
for text, line in (("우리 커피 들렀다가 p3 가자", "go_to p3"), ("let's grab coffee then go to p3", "go_to p3"),
("Don't look up.", "look down"), ("흔들지 마", "wave -"), ("고개 돌리지 마세요", "turn left"),
+1
View File
@@ -4,6 +4,7 @@ gives no motion. No robot; the embedding server answers the bank.
.venv/bin/python tests/test_ko_levels.py
"""
import no_robot # noqa: F401 any connection to the robot fails the test
from tests import ko_levels_check
CAPS = {"wave", "turn45", "head_up", "follow", "fetch", "go_to"}
+1
View File
@@ -3,6 +3,7 @@ wording.norm, the route lumi.answer() takes before the LLM and intent_bank.said_
without a fitting unit is asked. No robot: python tests/test_korean_numbers.py"""
import math
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, intent_bank, steps, wording
from tests import command_check
from tests.korean_numbers_cases import NORM, ROUTE, SAID, STEPS
+133
View File
@@ -0,0 +1,133 @@
"""Self-check of "look at me": the person seen nearest the voice (head or torso camera), the voice first when nobody
is seen there, nobody seen -> the head stays. No robot: python tests/test_look_me.py"""
import math
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
turns, pitches = [], []
lumi.head.turn = lambda yaw, pitch=None: (turns.append(round(yaw)), pitches.append(pitch))
lumi.LOOK_ME_SETTLE_S = 0.0
class Vision:
def __init__(self, before, after=None):
self.views = [before, before if after is None else after]
def seen(self):
return self.views.pop(0) if len(self.views) > 1 else self.views[0]
def present(self, t):
return False
def head_person(self, angle, since):
return None
def near_angle(self, a, max_diff=25.0):
return None
def look(seen, voice=None, after=None):
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current = Vision(seen, after), None
L.voice_angle, L.voice_trusted = (voice or 0.0), voice is not None
turns.clear()
L.look_at_speaker()
return list(turns)
# someone on Lumi's right, seen only by the torso camera, no voice direction: the head turns right to them
assert look([(-33.0, 0.78)]) == [-33], turns
# the voice agrees with a person seen: that person, not the nearer one elsewhere
assert look([(-33.0, 1.2), (40.0, 0.6)], voice=-20.0) == [-33], turns
# the voice comes from out of view: the head turns there, then to the person its camera finds
assert look([(40.0, 0.6)], voice=-55.0, after=[(-50.0, 0.9), (40.0, 0.6)]) == [-55, -50], turns
# the voice direction is wrong (left), the only person is on the right: voice first, then the person seen
assert look([(-33.0, 0.78)], voice=50.0) == [50, -33], turns
# nobody seen, no voice: the head does not move (it used to tilt up)
assert look([]) == [], turns
# "Lumi" with the voice read on the left, nobody there: the head turns there, then to the person seen, else back
heads = []
lumi.time.sleep = lambda s: None
class Head(Vision):
camera = "head"
def near_angle(self, a, max_diff=25.0):
return None
for seen, want in (([(-33.0, 0.8)], [50, -33]), ([], [50, 5])):
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current = Head(seen), None
L.det_yaw = lambda: 5.0
L.turn_head = lambda yaw=None, pitch=None, force=False: heads.append(round(yaw))
heads.clear()
assert L.find_caller(50.0, True) is None and heads == want, heads
# the pitch follows the person in the head camera (torso camera intrinsics, near the head camera's)
FY, CY, H = 608.4, 363.2, 720
far = lumi.look_me_pitch
assert far([600, 250, 700, 600], H, 0.0, FY, CY) is None # far, all of them in view: stays level
# sitting, close: head low, legs cut: down 30 deg, cut to the head's range
assert far([600, 400, 800, 720], H, 0.0, FY, CY) == lumi.head.PITCH_RANGE[0]
p = far([600, 400, 800, 720], H, 30.0, FY, CY)
assert -2 < p < 2, p
assert far([500, 0, 900, 720], H, 0.0, FY, CY) == lumi.LOOK_ME_UP_STEP # tall, close: head cut, up a step
assert far([500, 0, 900, 720], H, 35.0, FY, CY) is None # already at the top of the range
assert far([600, 60, 800, 720], H, 5.0, FY, CY) is None # head already near the top
class Camera(Vision):
"""Head camera frames after each turn: the box top moves by the pitch change (fy px per radian)."""
def __init__(self, top, bottom=720):
super().__init__([(-30.0, 1.0)])
self.top, self.bottom, self.pitch = top, bottom, 0.0
def head_person(self, angle, since):
if pitches:
shift = FY * (math.tan(math.radians(pitches[-1] - self.pitch)))
self.top, self.pitch = self.top + shift, pitches[-1]
return {"box": [500, max(0, self.top), 900, self.bottom], "height": H, "pitch": self.pitch, "fy": FY, "cy": CY}
def look_pitch(cam):
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current, L.voice_angle, L.voice_trusted = cam, None, 0.0, False
turns.clear(), pitches.clear()
L.look_at_speaker()
return [round(p) for p in pitches]
assert look_pitch(Camera(250, 600)) == [0], pitches # far: level, no correction
assert look_pitch(Camera(300)) == [0, -5], pitches # sitting close: down, to the lowest pitch
assert look_pitch(Camera(100)) == [0, -3], pitches # standing close, legs cut: head to the top
p = look_pitch(Camera(-150)) # tall close: up until the head shows
assert p[0] == 0 and p[-1] > 10 and len(p) <= 1 + lumi.LOOK_ME_TRIES, p
assert set(turns) == {-30}, turns # the yaw stays on them
print("look me: ok")
# "look at me" from behind with Patrol off: the waist turns in place toward the voice, the head looks on from there
from tasks import fetch
waist = {"at": 0.0, "calls": []}
lumi.waist_turned = lambda: waist["at"]
def fake_waist_to(rel, in_place=False, look=None):
waist["calls"].append((round(rel), in_place, look))
waist["at"] = rel
return True
fetch._waist_to = fake_waist_to
L = lumi.Lumi.__new__(lumi.Lumi)
L.vision, L.current = Vision([]), None
L.voice_angle, L.voice_trusted = 170.0, True
L.modes = type("M", (), {"drive": True, "patrol": False})()
turns.clear()
L.look_at_speaker()
assert waist["calls"] == [(120, True, 170.0)], waist
assert turns == [50], turns # 170 - 120 left for the head
print("look me behind: ok")
+1
View File
@@ -2,6 +2,7 @@
list at once (api/server.py, robot/agv.py), with a fake base, no robot: python tests/test_map_info.py"""
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from api import server
from robot import agv
+1
View File
@@ -3,6 +3,7 @@ assistant's live list), with fake marker lists for the office and a conference m
python tests/test_map_names.py"""
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi, steps, wording
from robot import agv
+1
View File
@@ -8,6 +8,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import memory
memory.DIR = Path(tempfile.mkdtemp())
+1
View File
@@ -1,6 +1,7 @@
"""Self-check of tasks/mimic.py without the robot or camera: face angles and the playback plan."""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from tasks import mimic
from vision import pose
+1
View File
@@ -12,6 +12,7 @@ import time
re._MAXCACHE = 100000
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import fetch
+1
View File
@@ -6,6 +6,7 @@ drives is refused with one line, one that stays in place runs). Fake robot; the
python tests/test_mission_route.py"""
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, chain, lumi, steps
from tasks import fetch
from tests import steps_cases7 as c7
+1
View File
@@ -7,6 +7,7 @@ import tempfile
import threading
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import fetch
+1
View File
@@ -2,6 +2,7 @@
python tests/test_mission_talk.py"""
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import fetch
+1
View File
@@ -3,6 +3,7 @@ the place, "go on", "okay" while receiving) and of the status answer; no robot,
python tests/test_mission_wait.py"""
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from assistant import steps
from tasks import fetch
+1
View File
@@ -4,6 +4,7 @@
"""
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi
from robot import head
+1
View File
@@ -2,6 +2,7 @@
python tests/test_mouth.py
"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import llm_direct
from audio import mouth
+1
View File
@@ -5,6 +5,7 @@ import re
import threading
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import agv, nav_guard
from tasks import fetch
+1
View File
@@ -1,5 +1,6 @@
"""Self-check of whisper's number / unit slips read right in a move (assistant/wording.py number_slips), and words
that must stay as they are. python tests/test_number_slips.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import wording
CASES = {
+2 -1
View File
@@ -1,6 +1,7 @@
"""Self-check of objects.measure on a synthetic cup: python tests/test_objects.py"""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from vision import objects
# camera looking along base +y, base z up (like the real torso camera), 600 mm from a cup of r 40 mm, h 100 mm
@@ -27,7 +28,7 @@ box = (us.min() - 5, vs.min() - 5, us.max() + 5, vs.max() + 5)
m = objects.measure(color, depth, box, INTR, T, round_=True)
print(m)
assert m["colour"] == "red"
cx, cy, cz = m["position_mm"]
cx, cy, cz = np.subtract(m["position_mm"], [*objects.ROUND_FIX_MM, 0]) # the measured camera error added
assert abs(cx) < 5 and abs(cy - D) < 10 and abs(cz) < 5, m
assert abs(m["width_mm"] - 2 * R) < 8, m
assert abs(m["height_mm"] - H) < 12, m
+1
View File
@@ -1,5 +1,6 @@
"""tests/parity_check.py on a few fixed sentences: typed (the Command box) and voice give the same plan, English and
Korean the same, each the one asked for. Rules only, nothing moves: python tests/test_parity.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from tests import parity_check as pc
M = ["p1", "p2", "p3", "p5", "home", "exit", "dock2"]
+1
View File
@@ -9,6 +9,7 @@ import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import no_robot # noqa: F401 any connection to the robot fails the test
from tests import pick_sweep as ps
ps.install()
+1
View File
@@ -1,5 +1,6 @@
"""Self-check of marker names and numbers as people say them (assistant/wording.py), the keyword rules
(brain.intent) and the check of the LLM's place (brain.named_place), no robot, no LLM: python tests/test_places.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, wording
from tests.steps_cases5 import INTENTS
+1
View File
@@ -3,6 +3,7 @@ import math
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import agv
from tasks import fetch
from vision import pointing, pose, scene
+1
View File
@@ -4,6 +4,7 @@ Needs the embedding server (assistant/knowledge.embed starts it); nothing moves.
in other words than the bank's too; follow-ups, camera questions, commands and company facts never do."""
import re
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import quick_answers as qa
TALK = [("what does cutshion make?", "Cutshion makes robot applications, such as barista and cooking robots.")]
+12 -7
View File
@@ -8,6 +8,7 @@ import math
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from robot import kinematics, motion
from manipulation import arm_route, skills
from tasks import fetch
@@ -67,13 +68,15 @@ def line_ok(w, ja): # the straight line
return True
except fetch.FetchError:
return False
for xy in ((-104, 694), (-99, 738)):
for seen in ((-104, 694), (-99, 738)): # seen live before the camera's error was fixed
xy = np.add(seen, skills.objects.ROUND_FIX_MM)
assert skills.reachable_pick(cup(*xy, -186), accept=line_ok) is None, xy
plan = skills.reachable_pick(cup(*xy, -186), accept=lambda w, ja: skills.carry_up(w[0][1], ja) is not None)
assert plan, xy
via, carry = skills.carry_up(plan[0][0][1], plan[1])
assert via[2] > plan[0][0][1][2] and np.allclose(kinematics.pose(carry)[:3], kinematics.pose(motion.poses()["carry"])[:3], atol=0.1)
plan = skills.reachable_pick(cup(-104, 694, -186), accept=lambda w, ja: skills.carry_up(w[0][1], ja) is not None,
# the live (-104, 694) is (-92, 689) with the camera fixed: 9 mm past the trusted-turn edge; just inside it
plan = skills.reachable_pick(cup(-92, 680, -186), accept=lambda w, ja: skills.carry_up(w[0][1], ja) is not None,
max_yaw=skills.TRUSTED_YAW_DEG)
assert plan and abs(skills.yaw_of(plan[0][1][1])) <= 15.5, plan
@@ -111,7 +114,8 @@ assert np.isclose(np.hypot(*(np.subtract((t["x"], t["y"]), C))), np.hypot(*(np.s
assert t["x"] > o["x"] # waist left: a thing on the left comes ahead
assert np.allclose([fetch.turned(t, -30.0)[k] for k in "xy"], [o[k] for k in "xy"])
for r, b in ((600, 60), (600, -60), (550, 90), (600, -100), (730, 7), (720, 25)): # beside it and the live ones
for r, b in ((600, 60), (600, -60), (550, 90), (600, -100), (720, 7), (720, 25)): # beside it and the live ones
# (the live 730 mm one is 1 cm past the trusted reach since the grasp point was fixed, 2026-10-27)
o = around(r, b)
assert trusted(o) is None, (r, b) # not from here ...
turns = fetch.waist_for(o)
@@ -125,9 +129,10 @@ for r, b in ((1000, 0), (950, 40)): # too far for any wa
LIVE = (((262, 774, -189), "base"), ((267, 763, -188), "base"), ((260, 722, -186), "base"), # missed at -45 / -30
((300, 621, -191), "waist"), ((-99, 738, -181), "waist"), # missed at -30 / carry line jumped at -30
((-141, 869, -186), "base"), ((-117, 960, -186), "base"), # across the table / far
((-104, 694, -186), "here"), ((-73, 588, -186), "here"), ((-96, 598, -260), "here")) # carried / picked
for (x, y, top), how in LIVE:
o = cup(x, y, top)
((-104, 694, -186), "waist"), ((-73, 588, -186), "here"), ((-96, 598, -260), "here")) # carried / picked
# (694: picked from here live; at the trusted-turn edge since the grasp point was fixed, a small waist turn first)
for (x, y, top), how in LIVE: # seen before the camera's error was fixed
o = cup(x + skills.objects.ROUND_FIX_MM[0], y + skills.objects.ROUND_FIX_MM[1], top)
got = "here" if trusted(o) else "waist" if any(trusted(fetch.turned(o, d)) for d in fetch.waist_for(o)) else "base"
assert got == how, ((x, y, top), got, how)
body["waist"] = 100.0 # the waist near its limit (140): no turn past it
@@ -143,7 +148,7 @@ fetch._other_here = lambda task, obj: None
fetch.arm_yaw = lambda: -95.5
fetch.remember = lambda obj, yaw: {}
fetch.agv.pose = lambda: (0.0, 0.0, 0.0)
def waist_to(rel):
def waist_to(rel, in_place=False):
calls.append(("waist", round(rel)))
body["waist"] = -20.31 + rel
return True
+1
View File
@@ -4,6 +4,7 @@ import types
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from vision import reid
+1
View File
@@ -5,6 +5,7 @@ import json
import tempfile
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from fastapi import HTTPException
from api import server
+1
View File
@@ -5,6 +5,7 @@ cases. No robot.
.venv/bin/python tests/test_route_words.py
"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, detour
from tests import command_check
+1
View File
@@ -5,6 +5,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import seeing
from vision import pose, scene
+1
View File
@@ -15,6 +15,7 @@ import sys
import time
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi, seeing
from vision import scene
+1
View File
@@ -9,6 +9,7 @@ import tempfile
import time
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
import cv2
import numpy as np
+1
View File
@@ -5,6 +5,7 @@ alone. Fake people, no robot, no VLM. python tests/test_seeing_people.py
"""
import re
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import seeing
from vision import scene
+26 -1
View File
@@ -1,6 +1,7 @@
"""Self-check of the skills.py geometry, no robot: python tests/test_skills.py"""
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from vision import calib, head_cam
from manipulation import skills
@@ -124,6 +125,29 @@ assert plan and plan[1][4] < 0 and abs(round(skills.yaw_of(plan[0][1][1]))) == 4
plan = skills.reachable_pick(cup, start, accept=lambda wp, ja: abs(skills.yaw_of(wp[1][1])) > 100)
assert plan and abs(round(skills.yaw_of(plan[0][1][1]))) == 105, plan
assert skills.reachable_pick(cup, start, accept=lambda wp, ja: False) is None
# trusted turns are the ones picked live, -15..0: +15 missed 2 of 2 (a finger on the cup); the voice pick keeps to them
def ik_at(turns):
def ask(name, **a):
if name == "kine_forward":
return {"errorCode": "0", "cartPosition": [0, 0, 0] + list(skills.GRASP_RPY)}
ok = round(skills.yaw_of(a["cartPosition"])) in turns
return {"errorCode": "0", "jointPosition": list(a["jointPosition"])} if ok else {"errorCode": "1"}
return ask
skills._ask = ik_at({15, -15})
plan = skills.reachable_pick(cup, start, max_yaw=skills.TRUSTED_YAW_DEG)
assert plan and round(skills.yaw_of(plan[0][1][1])) == -15, plan
skills._ask = ik_at({15, 30})
assert skills.reachable_pick(cup, start, max_yaw=skills.TRUSTED_YAW_DEG) is None
real_find, real_guarded, real_home = skills.find, skills._guarded, skills.home_joints
skills.home_joints = lambda: start
skills.find = lambda name, colour=None, seen=None: dict(cup, colour="grey", width_mm=74)
skills._guarded = lambda *a: (_ for _ in ()).throw(AssertionError("picked at an untrusted turn"))
try:
skills.pick("cup")
raise AssertionError("picked")
except skills.SkillError as e:
assert e.args[0] == "I can't reach it safely.", e
skills.find, skills._guarded, skills.home_joints = real_find, real_guarded, real_home
# hand_sees: depth right at the cup's axis = object, far behind it = empty, nothing seen = unknown
skills.objects.base_from_camera = lambda: np.eye(4) # camera at the arm base origin
skills._ask = lambda name, **a: {"errorCode": "0", "cartPosition": [0.0, 500.0, 0.0] + list(skills.GRASP_RPY)}
@@ -162,7 +186,8 @@ assert np.allclose(np.array(d[:3]) + R @ (skills.GRASP_OFFSET + skills.TIPS_OFFS
skills._held.clear()
# the owner's taught tips grasp of the spray can (grasp_tips_teach.json): the same flange within a few mm, 2 deg
t = skills.TIPS_TEACH
f = skills.flange_for(*t["can_seen"], t["grasp_point_code"][2], skills.yaw_of(t["flange"]), tips=True)
can = np.add(t["can_seen"][:2], skills.objects.ROUND_FIX_MM) # seen before the camera's error was fixed
f = skills.flange_for(*can, t["grasp_point_code"][2], skills.yaw_of(t["flange"]), tips=True)
assert np.linalg.norm(np.subtract(f[:3], t["flange"][:3])) < 10, f
# ---------- frames after a move: wait for one written after it ended, never longer than FRESH_WAIT_S ----------
+39 -2
View File
@@ -7,6 +7,7 @@ import types
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from audio import sing
from assistant import lumi
@@ -172,6 +173,17 @@ assert time.time() - stop_at < 0.1, time.time() - stop_at # at on
sing._head_thread.join(2)
assert head.moves and head.moves[-1] == [120.0, 5.0, 0.0, 0.0], head.moves
for centre in (-40.0, 55.0, -90.0): # the owner on a side: the dance around them, inside the limits
head = FakeHead()
assert sing.sing(B, None, player(2.5), head, fake_load, centre_yaw=centre)
sing._head_thread.join(2)
c = max(-sing.YAW_LIMIT, min(sing.YAW_LIMIT, centre))
assert head.moves[0][2] == c and head.moves[-1][2] == c, (centre, head.moves) # turns there and stays there
assert all(abs(m[2] - c) <= sing.YAW_SWAY and abs(m[2]) <= sing.YAW_LIMIT for m in head.moves), (centre, head.moves)
assert c == -sing.YAW_LIMIT or len({m[2] for m in head.moves}) > 2, head.moves # still dances (at the limit: one side)
assert all(abs(sing.around(c, y)) <= sing.YAW_LIMIT for c in range(-90, 91, 5) for y in range(-40, 41, 2))
assert sing.around(0.0, 33.0) == 33.0 # the default: as before
played = [] # a stereo file reaches the one-channel speaker as mono
assert sing.sing(D, None, lambda wav, rate, abort: played.append(wav.ndim) or True, FakeHead(),
lambda path: (np.zeros((4410, 2), np.float32), 44100))
@@ -184,9 +196,13 @@ heard = [] # what the fake clip mic he
sung = []
def fake_sing(sid, abort=None):
centres = []
def fake_sing(sid, abort=None, centre_yaw=0.0):
sung.append(sid)
return real_sing(sid, abort, player(5), FakeHead(), fake_load)
centres.append(centre_yaw)
return real_sing(sid, abort, player(5), FakeHead(), fake_load, centre_yaw)
lumi.sing.sing = fake_sing
@@ -194,11 +210,13 @@ lumi.LOG_FILE = "/dev/null" # keep the assistant's log clea
lumi.ears.transcribe = lambda mono: heard.pop(0) if heard else ""
lumi.ears.understood = lambda *a: True
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers = ["home", "p1"] # never the base's marker list
L.lang, L.current, L.vision, L.last_song, L.pending_text, L.voice_until = "en", None, None, None, None, 0.0
L.skill_thread, L.mission_hold = None, None
L.brain = types.SimpleNamespace(history=[])
L.fetch_status = lambda: None
L.mission_running = lambda: False
L.det_yaw = lambda: -40.0 # nobody tracked: the head already faces the voice
utterance = types.SimpleNamespace(during_speech=True, seconds=1.0, mono=None)
L.mic = types.SimpleNamespace(next=lambda wait: utterance if heard else None)
@@ -206,6 +224,7 @@ t0 = time.time()
threading.Timer(0.3, lambda: heard.append("stop")).start()
L.sing_song("sing Love Attack")
assert sung == [L_] and time.time() - t0 < 1.0 and L.pending_text is None, (sung, time.time() - t0)
assert centres == [-40.0], centres # the dance stays toward the listener
threading.Timer(0.3, lambda: heard.append("sing another song")).start()
L.sing_song("sing a song")
@@ -221,6 +240,24 @@ t0 = time.time()
L.sing_song("sing Fantastic Baby")
assert time.time() - t0 > 4.5 and L.pending_text is None
# words over a song that are no new request leave it going (logs/lumi.log 2026-10-27, logs/heard): whisper's words
# from the music (0.26 s of speech for "Last hole."), a single word, the request said again while it starts
lumi.ears.last_stt = {"speech_s": 0.26}
threading.Timer(0.3, lambda: heard.append("Last hole.")).start()
t0 = time.time()
L.sing_song("Let's make music.")
assert time.time() - t0 > 4.5 and L.pending_text is None
lumi.ears.last_stt = {}
ign = sing.ignored_over_song
assert ign("Last hole.", "Let's make music.", 3.0, 0.26) and ign("Let's make music.", "Let's make music.", 2.0, 0.99)
assert ign("Okay.", "sing a song", 3.0, 0.5) and ign("Lumi.", "sing a song", 3.0, None)
assert ign("sing a song", "Let's make music.", 40.0, 1.0) and ign("노래 불러 줘", "sing a song", 40.0, 1.0)
assert ign("Let's make music.", "Let's make music.", 40.0, 0.99) is None # long after: asked for real
for words, speech in (("Let's change music.", 1.28), ("Let's change the music.", 1.2), ("another song", 0.6),
("다른 노래", 0.6), ("바꿔", 0.3), ("sing Fantastic Baby", 0.9), ("What time is it?", 0.9),
("Lumi, go to p3", 0.8), ("Let's make music.", None)):
assert ign(words, "Let's make music.", 2.0 if words != "Let's make music." else 30.0, speech) is None, words
# lumi.answer(): "again" right after a song is the song (not the drive words), "Can you sing song?" tagged Korean
# by whisper is still sung, "what songs can you sing?" lists them
said = []
+1
View File
@@ -5,6 +5,7 @@ Each case: command -> the steps it must give, written short:
say <text> | place | place white dining table left | give | hold | arm reach |
wait (no time: stay / until go on) | wait 30 | wait order [600] (an instruction there) | receive cup wait [120]
"?" as the steps: some words must stay unread (Lumi asks again, nothing runs)."""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import steps
M = ["home", "PInit", "Wp", "a", "b", "dock2", "exit", "final"] + [f"p{i}" for i in range(1, 11)]
+8 -6
View File
@@ -22,11 +22,13 @@ 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_turned = lambda: 0.0
lumi.mouth.say = lambda text, **k: done.append(("say", text))
lumi.mouth.own_voice = lambda u: False
lumi.mouth.recent_speech = lambda s: ""
lumi.doa.load_calib = lambda: {"fitted": False}
lumi.doa.estimate = lambda mics, cal: (0.0, 0.0, 0.0)
lumi.doa.estimate = lambda mics, cal, ref=None: (0.0, 0.0, 0.0)
lumi.ears.heard_lang = lambda lang: lang
@@ -125,13 +127,13 @@ lumi.head.status = lambda: [0, 0, 0, 0]
lumi.nav.person_on_map = lambda *a: (3.0, 0.0)
lumi.nav.approach = lambda *a: (2.0, 0.0, 0.0)
L = fresh(U("Stop!"), trip=False)
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a, **k: None
base["move_status"] = "running"
t = time.time()
L.come_to(Track())
assert stopped(L) and time.time() - t < 3, done
L = fresh(U("What is your name?"), trip=False)
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a, **k: None
base["move_status"] = "running"
threading.Timer(1.0, lambda: base.update(move_status="succeeded")).start()
L.come_to(Track())
@@ -140,7 +142,7 @@ assert "agv cancel" not in done and L.pending_text == "What is your name?", done
# right after Lumi said "Okay, I stopped.", "Stop." is no echo of it (own_echo counts "stop" in "stopped")
lumi.mouth.recent_speech = lambda s: "Okay, I stopped. Let's go to p5."
L = fresh(U("Stop."), trip=False)
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a: None
L.vision, L.modes, L.turn_head = Vision(), type("Modes", (), {"drive": True})(), lambda *a, **k: None
base["move_status"] = "running"
L.come_to(Track())
assert stopped(L), done
@@ -148,7 +150,7 @@ head_u = U("Stop.")
head_u.source = "head"
lumi.ears.listen = lambda **k: ("Stop.", head_u)
L = fresh(trip=False)
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u: None, None
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u, text=None: None, None
L.follow_filter = lambda text, u: False
assert L.talk_turn() and ("answer", "Stop.") in done, done
@@ -161,7 +163,7 @@ for heard in ("Stop.", "멈춰.", "Stop it."):
L = fresh(U(heard, during_speech=True))
assert L.check_wake() and stopped(L), (heard, done)
L = fresh(trip=False)
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u: None, None
L.warm_llm, L.interrupted, L.who_spoke, L.mission_hold = lambda: None, lambda: False, lambda u, text=None: None, None
L.follow_filter = lambda text, u: False
assert L.talk_turn() and ("answer", "Stop.") in done, done
L = fresh(U("Okay, I'm going to p5.", during_speech=True)) # Lumi's own sentence: still ignored
+66 -8
View File
@@ -4,6 +4,7 @@ arm action with the arm switched off asks to enable it, nothing else asks. Fake
python tests/test_switches.py"""
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from tasks import fetch, follow
@@ -175,9 +176,9 @@ L.act("go_to", "p3")
assert moved == ["start_trip"]
follow.stop, fetch.stop = real_follow_stop, real_fetch_stop
# ---------- "reach out to me": toward the person; Greeter never turns the base for it, asks them in front ----------
assert lumi.reach_turn(None, True) is None and lumi.reach_turn(10.0, False) == 0.0
assert lumi.reach_turn(-35.0, True) == -35.0 and lumi.reach_turn(35.0, False) is None
# ---------- "reach out to me": toward the person; the waist turns to them with Greeter only too (the base stays) ----
assert lumi.reach_turn(None) is None and lumi.reach_turn(10.0) == 0.0
assert lumi.reach_turn(-35.0) == -35.0 and lumi.reach_turn(35.0) == 35.0
reached = []
real_reach = fetch.reach
fetch.reach = lambda angle=0.0, say=None: reached.append(angle)
@@ -185,14 +186,16 @@ L.fetch_finish = lambda how, **k: moved.append(how)
L.skill_thread, L.voice_trusted = None, False
person = types.SimpleNamespace(angle=35.0)
L.vision = types.SimpleNamespace(present=lambda t: False, near_angle=lambda a, d=25: None, only_person=lambda: person)
for patrol, angle, want in ((False, 35.0, None), (True, 35.0, [35.0]), (False, -12.0, [0.0]), (True, -12.0, [0.0])):
L.turn_head = lambda yaw=None, pitch=None, force=False: moved.append(("head", yaw))
for patrol, angle, want in ((False, 35.0, [35.0]), (True, 35.0, [35.0]), (False, -40.0, [-40.0]), (False, -12.0, [0.0]),
(True, -12.0, [0.0])):
L.modes.patrol, person.angle = patrol, angle
reached.clear(), said.clear(), moved.clear()
got = L.reach_out(False)
if want is None: # nothing moves, not even the head
assert got is None and not reached and said == [lumi.GREETER_FRONT_SAY[0]] and not moved, (angle, said)
else:
assert got and reached == want and moved == ["head"], (patrol, angle, reached, moved)
# a waist turn takes the head onto them (fetch._waist_to look); a head turn here raced it (looked away live)
head_cmds = [] if want[0] else [("head", lumi.HEAD_SIGN * angle)]
assert got and reached == want and moved == head_cmds and not said, (patrol, angle, reached, moved, said)
L.turn_head = lambda *a, **k: moved.append("head")
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]]
@@ -210,5 +213,60 @@ assert lumi.Lumi.arm_pose(L, "open") and moved == ["open"] and not said, (moved,
lumi.gripper.open_, fetch.check_hand = real_open, real_check
L.fetch_status = lambda: None
fetch.reach = real_reach
# ---------- the waist back to the front (waist_home): in place, Greeter only too; never with the arm out or a task ----
real = {n: getattr(fetch, n) for n in ("_waist_turn", "state", "_at_pose", "_waist_to")}
calls = []
fetch._waist_to = lambda rel, in_place=False: calls.append((rel, in_place)) or True
fetch.state = lambda: {"status": "idle"}
fetch._at_pose = lambda name: True
fetch._waist_turn = lambda: 0.4 # at the front already: nothing moves
assert lumi.waist_home("test") and calls == []
fetch._waist_turn = lambda: 35.0 # turned for a person
fetch.state = lambda: {"status": "running"} # a task turns the waist itself
assert lumi.waist_home("test") is False and calls == []
fetch.state = lambda: {"status": "done"}
fetch._at_pose = lambda name: False # the hand held out (a reach): it stays turned
assert lumi.waist_home("test") is False and calls == []
fetch._at_pose = lambda name: True
assert lumi.waist_home("test") and calls == [(0.0, True)] # in place: also with Patrol off (stay_put)
fetch._waist_to = lambda rel, in_place=False: False # the arm's sweep is not clear
assert lumi.waist_home("test") is False
for n, f in real.items():
setattr(fetch, n, f)
# ---------- 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.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")
lumi.agv.turn_by = lambda a: order.append(("turn", round(lumi.math.degrees(a)))) or (True, "OK")
P = lumi.Patrol(["p3"], once=True)
P.tick(force=True)
assert order == ["waist", ("go", "p3")] and P.moving, order
lumi.agv.status = lambda: {"move_status": "idle", "power_percent": 2} # low battery: home, the waist first
order.clear()
P = lumi.Patrol(["p3"])
P.tick(force=True)
assert order == ["waist", ("go", "home")] and P.mode == "going_home", order
lumi.agv.status = lambda: {"move_status": "idle", "power_percent": 90}
L.modes.patrol, L.modes.drive = True, True
real_turned, lumi.waist_turned = lumi.waist_turned, lambda: 30.0 # turned 30 left for someone
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
order.clear()
P = lumi.Patrol(["p3"], once=True)
P.tick(force=True)
assert order == ["waist"] and P.stuck == "p3" and P.stuck_why == lumi.WAIST_BACK_SAY and P.mode == "done"
order.clear()
L.look_toward(150.0)
assert order == ["waist"], order
lumi.waist_home, lumi.waist_turned = real_home, real_turned
for name in ("status", "go", "go_point", "turn_by"):
setattr(lumi.agv, name, forbid)
print(f"switches ok: {len(BASE)} base phrases refused with Greeter only, {len(IN_PLACE)} in place done; "
"arm off asks; Patrol allows all; stop always")
+1
View File
@@ -9,6 +9,7 @@
"""
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, knowledge, memory, talk_examples, web
FAKE_NOW = "Friday, 13 March 2026, 10:05" # a date the model could never have guessed
+1
View File
@@ -6,6 +6,7 @@ import json
import tempfile
from pathlib import Path
import no_robot # noqa: F401 any connection to the robot fails the test
from fastapi import HTTPException
from api import server
+1
View File
@@ -1,5 +1,6 @@
"""Self-check of the camera choice in lumi.Vision (head standing, torso driving, fallback), no robot:
python tests/test_vision.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
v = lumi.Vision.__new__(lumi.Vision) # no camera service needed: only pick() is checked
+2
View File
@@ -5,6 +5,7 @@ import pathlib
import tempfile
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from assistant import voice_words as vw
from audio import mouth
@@ -62,6 +63,7 @@ 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}
L = lumi.Lumi.__new__(lumi.Lumi)
L.markers = ["home", "p1"] # never the base's marker list
L.lang, L.current, L.closing_pending = "en", None, None
L.brain = types.SimpleNamespace(history=[])
L.follow_stop = lambda text: False
+65 -3
View File
@@ -7,6 +7,7 @@ import threading
import time
import types
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain as brain_mod
from assistant import lumi
from tasks import fetch, follow
@@ -24,11 +25,13 @@ lumi.mouth.own_voice = lambda u: False
lumi.mouth.recent_speech = lambda s: ""
lumi.mouth.last_echo = 0.0
lumi.doa.load_calib = lambda: {"fitted": False}
lumi.doa.estimate = lambda mics, cal: (0.0, 0.0, 0.0)
lumi.doa.estimate = lambda mics, cal, ref=None: (0.0, 0.0, 0.0)
lumi.ears.heard_lang = lambda lang: lang
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
M = ["home", "dock2"]
@@ -106,7 +109,7 @@ def fresh(*tracks, utts=()):
L.mission_running = lambda: False
L.mission_hold = None
L.warm_llm = lambda: None
L.who_spoke = lambda u: done.append("who spoke")
L.who_spoke = lambda u, text=None: done.append("who spoke")
lumi.ears.listen = lambda **k: (None, None)
done.clear()
up.clear()
@@ -264,9 +267,68 @@ 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
H.head_rest() # "be quiet" 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
# the head stays toward the person while the conversation goes on; it rests only when the conversation is over
fetch.stop = lambda: done.append("fetch stop")
L = fresh(a := Track(31, 40))
a.greeted, L.current, L.looked_at = True, a, time.time()
L.act = lambda action, target: done.append(("act", action))
L.stop_all("Stop.") # stopping a song or an answer mid-talk
assert ("act", "stop") in done and "head" not in done and L.looked_at == 0.0, done
L = fresh(a := Track(32, 40))
a.greeted, L.current = True, a
L.vision.tracks.clear() # out of the frame, nobody else greeted
L.step()
assert L.current is None and L.voice_until > time.time() and "head" not in done, done
L.step() # the voice session goes on: still no rest
assert "head" not in done, done
L.voice_until = time.time() - 1 # the session ends by silence, nobody in view
L.check_wake = lambda: False
L.step()
assert "head" in done and L.voice_until == 0.0, done # end_conversation: yaw 0, rest pitch
# the conversation ends (silence, goodbye, "be quiet"): the waist comes back to the front too, Greeter or Patrol;
# 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
for patrol in (False, True):
L = fresh(a := Track(33, 40))
a.greeted, L.current, L.modes.patrol = True, a, patrol
L.traveling = lambda: False
homed.clear(), back.clear()
L.end_conversation(None, quiet=True)
assert back.wait(2) and "head" in done and L.current is None and homed, (patrol, done, homed)
homed.clear(), back.clear()
L.head_rest() # "be quiet"
assert back.wait(2) and homed
L.looked_at = L.last_activity = time.time() # "look up" just now, then silence ends the talk
homed.clear(), back.clear()
L.end_conversation(None, quiet=True)
assert not back.wait(0.3) and not homed
# someone else takes over (on the right, Lumi turned left for the first one): the waist back to the front, then the
# head to the new person (their angle from the waist's old place + the turn taken back); not turned: the head only
lumi.doa.load_calib = lambda: {"fitted": True}
lumi.doa.clip_ref = lambda u: None
lumi.doa.estimate = lambda mics, cal, ref=None: (-50.0, 0.9, 0.0)
for turned, homes, want in ((30.0, True, -20.0), (30.0, False, -50.0), (0.0, True, -50.0)):
L = fresh(a := Track(40, 40), b := Track(41, -50))
a.greeted, L.current = True, a
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
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)
assert bool(homed) == bool(turned), (turned, homed)
lumi.waist_home, lumi.waist_turned = real_home, real_turned
lumi.doa.load_calib = lambda: {"fitted": False}
lumi.doa.estimate = lambda mics, cal, ref=None: (0.0, 0.0, 0.0)
print("ok: wake words, waves, no greeting to passers-by or during tasks, answers never cut, names")
+6 -3
View File
@@ -7,6 +7,7 @@ from pathlib import Path
import numpy as np
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import lumi
from manipulation import arm_route, skills, wave
from robot import agv, arm, gripper, motion
@@ -27,6 +28,7 @@ gripper.state = lambda: {"holding": hand["holding"]}
base = {"move_status": "idle"}
agv.status = lambda: dict(base)
wave.log = arm_route.log = lambda *a: None
fetch._waist_turn = lambda: 0.0 # the waist at the front (never the body)
motion.SETTLE_S = 0.01 # quick here (tests/test_arm_route.py checks it)
@@ -128,11 +130,12 @@ refused(wave.HOLDING)
skills.hand_sees = lambda: "unknown"
assert a.sent == []
# ---------- from carry (empty hand): down to look first, then up ----------
# ---------- from carry (empty hand): the least joint travel checked; straight to wave_start passes the head ----------
POSES["carry"] = [30.0, 0.0, 0.0, 0.0, 0.0, 0.0]
a = use(FakeArm(POSES["carry"]))
wave.wave()
assert a.sent[:4] == [LOOK, POSES["wave_out"], top, swing], a.sent
assert a.sent[:3] == [POSES["wave_out"], top, swing], a.sent
assert arm_route.profile(POSES["carry"], top, HEAD)[0] < arm_route.HEAD_CLEAR_MM
del POSES["carry"]
# ---------- an unknown start (after free drive: the wrist the other way round): joins by a checked move; power ----------
@@ -152,7 +155,7 @@ del POSES["wave"]
refused(wave.NOT_TAUGHT)
POSES["wave"] = swing
del POSES["wave_out"]
refused(wave.NOT_TAUGHT)
refused(wave.NEAR_HEAD) # the ways left (look -> wave -> ...) pass the head
POSES["wave_out"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
assert arm.cmd.sent == [] # nothing sent for any refusal
+1
View File
@@ -4,6 +4,7 @@ The search words made from a question, the parts of a Naver page that are kept,
DuckDuckGo when Naver gives nothing), and what a follow-up of a lookup searches for. Live answers: tests/web_check.py."""
import datetime
import no_robot # noqa: F401 any connection to the robot fails the test
from assistant import brain, lumi, web
# English questions become search words; Korean stays as it is