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:
2026-10-29 19:10:09 +09:00
co-authored by Claude Opus 5.5
parent e8d651da49
commit 799e210f4b
10 changed files with 67 additions and 32 deletions
+5 -4
View File
@@ -51,12 +51,13 @@ from vision import calib, head_cam
HOME = "look" # every arm action starts here
GIVE = "give" # the hand held out to a person
GIVE_PRE = "give_pre" # one step before GIVE: an empty-hand way to GIVE always ends GIVE_PRE -> GIVE
GIVE_SPEED = "slow" # motion.JOINT_SPEED of the last move, GIVE_PRE -> GIVE (first live runs: slow)
GIVE_SPEED = "route" # motion.JOINT_SPEED of the last move, GIVE_PRE -> GIVE
EDGES = (("give_pre", "give"), ("give", "carry"), ("carry", "look"), ("look", "wave_out"), ("wave_out", "wave_start"),
("wave_start", "wave"), ("look", "ready")) # the moves with something in the hand (both ways)
NO_EDGES = {frozenset(("look", "wave_start"))} # never one joint move: passes 267 mm from the head (the wave
# goes up and down through wave_out, 309 mm)
WAVE_POSES = ("wave_out", "wave_start", "wave") # never with something in the hand (the cup would tip)
NO_EDGES = {frozenset(("look", "wave_start")), # never one joint move: passes 267 mm from the head (the wave
*(frozenset(("give", w)) for w in ("wave_out", "wave_start", "wave"))} # goes up and down through
# wave_out, 309 mm); give and the wave poses through give_pre
STOP_DEG = 10.0 # deg of joint travel one more stop on a route costs (SETTLE_S, slowing down and
# starting again; an estimate, it only weighs routes against each other)
SPEED = "route" # motion.JOINT_SPEED of the moves along the graph, empty hand
@@ -193,7 +194,7 @@ def hops(now, target, leaf=False, holding=False, skip=()):
"""The poses the arm goes through from the joints `now` to `target`, in order (not the one it is at). `leaf`: the
arm is out on the task's own checked way from look (above a table): when it is at no pose, straight to target.
`skip`: poses the way must not pass."""
if holding and target in WAVE_POSES:
if holding and target in WAVE_POSES + (GIVE_PRE,): # GIVE_PRE is the empty hand's (the gripper reads holding)
raise RouteError(*SPILL)
nodes = graph(holding, skip)
if target not in nodes:
+7 -4
View File
@@ -23,8 +23,8 @@ from robot import agv, arm, gripper, motion
START = "wave_start" # hand above the head; the wave starts and ends here
SWING = "wave" # START with J3 −14.7°
SWINGS = 2 # times START -> SWING -> START
SWING_SPEED = "normal" # motion.JOINT_SPEED of the swings; the way up is arm_route.SPEED ...
ARRIVE_SPEED = "normal" # ... but its last move, into START: at route speed it stopped there hard (J1 60°)
SWING_SPEED = "quick" # motion.JOINT_SPEED of the swings; the way up is arm_route.SPEED ...
ARRIVE_SPEED = "route" # ... its last move, into START (J1 60°), too (owner: as fast as the way down)
# Why Lumi does not wave, (English, Korean)
OFF = ("Please enable my arm first.", "먼저 제 팔을 켜 주세요.")
@@ -86,8 +86,9 @@ def plan():
return route, swings
def wave(on_start=None):
"""Plan, check and wave; the arm stays at START. `on_start()` is called once the plan is checked.
def wave(on_start=None, on_up=None):
"""Plan, check and wave; the arm stays at START. `on_start()` is called once the plan is checked, `on_up()` at
START before the swings (the hand above the head from there on).
Raises WaveError (refused) or motion.MotionError (stopped / failed while moving: the arm stays where it stopped)."""
try:
route, swings = plan()
@@ -104,6 +105,8 @@ def wave(on_start=None):
log(f"arm at {START} after {time.time() - t0:.1f} s")
if route and motion._stopped.wait(motion.SETTLE_S): # stand at START first, as between any two moves
raise motion.MotionError("stopped")
if on_up:
on_up()
t0 = time.time()
motion.move_path([(t, SWING_SPEED) for t in swings], queued=True) # back to back, no stop between swings
log(f"wave: {SWINGS} swings after {time.time() - t0:.1f} s")