Fix hand reach, arm rest routing and response delays on the charger
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -522,3 +522,23 @@ ko = sum(1 for t, _, _ in READ if brain.HANGUL.search(t))
|
||||
print(f"{len(READ) - len(bad)}/{len(READ)} read right ({ko} Korean, {len(READ) - ko} English)")
|
||||
assert not bad
|
||||
print("command box ok")
|
||||
|
||||
# ---------- a bag on the hooks: "give me the bag" holds it out at once (the gripper holds nothing), a new bag order
|
||||
# is still a mission ----------
|
||||
L.bag_on = lambda: True
|
||||
L.reach_out = lambda held: rec("reach", held)
|
||||
L.held_now = lambda look=False: look and (_ for _ in ()).throw(AssertionError("the arm moved to look at the hand"))
|
||||
for text in ("give me the bag", "Lumi, give me the bag please", "hand me the bag", "give it to me", "가방 줘", "가방 주세요"):
|
||||
assert voice(text) == ("reach", False), (text, got_voice)
|
||||
assert voice("take the bag to p1")[0] == "steps" and got_voice[0][1][0] == {"do": "arm", "pose": "bag"}, got_voice
|
||||
L.bag_on, L.held_now = (lambda: False), (lambda look=False: False)
|
||||
assert voice("give me the bag") != ("reach", False) # no bag: not this way
|
||||
print("bag give ok")
|
||||
|
||||
# "thanks" after the bag was held out: reach_done folds (arm_pose "fold"), which with a bag on takes it off (look)
|
||||
offs = []
|
||||
real_off, fetch.bag_off = fetch.bag_off, lambda: offs.append("off")
|
||||
L.bag_on = lambda: True
|
||||
assert lumi.Lumi.arm_pose(L, "fold") and offs == ["off"], offs
|
||||
fetch.bag_off = real_off
|
||||
print("bag fold ok")
|
||||
|
||||
@@ -1381,3 +1381,31 @@ 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")
|
||||
|
||||
# ---- a bag on the hooks: drives keep the arm in the bag pose; the step waits for the bag once; fold takes it off ----
|
||||
went, said = [], []
|
||||
fetch._pose = lambda name, holding=False, leaf=False: went.append(name)
|
||||
fetch._set(holding=False, bag=False)
|
||||
fetch._drive_pose()
|
||||
assert went == [fetch.arm_route.rest_pose()], went # the empty arm drives at rest
|
||||
went.clear()
|
||||
real_wait, fetch._stop = fetch._stop, threading.Event()
|
||||
fetch.BAG_HANG_S = 0.01
|
||||
fetch._arm("bag", lambda en, ko: said.append(en))
|
||||
assert went == [fetch.BAG_POSE] and fetch.state()["bag"] and said == [fetch.BAG_HANG_SAY[0]], (went, said)
|
||||
fetch._drive_pose()
|
||||
fetch._arm("bag", lambda en, ko: said.append(en)) # hung already: no asking again
|
||||
assert went == [fetch.BAG_POSE, fetch.arm_route.rest_pose(), fetch.BAG_POSE] and len(said) == 1, (went, said) # drives at
|
||||
# rest with the bag too; hung already: no asking again
|
||||
fetch._set(holding=True)
|
||||
try:
|
||||
fetch._arm("bag")
|
||||
raise AssertionError("bag pose with a cup in the hand")
|
||||
except fetch.FetchError:
|
||||
pass
|
||||
fetch._set(holding=False)
|
||||
went.clear()
|
||||
fetch.bag_off()
|
||||
assert went == [fetch.arm_route.rest_pose()] and not fetch.state()["bag"], went
|
||||
fetch._stop = real_wait
|
||||
print("bag ok")
|
||||
|
||||
@@ -8,6 +8,7 @@ from assistant import lumi
|
||||
turns, pitches = [], []
|
||||
lumi.head.turn = lambda yaw, pitch=None, **k: (turns.append(round(yaw)), pitches.append(pitch))
|
||||
lumi.LOOK_ME_SETTLE_S = 0.0
|
||||
lumi.on_charger = lambda: False # off the charger: the body may turn (it asks the base)
|
||||
lumi.waist_turned = lambda: 0.0 # the waist at the front unless a case says otherwise
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +122,19 @@ with os.fdopen(fd, "w") as f:
|
||||
L.poll_commands()
|
||||
os.remove(lumi.CMD_FILE)
|
||||
assert "stop" in done and run["status"] == "stopped" and L.mission_hold is None, done
|
||||
# 19:47 the dashboard's stop while following (no task runs): following ends too, not only the task
|
||||
from tasks import follow
|
||||
ended, real = [], (follow.stop, fetch.stop)
|
||||
follow.stop, fetch.stop = (lambda: ended.append("follow")), (lambda: ended.append("task"))
|
||||
L = fresh()
|
||||
L.cmd_id, L.modes = 0, type("Modes", (), {"patrol": True})()
|
||||
fd, lumi.CMD_FILE = tempfile.mkstemp(suffix=".json")
|
||||
with os.fdopen(fd, "w") as f:
|
||||
json.dump({"id": 1, "time": time.time(), "cmd": "fetch_stop"}, f)
|
||||
L.poll_commands()
|
||||
os.remove(lumi.CMD_FILE)
|
||||
follow.stop, fetch.stop = real
|
||||
assert ended == ["follow", "task"], ended
|
||||
|
||||
|
||||
# 16:56:38 "One more." right after "look left": further left; also "a bit more", "더", after a lift
|
||||
|
||||
@@ -308,6 +308,23 @@ assert llm_says("go to p2, then chill there and do whatever the visitors tell yo
|
||||
{"do": "wait", "s": None, "until": "instruction"}])[0] == S("go p2 | wait order")
|
||||
print("steps wait ok")
|
||||
|
||||
# ---- a bag hung on the gripper's hooks (owner, 2026-11-04): the arm to its bag pose, then the drive ----
|
||||
for text, want in (("take the bag to p1", "arm bag | go p1"), ("Lumi, take this bag to p2", "arm bag | go p2"),
|
||||
("carry my bag to p4", "arm bag | go p4"), ("take the bag home", "arm bag | go home"),
|
||||
("take the bag and go to p1", "arm bag | go p1"), ("hold the bag", "arm bag"),
|
||||
("here's the bag", "arm bag"), ("가방 들어", "arm bag"), ("가방 좀 받아 줘", "arm bag"),
|
||||
("가방 p1으로 가져가", "arm bag | go p1"), ("쇼핑백 p3까지 옮겨 줘", "arm bag | go p3"),
|
||||
("가방 홈으로 가져가 줘", "arm bag | go home"), ("take the cup to p1", "pick cup | go p1")):
|
||||
got, unread = steps.rules(text, M)
|
||||
assert not unread and got == [short(x) for x in want.split(" | ")], (text, got, unread)
|
||||
for text in ("I have a bag", "what a nice bag", "where is my bag?", "the bag is heavy", "가방 p99로 가져가"):
|
||||
got, unread = steps.rules(text, M)
|
||||
assert unread or not got, (text, got) # no order, or a place not on the map: nothing runs
|
||||
bag = [short("arm bag"), short("go p1")]
|
||||
assert steps.check(bag, False, M) == [] and steps.check(bag, True, M) # never with a cup in the hand
|
||||
assert steps.describe(bag) == "Hold my hand ready for the bag, then go to p1." and steps.is_mission(bag)
|
||||
print("steps bag ok")
|
||||
|
||||
# ---- three or four steps in one breath on the conference map (tests/steps_cases7.py) ----
|
||||
from assistant import brain
|
||||
from tests import steps_cases7 as c7
|
||||
|
||||
+100
-41
@@ -177,12 +177,7 @@ 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; the waist turns to them with Greeter only too (the base stays) ----
|
||||
assert lumi.reach_turn(None) is None and lumi.reach_turn(8.0) == 0.0
|
||||
assert lumi.reach_turn(-35.0) == -35.0 and lumi.reach_turn(35.0) == 35.0
|
||||
# the hand held out 21 deg right of the waist's front (give): the waist turns until the hand, not its front, points
|
||||
# at the person (live 2026-10-28: turned straight at them, the hand went out beside them)
|
||||
assert lumi.reach_turn(36.0, -21.0) == 57.0 and lumi.reach_turn(-15.0, -21.0) == 0.0 and lumi.reach_turn(0.0, -21.0) == 21.0
|
||||
# ---------- "reach out to me": at once the way the waist faces, wherever the person is (owner, 2026-11-04) ----------
|
||||
reached, looked = [], []
|
||||
real_reach, real_bearing = fetch.reach, fetch.give_bearing
|
||||
fetch.reach = lambda angle=0.0, say=None, look=None: reached.append(angle) or looked.append(look)
|
||||
@@ -190,43 +185,21 @@ fetch.give_bearing = lambda: 0.0
|
||||
L.fetch_finish = lambda how, **k: moved.append(how)
|
||||
L.skill_thread, L.voice_trusted = None, False
|
||||
person = types.SimpleNamespace(angle=35.0, distance=1.0, id=8)
|
||||
L.vision = types.SimpleNamespace(present=lambda t: False, near_angle=lambda a, d=25: None, only_person=lambda: person,
|
||||
visible=lambda t: False, only_seen=lambda: person)
|
||||
L.vision = types.SimpleNamespace(present=lambda t: True, near_angle=lambda a, d=25: None, only_person=lambda: person,
|
||||
visible=lambda t: True, only_seen=lambda: person)
|
||||
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, -8.0, [0.0]),
|
||||
(True, -8.0, [0.0])):
|
||||
L.modes.patrol, person.angle = patrol, angle
|
||||
reached.clear(), said.clear(), moved.clear()
|
||||
got = L.reach_out(False)
|
||||
# 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)
|
||||
fetch.give_bearing = lambda: -21.0 # the hand right of the front: turned further, the head on them
|
||||
person.angle = 36.0
|
||||
reached.clear(), looked.clear()
|
||||
assert L.reach_out(False) and reached == [57.0] and looked == [36.0], (reached, looked)
|
||||
person.angle, person.distance = 0.0, 3.0 # far away: come to them first, then reach
|
||||
came = []
|
||||
L.vision.present = lambda t: True
|
||||
L.come_to = lambda t: came.append(t.id) or setattr(t, "distance", 1.1)
|
||||
reached.clear(), said.clear()
|
||||
assert L.reach_out(False) and came == [8] and reached == [21.0], (came, reached)
|
||||
person.distance, L.modes.patrol = 3.0, False # far, Greeter only (the base stays): asked to come, no reach
|
||||
reached.clear(), said.clear(), came.clear()
|
||||
assert L.reach_out(False) is None and not reached and not came and said == [lumi.COME_CLOSER_SAY[0]], (said, reached)
|
||||
L.modes.patrol, person.distance = True, 1.0
|
||||
fetch.give_bearing = lambda: 0.0
|
||||
L.turn_head = lambda *a, **k: moved.append("head")
|
||||
seen_vision, L.vision = L.vision, None # nobody seen, the voice's direction not trusted: ask
|
||||
reached.clear(), said.clear()
|
||||
assert L.reach_out(False) is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]]
|
||||
L.voice_trusted, L.voice_angle, L.modes.patrol = True, -50.0, True # heard from the right, nobody seen there:
|
||||
L.find_caller = lambda angle, trusted: None # no reach to a bare voice direction (it was
|
||||
reached.clear(), said.clear() # 166 deg off, 2026-10-28)
|
||||
assert L.reach_out(False) is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]]
|
||||
L.find_caller = lambda angle, trusted: person # someone seen there: to them
|
||||
person.angle, L.vision = -50.0, seen_vision
|
||||
assert L.reach_out(False) and reached == [-50.0]
|
||||
L.come_to = lambda t: came.append(t.id)
|
||||
for patrol, angle, dist in ((False, 35.0, 1.0), (True, -40.0, 1.0), (True, 0.0, 25.9), (False, 0.0, 3.0)):
|
||||
L.modes.patrol, person.angle, person.distance = patrol, angle, dist # (25.9 m: a crowd, 2026-11-04)
|
||||
reached.clear(), said.clear(), moved.clear(), came.clear()
|
||||
assert L.reach_out(False) and reached == [0.0] and not moved and not came and not said, (patrol, angle, reached, moved, said)
|
||||
L.vision = None # nobody seen at all: the same
|
||||
reached.clear()
|
||||
assert L.reach_out(False) and reached == [0.0]
|
||||
L.modes.patrol, person.distance, person.angle = True, 1.0, 35.0
|
||||
L.vision = types.SimpleNamespace(present=lambda t: True, near_angle=lambda a, d=25: None, only_person=lambda: person,
|
||||
visible=lambda t: True, only_seen=lambda: person)
|
||||
moved.clear(), reached.clear(), said.clear()
|
||||
L.fetch_status = lambda: "holding"
|
||||
real_check, fetch.check_hand = fetch.check_hand, lambda: True # the hand checked: something is in it
|
||||
@@ -242,6 +215,7 @@ fetch.reach, fetch.give_bearing = real_reach, real_bearing
|
||||
|
||||
# ---------- 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")}
|
||||
real_rest, lumi.arm_route.rest_pose = lumi.arm_route.rest_pose, lambda holding=False: "look" if holding else "rest"
|
||||
calls = []
|
||||
fetch._waist_to = lambda rel, in_place=False: calls.append((rel, in_place)) or True
|
||||
fetch.state = lambda: {"status": "idle"}
|
||||
@@ -256,10 +230,27 @@ fetch._at_pose = lambda name: False # the hand held out (a
|
||||
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)
|
||||
calls.clear()
|
||||
fetch._at_pose = lambda name: name == "look" # in look on the charger (not rest): it turns too
|
||||
assert lumi.waist_home("test") and calls == [(0.0, True)], calls
|
||||
fetch._waist_to = lambda rel, in_place=False: False # the arm's sweep is not clear
|
||||
assert lumi.waist_home("test") is False
|
||||
# a drive or turn (fold): the empty arm goes to rest first wherever it is, also with the waist at the front already
|
||||
went = []
|
||||
real_plan, real_move, real_lower = lumi.arm_route.plan, lumi.arm_route.move, lumi.wave_greet.lower
|
||||
lumi.arm_route.plan, lumi.wave_greet.lower = (lambda target, holding=False: [target]), (lambda: None)
|
||||
lumi.arm_route.move = lambda seq, speed=None, holding=False: went.append(seq[-1])
|
||||
fetch._waist_turn, fetch._at_pose, fetch.state = (lambda: 0.4), (lambda name: name == "look"), (lambda: {"status": "idle"})
|
||||
assert lumi.waist_home("drive", fold=True) and went == ["rest"], went
|
||||
went.clear()
|
||||
fetch.state = lambda: {"status": "idle", "holding": True} # a cup: look (drive_ready), never rest
|
||||
real_ready, fetch.drive_ready = fetch.drive_ready, lambda: went.append("drive_ready")
|
||||
assert lumi.waist_home("drive", fold=True) and went == ["drive_ready"], went
|
||||
fetch.drive_ready = real_ready
|
||||
lumi.arm_route.plan, lumi.arm_route.move, lumi.wave_greet.lower = real_plan, real_move, real_lower
|
||||
for n, f in real.items():
|
||||
setattr(fetch, n, f)
|
||||
lumi.arm_route.rest_pose = real_rest
|
||||
|
||||
# ---------- every drive and base turn starts with the waist at the front ----------
|
||||
order = []
|
||||
@@ -302,5 +293,73 @@ with tempfile.TemporaryDirectory() as tmp:
|
||||
m = lumi.Modes(types.SimpleNamespace(patrol=None, no_arm=False))
|
||||
assert (m.greeter, m.patrol, m.wave) == (True, True, False) and not hasattr(m, "drive"), vars(m)
|
||||
|
||||
# ---------- on the charger with nothing to do: the arm slowly from rest to look, the waist to HOME_WAIST_DEG; off
|
||||
# it, with a drive running, a task, a cup or the hand out: nothing moves ----------
|
||||
turned, arm_at = [], {"now": "rest"}
|
||||
real_waist_to, real_at_pose, real_state = fetch._waist_to, fetch._at_pose, fetch.state
|
||||
real_plan, real_move, real_rest = lumi.arm_route.plan, lumi.arm_route.move, lumi.arm_route.rest_pose
|
||||
fetch._waist_to = lambda rel, in_place=False, look=None: turned.append(("waist", rel)) or True
|
||||
fetch._at_pose = lambda name: name == arm_at["now"]
|
||||
lumi.arm_route.rest_pose = lambda holding=False: "rest"
|
||||
lumi.arm_route.plan = lambda target, holding=False: [target]
|
||||
lumi.arm_route.move = lambda seq, speed=None, holding=False: turned.append(("arm", seq[-1], speed)) or arm_at.update(now=seq[-1])
|
||||
fetch.state = lambda: {"status": "idle"}
|
||||
for st, at, want in (({"charge_state": True, "move_status": "succeeded"}, "rest",
|
||||
[("arm", "look", lumi.HOME_ARM_SPEED), ("waist", lumi.HOME_WAIST_DEG)]),
|
||||
({"charge_state": True, "move_status": "idle"}, "look", [("waist", lumi.HOME_WAIST_DEG)]),
|
||||
({"charge_state": True, "move_status": "running"}, "rest", []), # leaving the charger
|
||||
({"charge_state": False, "move_status": "idle"}, "rest", []), # not at home
|
||||
({"charge_state": True, "move_status": "idle"}, "give", [])): # the hand held out
|
||||
lumi.agv.status, arm_at["now"], turned[:] = (lambda st=st: st), at, []
|
||||
assert lumi.waist_home_rest("test") == bool(want) and turned == want, (st, at, turned)
|
||||
lumi.agv.status = lambda: {"charge_state": True, "move_status": "idle"}
|
||||
for task in ({"status": "running"}, {"status": "idle", "holding": True}): # a task, a cup in the hand
|
||||
fetch.state, arm_at["now"], turned[:] = (lambda t=task: t), "rest", []
|
||||
assert not lumi.waist_home_rest("test") and turned == [], task
|
||||
fetch._waist_to, fetch._at_pose, fetch.state = real_waist_to, real_at_pose, real_state
|
||||
lumi.arm_route.plan, lumi.arm_route.move, lumi.arm_route.rest_pose = real_plan, real_move, real_rest
|
||||
|
||||
# ---------- on the charger the body stays turned to its rest: someone speaking or calling turns the head only ------
|
||||
moves = []
|
||||
real_on, real_turned, real_home2 = lumi.on_charger, lumi.waist_turned, lumi.waist_home
|
||||
lumi.on_charger, lumi.waist_turned = (lambda: True), (lambda: 86.0)
|
||||
lumi.waist_home = lambda why, fold=False: moves.append(("waist", why)) or True
|
||||
L.turn_head = lambda yaw=None, pitch=None, force=False: moves.append(("head", yaw))
|
||||
lumi.Lumi.face(L, types.SimpleNamespace(angle=-30.0))
|
||||
lumi.Lumi.look_toward(L, 170.0) # a voice behind: no base turn, the head as far as it goes
|
||||
assert moves == [("head", lumi.HEAD_SIGN * -30.0), ("head", lumi.HEAD_SIGN * lumi.head.YAW_LIMIT)], moves
|
||||
lumi.on_charger, lumi.waist_turned, lumi.waist_home = real_on, real_turned, real_home2
|
||||
|
||||
# ---------- on the charger, nobody talking: the head on the nearest passer-by, left and right, not too often ----------
|
||||
moves = []
|
||||
real_on, real_busy = lumi.on_charger, lumi.wave_greet.busy
|
||||
lumi.on_charger, lumi.wave_greet.busy = (lambda: True), (lambda: False)
|
||||
L.turn_head = lambda yaw=None, pitch=None, force=False: moves.append(yaw)
|
||||
L.look_held, L.det_yaw = (lambda: False), (lambda: 0.0)
|
||||
L.vision = types.SimpleNamespace(seen=lambda m: [(40.0, 3.5), (-25.0, 1.8)])
|
||||
L.passer_at = 0.0
|
||||
L.watch_passers()
|
||||
assert moves == [lumi.HEAD_SIGN * -25.0], moves # the nearest one
|
||||
L.watch_passers()
|
||||
assert len(moves) == 1 # not again within PASSER_EVERY_S
|
||||
L.passer_at, L.det_yaw = 0.0, (lambda: lumi.HEAD_SIGN * -25.0)
|
||||
L.watch_passers()
|
||||
assert len(moves) == 1 # looking at them already
|
||||
L.passer_at, lumi.on_charger = 0.0, (lambda: False)
|
||||
L.watch_passers()
|
||||
assert len(moves) == 1 # off the charger: never
|
||||
lumi.on_charger, lumi.wave_greet.busy = real_on, real_busy
|
||||
|
||||
# ---------- "look left" turns the head there at once: no turn to the speaker first (one body move at a time) ----------
|
||||
moves = []
|
||||
L.vision, L.markers, L.current = types.SimpleNamespace(only_person=lambda: None, present=lambda t: False), ["p1"], None
|
||||
L._who_spoke = lambda u, text: moves.append("who")
|
||||
L.turn_head = lambda yaw=None, pitch=None, force=False: moves.append(yaw)
|
||||
for text in ("Lumi, look at the right side.", "Look at the left side.", "왼쪽 봐", "look up"):
|
||||
lumi.Lumi.who_spoke(L, object(), text)
|
||||
assert moves == [], moves
|
||||
lumi.Lumi.who_spoke(L, object(), "look at me") # "look at me" needs the voice: as before
|
||||
assert moves == ["who"], moves
|
||||
|
||||
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")
|
||||
|
||||
@@ -32,6 +32,7 @@ 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, fold=False: True
|
||||
lumi.wave_greet_on = lumi.on_charger = lambda: False # the dashboard's switch file and the base: not this test's
|
||||
M = ["home", "dock2"]
|
||||
|
||||
|
||||
@@ -76,6 +77,9 @@ class Vision: # people in the greeting zone
|
||||
def anyone_near(self):
|
||||
return bool(self.tracks)
|
||||
|
||||
def seen(self, max_m=lumi.STAY_MAX):
|
||||
return [(t.angle, t.distance) for t in self.tracks if t.distance <= max_m]
|
||||
|
||||
def nearest_greeted(self):
|
||||
return next((t for t in self.tracks if t.greeted), None)
|
||||
|
||||
|
||||
@@ -206,6 +206,81 @@ switch["free"] = False
|
||||
run(500.0, 505.0)
|
||||
assert done == [] and not g.busy(), done
|
||||
|
||||
# a drive starts (lumi.waist_home) with the hand up mid-swing: the swings end, then the arm down before the drive
|
||||
fresh()
|
||||
waver["w"] = W(0.0)
|
||||
run(550.0, 550.0)
|
||||
g._st["swing_end"] = 1e12 # a swing still queued
|
||||
switch["free"] = False
|
||||
run(550.5, 550.5) # the drive took the robot: the wave greeting lets go
|
||||
done.clear()
|
||||
g._rest = lambda: 86.0 # on the charger the waist rests turned; a drive still wants the front
|
||||
g.lower()
|
||||
assert done == ["settle", "waist +0 look None", "down normal", "head +0 rest"] and arm["at"] == "look", done
|
||||
arm["at"] = "wave_start" # nobody waves any more on the charger: down to the waist's rest there
|
||||
done.clear()
|
||||
g._down()
|
||||
assert done[:2] == ["waist +86 look None", "down normal"], done
|
||||
g._rest = lambda: 0.0
|
||||
done.clear()
|
||||
g.lower() # the hand is down: nothing moves
|
||||
assert done == [], done
|
||||
|
||||
# nothing asked for a while on the charger (_idle): the hand goes up and stays up, no words; 2 swings every
|
||||
# IDLE_WAVE_EVERY_S while nobody talks; a call stops them (the hand still up); a drive brings it down (lower); someone
|
||||
# waving is greeted as always
|
||||
fresh()
|
||||
waver["w"] = None
|
||||
g._idle, g._rest_arm = (lambda: True), (lambda: "look")
|
||||
g._someone_within = lambda m: True # someone right by the arm: no idle wave, tried again later
|
||||
g._st["idle_at"] = 0.0
|
||||
run(690.0, 690.0)
|
||||
assert done == [], done
|
||||
g._someone_within = lambda m: False
|
||||
arm["at"] = "rest" # the arm still on its way to look on the charger: not yet
|
||||
g._st["idle_at"] = 0.0
|
||||
run(691.0, 691.0)
|
||||
assert done == [], done
|
||||
arm["at"] = "look"
|
||||
g._st["idle_at"] = 700.0 # the last idle wave
|
||||
run(700.0, 700.0 + g.IDLE_WAVE_EVERY_S - 1)
|
||||
assert done == [] and said == [], done # not before IDLE_WAVE_EVERY_S
|
||||
run(700.0 + g.IDLE_WAVE_EVERY_S + 0.5, 700.0 + g.IDLE_WAVE_EVERY_S + 0.5)
|
||||
assert done == ["up route", "swing", "swing"] and said == [] and g._st["up"] and g._st["held"], (done, said)
|
||||
done.clear()
|
||||
t = 700.0 + g.IDLE_WAVE_EVERY_S + 1
|
||||
run(t, t + g.IDLE_WAVE_EVERY_S - 2)
|
||||
assert done == [], done # up, still, until the next swings
|
||||
run(t + g.IDLE_WAVE_EVERY_S, t + g.IDLE_WAVE_EVERY_S + 200)
|
||||
assert done.count("swing") >= 2 * 9 and "down normal" not in done and "up route" not in done, done # never down
|
||||
talk = {"on": True} # someone talks to Lumi: no swings, the hand stays up, still
|
||||
g._idle = lambda: not talk["on"]
|
||||
done.clear()
|
||||
run(1000.0, 1100.0)
|
||||
assert done == [] and g._st["up"], done
|
||||
talk["on"] = False # quiet again: the swings go on
|
||||
run(1101.0, 1102.0)
|
||||
assert done == ["swing", "swing"], done
|
||||
done.clear()
|
||||
g.lower() # a drive: down to the front first
|
||||
assert "down normal" in done and not g._st["up"] and not g._st["held"], done
|
||||
g._idle = lambda: True
|
||||
done.clear()
|
||||
said.clear() # someone waves back during an idle wave: greeted as always,
|
||||
real_waver, g._waver = g._waver, (lambda: W(20.0)) # the hand stays up and swings on
|
||||
arm["at"], g._st["idle_at"], g._st["up"] = "look", 0.0, False
|
||||
run(760.0, 760.0)
|
||||
assert "up route" in done and "down normal" not in done and g._st["up"], done
|
||||
run(760.5, 762.0)
|
||||
assert said and said[0] in sum(g.wave_lines.INTRO + g.wave_lines.GREET, ()) and done.count("swing") >= 1, (done, said)
|
||||
g._waver = real_waver
|
||||
g._st["up"] = g._st["held"] = False
|
||||
done.clear()
|
||||
g._idle = lambda: False # someone talks to Lumi, or off the charger: no idle waves
|
||||
run(800.0, 900.0)
|
||||
assert done == [], done
|
||||
g._idle, g._rest_arm = (lambda: False), g.arm_route.rest_pose
|
||||
|
||||
# Lumi introduces itself once per person: the same person waving again (after NEW_WAVE_S) gets a hello, someone
|
||||
# else an introduction, and the first person too once they were out of view for GONE_S
|
||||
fresh()
|
||||
|
||||
Reference in New Issue
Block a user