Add hand-raised patrol routes with greeting stops and round counts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 10:35:56 +09:00
co-authored by Claude Opus 5.5
parent cf8a170297
commit 57a0160f38
12 changed files with 358 additions and 76 deletions
+37
View File
@@ -222,6 +222,43 @@ fetch._place_kept = real_kept
fetch._state.update(holding=False, held_object=None)
skills.flat_points = flat
# ---------- a table seen further away, lost up close (out of the torso camera's view, no depth frame, and no level
# point of it remembered: seen by the head camera): put on its kept spot once the base brought it into reach ----------
ROUND.update(c=(-160.0, 1350.0), r=400.0)
TABLE_Z = -390.0
far = fetch.far_table()
assert far and abs(far["table"] - TABLE_Z) < 1.0, far
kept = fetch._keep((far["x"], far["y"]), far["table"]) # no level points kept
spot_world = fetch._kept_at(kept)
fetch.agv.pose = lambda: (0.60, 0.0, 0.0) # the base drove 0.6 m towards it
x, y, z = fetch._kept_at(kept)
assert math.hypot(x, y) <= fetch.FAR_REACH_MM and abs(y - (spot_world[1] - 600.0)) < 60.0, (x, y)
assert math.hypot(x - ROUND["c"][0], y - (ROUND["c"][1] - 600.0)) < ROUND["r"] # on the table, moved with it
real_place_at, real_look = fetch._place_at, skills.look
put = []
fetch._place_at = lambda tries, top, turned=True: put.append((tries, top)) or True
skills.look = lambda *a, **kw: []
skills._held.clear()
skills._held.update(top_mm=-300.0, table=-400.0)
VIEW_Y = 1e9 # lost: the camera sees nothing of it
assert fetch._kept_spots(kept, lambda x, y: 0.0) == []
assert fetch._place_remembered(-300.0, kept) is True, lines
assert put == [([(x, y)], -290.0)], put # its spot, the cup's top 10 mm higher
# never where the camera sees something else, nor next to a thing standing there, nor out of reach
put.clear()
VIEW_Y = 0.0
ROUND["c"] = (-160.0, 2500.0) # the floor where it was kept: not there
assert fetch._place_remembered(-300.0, kept) is None and not put
VIEW_Y = 1e9
skills.look = lambda *a, **kw: [{"name": "cup", "x": x + 50.0, "y": y, "top_mm": -300.0}]
assert fetch._place_remembered(-300.0, kept) is None and not put
skills.look = lambda *a, **kw: []
fetch.agv.pose = lambda: (0.0, 0.0, 0.0) # where it was seen from: too far
assert fetch._place_remembered(-300.0, kept) is None and not put
VIEW_Y = 655.0
fetch._place_at, skills.look = real_place_at, real_look
skills._held.clear()
# ---------- several cups: the said colour / size / place first; that colour nowhere: the closest, said ----------
cups = [{"name": "cup", "colour": c, "x": x, "y": y, "top_mm": -260.0, "width_mm": w, "seen": 8, "spread": 2.0}
for c, x, y, w in (("white", -150.0, 600.0, 80.0), ("red", 100.0, 700.0, 70.0), ("white", -300.0, 900.0, 64.0))]
+4 -3
View File
@@ -235,13 +235,14 @@ fetch._at_pose = lambda name: name == "look" # in look on the charge
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
# a drive or turn (fold), the wave greeting off: the empty arm goes to look first wherever it is (fetch.drive_arm),
# 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
fetch._waist_turn, fetch._at_pose, fetch.state = (lambda: 0.4), (lambda name: name == "rest"), (lambda: {"status": "idle"})
assert lumi.waist_home("drive", fold=True) and went == ["look"], 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")
+27 -2
View File
@@ -2,6 +2,7 @@
waving detector (vision/waving.py) on the recordings of vision/wave_record.py when they are here (tests/data/waves,
local only: people in the pictures): python tests/test_wave_greet.py"""
from pathlib import Path
import time
import no_robot # noqa: F401 any connection to the robot fails the test
from manipulation import arm_route, wave
@@ -246,7 +247,7 @@ 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)
assert done == ["up route"] + ["swing"] * g.IDLE_SWINGS 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)
@@ -260,10 +261,15 @@ 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
assert done == ["swing"] * g.IDLE_SWINGS, 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
done.clear() # the hand left up (its way down did not run): swings from there
arm["at"], g._st["idle_at"] = "wave_start", 0.0
run(1200.0, 1200.0)
assert done == ["swing"] * g.IDLE_SWINGS and g._st["held"], done
g.lower()
g._idle = lambda: True
done.clear()
said.clear() # someone waves back during an idle wave: greeted as always,
@@ -304,6 +310,25 @@ waver["w"] = W(0.0)
run(621.0, 621.0)
assert said[-1] in sum(g.wave_lines.INTRO, ()), said
# a loop patrol's wave for people passing: only with the hand up, someone within GREET_M, nobody by the arm
near = {"m": None}
waver["w"] = None
g._someone_within = lambda m: near["m"] is not None and near["m"] < m
g._nearest = lambda m: 20.0 if near["m"] is not None and near["m"] < m else None
saved, arm["at"] = arm["at"], "wave_start"
done.clear()
assert not g.passer_wave() and not done # nobody there
near["m"] = 0.5
assert not g.passer_wave() and not done # someone right by the arm
near["m"] = 2.0
assert g.passer_wave() and done.count("swing") == g.IDLE_SWINGS
time.sleep(0.2) # the head turns in the background
assert "head +20" in done and done[-1] == "head +0" # to them, then ahead again for the drive
arm["at"], near["m"] = "look", 2.0
assert not g.passer_wave() # the hand is not up
arm["at"] = saved
done.clear()
# a hand at the head (scratching, a phone at the ear) is not a raised hand; the same hand held out to the side is
import numpy as np # noqa: E402
kp = np.zeros((17, 3))