Speed up arm gestures and route the hand-over through give_pre
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,8 +31,8 @@ def moved(j, joint, deg):
|
||||
|
||||
|
||||
# ---------- 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"]
|
||||
for s in ("wave_start", "wave"): # after a wave: never in one move to give
|
||||
assert names("give", POSES[s])[-1] == "give" and len(names("give", POSES[s])) > 1
|
||||
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
|
||||
@@ -77,10 +77,10 @@ sent = []
|
||||
real_path, motion.move_path = motion.move_path, lambda moves, **k: sent.extend(moves)
|
||||
arm_route.move(arm_route.plan("give", now=list(POSES["wave_start"])))
|
||||
assert [s for _, s in sent][-1] == arm_route.GIVE_SPEED and \
|
||||
all(s == arm_route.SPEED for _, s in sent[:-1]), sent # the last move, give_pre -> give, slow
|
||||
all(s == arm_route.SPEED for _, s in sent[:-1]), sent # the last move, give_pre -> give, GIVE_SPEED
|
||||
del POSES["give_pre"] # not taught: the route and speed as before
|
||||
sent.clear()
|
||||
arm_route.move(arm_route.plan("give", now=list(POSES["wave_start"])))
|
||||
assert [s for _, s in sent] == [arm_route.SPEED], sent
|
||||
assert all(s == arm_route.SPEED for _, s in sent), sent # no give_pre: every move at route speed
|
||||
motion.move_path = real_path
|
||||
print("arm give route ok")
|
||||
|
||||
@@ -83,6 +83,11 @@ for a in POSES:
|
||||
fake = use(POSES[a])
|
||||
route = arm_route.goto(b)
|
||||
assert fake.sent == [POSES[n] for n in route] and arm_route.where(fake.j) == b, (a, b, route)
|
||||
if frozenset((a, b)) in arm_route.NO_EDGES and {a, b} != {"look", "wave_start"}: # give - wave poses:
|
||||
hops = [a] + route # through give_pre /
|
||||
assert route[-1] == b and not any(frozenset(h) in arm_route.NO_EDGES for h in zip(hops, hops[1:])), \
|
||||
(a, b, route) # wave_out
|
||||
continue
|
||||
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
|
||||
@@ -100,7 +105,8 @@ use(POSES["give"])
|
||||
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
|
||||
r = arm_route.goto("give") # empty after a wave: never wave pose - give
|
||||
assert r[-1] == "give" and "wave_start" not in r and len(r) > 1, r # in one move (owner)
|
||||
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
|
||||
|
||||
@@ -85,7 +85,7 @@ fetch._thread.join(10)
|
||||
st = fetch.state()
|
||||
assert st["status"] == "done", st
|
||||
w0, arm0, arm1, w1 = when("waist start")[0], when("arm start")[0], when("arm end")[0], when("waist end")[-1]
|
||||
assert w0 <= arm0 < arm1, events # the waist command went out first, before the arm route ended
|
||||
assert abs(w0 - arm0) < 0.1 and w0 < arm1, events # both start together (threads: either first), the waist before the arm ends
|
||||
assert arm0 < w1, events # the arm started before the waist got there
|
||||
assert len(when("waist start")) == math.ceil(30.0 / fetch.WAIST_STEP_DEG), events
|
||||
assert abs(body["pos"][1] - 30.0) < 1e-6 and abs(body["pos"][2]) < 1e-6, body # waist 30, head yaw 30 - 30 = 0
|
||||
|
||||
+17
-7
@@ -75,9 +75,10 @@ def refused(reason):
|
||||
|
||||
# ---------- from look: up through wave_out, 2 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)))
|
||||
started, up = [], []
|
||||
wave.wave(on_start=lambda: started.append(len(a.sent)), on_up=lambda: up.append(len(a.sent)))
|
||||
assert started == [0] # said before the first move
|
||||
assert up == [2] # at wave_start, before the swings (person stop off)
|
||||
top, swing = POSES["wave_start"], POSES["wave"]
|
||||
assert wave.SWINGS == 2
|
||||
assert a.sent == [POSES["wave_out"], top] + [swing, top] * wave.SWINGS, a.sent
|
||||
@@ -98,12 +99,12 @@ a.j = list(LOOK)
|
||||
wave.wave()
|
||||
sent = [e for e in names if e[0] in ("joint_move", "get_data")]
|
||||
route, swing_s = motion.JOINT_SPEED[arm_route.SPEED], motion.JOINT_SPEED[wave.SWING_SPEED]
|
||||
arrive = motion.JOINT_SPEED[wave.ARRIVE_SPEED] # into wave_start softer than the route speed
|
||||
assert arrive < route and wave.ARRIVE_SPEED == "normal"
|
||||
arrive = motion.JOINT_SPEED[wave.ARRIVE_SPEED] # into wave_start at the route speed too
|
||||
assert arrive == route and wave.ARRIVE_SPEED == "route"
|
||||
assert sent == [("joint_move", route, False), ("get_data", None, False), ("joint_move", arrive, False),
|
||||
("get_data", None, False)] + \
|
||||
[("joint_move", swing_s, False)] * 2 * wave.SWINGS + [("get_data", None, False)], sent # swings back to back
|
||||
assert wave.SWING_SPEED == "normal"
|
||||
assert wave.SWING_SPEED == "quick"
|
||||
arm.cmd = a
|
||||
a.j = list(top)
|
||||
a.sent.clear()
|
||||
@@ -190,9 +191,18 @@ assert L.wave() is False and said == [wave.HOLDING[1]]
|
||||
said.clear()
|
||||
assert L.wave(quiet=True) is False and said == [] # a goodbye wave refused: no words about it
|
||||
hand["holding"] = False # a stale "holding", the hand empty (2026-10-23
|
||||
real_wave, wave.wave = wave.wave, lambda on_start=None: None # 17:43): checked again, not refused for holding
|
||||
real_wave, wave.wave = wave.wave, lambda on_start=None, on_up=None: None # 17:43): checked again, not refused for holding
|
||||
said.clear()
|
||||
assert L.wave() is True and said == [] and not fetch.state()["holding"], said
|
||||
held, go = threading.Event(), threading.Event() # the same request twice (16:21, typed): one wave
|
||||
wave.wave = lambda on_start=None, on_up=None: (held.set(), go.wait(10))
|
||||
first = threading.Thread(target=L.wave)
|
||||
first.start()
|
||||
held.wait(10)
|
||||
assert L.wave() is False # asked again while it waves: refused, no second
|
||||
go.set()
|
||||
first.join()
|
||||
assert L.wave() is True # ... and the next one after it ended runs
|
||||
wave.wave = real_wave
|
||||
fetch.STATE_FILE.unlink()
|
||||
|
||||
@@ -207,7 +217,7 @@ def slow_say(text, **k): # speech tha
|
||||
|
||||
lumi.mouth = types.SimpleNamespace(say=slow_say)
|
||||
L.lang = "en"
|
||||
wave.wave = lambda on_start=None: (on_start(), order.append("move"))
|
||||
wave.wave = lambda on_start=None, on_up=None: (on_start(), order.append("move"))
|
||||
done = []
|
||||
th = threading.Thread(target=lambda: done.append(L.wave(("Okay!", "네!"))))
|
||||
th.start()
|
||||
|
||||
Reference in New Issue
Block a user