Wave along the taught poses: look, wave_out, wave_start, three swings to wave
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-9
@@ -12,7 +12,8 @@ from vision import head_cam
|
||||
|
||||
fetch.STATE_FILE = Path(tempfile.mkdtemp()) / "lumi_task.json" # never the real /dev/shm file
|
||||
POSES = {"look": [0.0] * 6, "carry": [20.0, 0, 0, 0, 0, 0], "give": [40.0, 0, 0, 0, 0, 0],
|
||||
"wave_start": [0.0, -20, 0, 0, 0, 0], "wave": [0.0, -20, 20, 0, 0, 0], "ready": [0.0, 0, -20, 0, 0, 0],
|
||||
"wave_out": [0.0, -20, 0, 0, 0, 0], "wave_start": [0.0, -20, 20, 0, 0, 0],
|
||||
"wave": [0.0, -20, 20, 0, 20, 0], "ready": [0.0, 0, -20, 0, 0, 0],
|
||||
"tuck": [-20.0, 0, 0, 0, 0, 0]}
|
||||
FAR = np.array([0.0, 0.0, 5000.0]) # the head far away: nothing near it
|
||||
head = {"centre": FAR}
|
||||
@@ -78,15 +79,18 @@ 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("tuck") == ["wave_start", "look", "tuck"] # fold: through look
|
||||
assert arm_route.goto("tuck") == ["wave_start", "wave_out", "look", "tuck"] # fold: through look
|
||||
use(POSES["look"])
|
||||
assert arm_route.goto("wave_start") == ["wave_out", "wave_start"] # up: never look -> wave_start directly
|
||||
assert {"look", "wave_start"} not in [set(e) for e in arm_route.EDGES]
|
||||
|
||||
# ---------- after a wave the arm stays up; the next pick goes wave -> wave_start -> look first ----------
|
||||
fake = use(POSES["wave"])
|
||||
# ---------- after a wave the arm stays at wave_start; the next pick goes down through wave_out first ----------
|
||||
fake = use(POSES["wave_start"])
|
||||
skills._prepare()
|
||||
assert fake.sent == [POSES["wave_start"], POSES["look"]], fake.sent
|
||||
fake = use(POSES["wave"])
|
||||
assert fake.sent == [POSES["wave_out"], POSES["look"]], fake.sent
|
||||
fake = use(POSES["wave_start"])
|
||||
fetch._pose("look")
|
||||
assert fake.sent == [POSES["wave_start"], POSES["look"]], fake.sent
|
||||
assert fake.sent == [POSES["wave_out"], POSES["look"]], fake.sent
|
||||
|
||||
# ---------- an unknown pose near a known one: a checked joint move to it, then on ----------
|
||||
near = [3.0, 2.0, -4.0, 5.0, 0.0, 0.0] # 5 deg from look (free drive)
|
||||
@@ -113,7 +117,7 @@ for start in (POSES["look"], near, POSES["give"]):
|
||||
refused(arm_route.NEAR_HEAD, arm_route.goto, "give" if start != POSES["give"] else "look")
|
||||
assert fake.sent == [], fake.sent
|
||||
fake = use(POSES["look"])
|
||||
assert arm_route.goto("wave") == ["wave_start", "wave"] # another edge: clear of it
|
||||
assert arm_route.goto("wave") == ["wave_out", "wave_start", "wave"] # other edges: clear of it
|
||||
head["centre"] = None # the head not measured: nothing moves
|
||||
refused(arm_route.UNSURE, arm_route.goto, "look")
|
||||
head["centre"] = FAR
|
||||
@@ -125,7 +129,7 @@ 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
|
||||
refused(arm_route.NOT_TAUGHT, arm_route.goto, "nowhere")
|
||||
POSES["wave_start"] = [0.0, -20, 0, 0, 0, 0]
|
||||
POSES["wave_start"] = [0.0, -20, 20, 0, 0, 0]
|
||||
|
||||
# ---------- Cobo π programs only from look; hand_shaking never ----------
|
||||
fake = use(POSES["carry"])
|
||||
|
||||
+23
-10
@@ -16,7 +16,8 @@ from vision import head_cam
|
||||
fetch.STATE_FILE = Path(tempfile.mkdtemp()) / "lumi_task.json" # never the real /dev/shm file
|
||||
lumi.BUSY_FILE = str(fetch.STATE_FILE.parent / "lumi_busy.json") # nor the real busy file
|
||||
LOOK = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
POSES = {"look": LOOK, "wave_start": [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0], "wave": [-50.0, 0.0, 60.0, 0.0, 30.0, 0.0]}
|
||||
POSES = {"look": LOOK, "wave_out": [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0], "wave_start": [-50.0, 0.0, 60.0, 0.0, 0.0, 0.0],
|
||||
"wave": [-50.0, 0.0, 60.0, 0.0, 21.7, 0.0]}
|
||||
HEAD = np.array([-100.0, -200.0, 700.0]) # mm, the head's turning centre in the toy arm
|
||||
motion.poses = lambda: dict(POSES)
|
||||
head_cam.head_centre = lambda: HEAD
|
||||
@@ -67,27 +68,36 @@ def refused(reason):
|
||||
raise AssertionError(f"waved, expected {reason}")
|
||||
|
||||
|
||||
# ---------- from look: up along the graph, wave, and the arm stays up; every move clear of the head ----------
|
||||
# ---------- from look: up through wave_out, 3 swings, the arm stays at wave_start; every move clear of the head ------
|
||||
a = use(FakeArm(LOOK))
|
||||
started = []
|
||||
wave.wave(on_start=lambda: started.append(len(a.sent)))
|
||||
assert started == [0] # said before the first move
|
||||
top = POSES["wave"]
|
||||
up, down = top[:4] + [top[4] + wave.WAVE_DEG] + top[5:], top[:4] + [top[4] - wave.WAVE_DEG] + top[5:]
|
||||
assert a.sent == [POSES["wave_start"], top] + [up, down] * wave.WAVE_SWINGS + [top], a.sent
|
||||
top, swing = POSES["wave_start"], POSES["wave"]
|
||||
assert wave.SWINGS == 3
|
||||
assert a.sent == [POSES["wave_out"], top] + [swing, top] * 3, a.sent
|
||||
for j0, j1 in zip([LOOK] + a.sent, a.sent):
|
||||
assert arm_route.profile(j0, j1, HEAD)[0] >= arm_route.HEAD_CLEAR_MM, (j0, j1)
|
||||
assert arm_route.profile(LOOK, top, HEAD)[0] < arm_route.HEAD_CLEAR_MM # straight up from look would pass the head
|
||||
assert {"look", "wave_start"} not in [set(e) for e in arm_route.EDGES] # so there is no such edge
|
||||
a.sent.clear()
|
||||
wave.wave() # asked again while up: only the swings
|
||||
assert a.sent == [top] + [up, down] * wave.WAVE_SWINGS + [top], a.sent
|
||||
assert a.sent == [swing, top] * 3, a.sent
|
||||
a.sent.clear()
|
||||
a.j = list(swing) # stopped at wave: back to wave_start, then swings
|
||||
wave.wave()
|
||||
assert a.sent == [top] + [swing, top] * 3, a.sent
|
||||
a.j = list(top)
|
||||
a.sent.clear()
|
||||
assert arm_route.goto("look") == ["wave_out", "look"] # the way down
|
||||
assert a.sent == [POSES["wave_out"], LOOK], a.sent
|
||||
|
||||
# ---------- a taught pose whose way passes the head: refused before anything moves ----------
|
||||
POSES["wave_start"] = [-15.0, 0.0, 40.0, 0.0, 0.0, 0.0]
|
||||
POSES["wave_out"] = [-15.0, 0.0, 40.0, 0.0, 0.0, 0.0]
|
||||
a = use(FakeArm(LOOK))
|
||||
refused(wave.NEAR_HEAD)
|
||||
assert a.sent == []
|
||||
POSES["wave_start"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
POSES["wave_out"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
# ---------- holding something: refused (task state, or AI_1 when the camera can't tell) ----------
|
||||
a = use(FakeArm(LOOK))
|
||||
@@ -106,7 +116,7 @@ assert a.sent == []
|
||||
POSES["carry"] = [30.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
a = use(FakeArm(POSES["carry"]))
|
||||
wave.wave()
|
||||
assert a.sent[:3] == [LOOK, POSES["wave_start"], top], a.sent
|
||||
assert a.sent[:4] == [LOOK, POSES["wave_out"], top, swing], a.sent
|
||||
del POSES["carry"]
|
||||
|
||||
# ---------- an unknown start (after free drive: the wrist the other way round), base, power ----------
|
||||
@@ -123,7 +133,10 @@ refused(wave.BUSY)
|
||||
fetch.STATE_FILE.unlink()
|
||||
del POSES["wave"]
|
||||
refused(wave.NOT_TAUGHT)
|
||||
POSES["wave"] = top
|
||||
POSES["wave"] = swing
|
||||
del POSES["wave_out"]
|
||||
refused(wave.NOT_TAUGHT)
|
||||
POSES["wave_out"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
assert a.sent == []
|
||||
|
||||
# ---------- the assistant: a greeting sends no arm command; a wave asked while holding is refused aloud ----------
|
||||
|
||||
Reference in New Issue
Block a user