Turn the waist with the arm on a hand-over, recover stopped picks and improve follow tracking

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 15:55:03 +09:00
co-authored by Claude Opus 5.5
parent 390ec9db99
commit e8d651da49
24 changed files with 728 additions and 200 deletions
+44 -8
View File
@@ -65,10 +65,10 @@ LIFT_MM = 30.0 # first lift after closing, the
MAX_TILT_DEG = 15.0 # deg; a held cup's axis may lean this far from vertical on a joint
# move with it (place_options; tasks/fetch.py uses the same)
PLACE_EXTRA_MM = 3.0 # put down this much higher than it was picked (same table)
MIN_WIDTH, MAX_WIDTH = 70.0, 81.0 # mm: the cup's top goes through the open hooks' ring (87 by tape) and
# the belly closes round it (closed 68). MAX_WIDTH: the owner's margin
# 6 for the camera (an 84 mm rim read 83-85); wider tops are taken from
# the side (side()). The tips grasp (61-72) missed twice live on a
MIN_WIDTH, MAX_WIDTH = 70.0, 97.0 # mm: the cup's top goes through the open hooks' ring (tips 100 open,
# owner's measure) and the belly closes round it. MAX_WIDTH: the
# owner's margin 3; wider tops are taken from the side (side()). The
# tips grasp (61-72) missed twice live on a
# 66 mm can (2026-10-22): off by the owner until it is checked; 61
# brings it back
SEEN_UNDER_MM = 8.0 # the camera's width is this much under the width the fingers meet
@@ -119,9 +119,9 @@ BELOW_SHOULDER_MM = 80.0 # bottles: grasp this far below
# the owner's taught tips grasp of a spray can, at its middle (2026-10-22,
# grasp_tips_teach.json); the hand's lowest part (TIP_MM below) must
# stay TIP_CLEAR_MM above the table (else its lowest point seen)
SIDE_MAX_WIDTH = 84.0 # mm; side grasp (a cup whose top is wider than MAX_WIDTH): the width the
SIDE_MAX_WIDTH = 97.0 # mm; side grasp (a cup whose top is wider than MAX_WIDTH): the width the
# fingers meet (seen + SIDE_SEEN_MM) where the hooks go in from the
# side, under the open tips' 87 mm (owner's tape) with a margin 3
# side, under the open tips' 100 mm (owner's measure) with a margin 3
SIDE_SEEN_MM = 0.0 # ... the camera's width of a cup's lower part is not under like its rim:
# an 84 mm rim cup read 73-77 where the tape gave 71 (45 mm up) and
# AI_1 74 (60 mm up, 2026-10-29)
@@ -195,8 +195,11 @@ CONFIRM_DEG = 2.0 # deg; its inverse kinematics w
RETRIES = 4 # the controller now and then answers with nothing: ask again,
RETRY_S = 0.2 # waiting this long, twice as long each time (it drops connections)
OPEN_AI = gripper.CLOSED_AI # AI_1 below this after opening = released
BACK_OUT_NEAR_MM = 30.0 # back_out: the hand this near the stopped pick's way in is still in it
_held = {} # what pick() holds: {"top_mm", "x", "y"} for place() / put_down()
_pick_way = {} # the pick's waypoints {name: pose} from the move to above until the
# hand holds or has backed out (back_out after a stop)
_cancel = threading.Event() # set by cancel(): the running skill makes no further move
LOG = collections.deque(maxlen=40) # last log lines, shown by the API
moved_at = {} # camera -> time its last move (lift, waist, base, head) ended:
@@ -1015,6 +1018,7 @@ def _prepare():
if gripper.state()["ai"][0] > OPEN_AI:
log("opening the gripper")
gripper.open_()
back_out()
if max(abs(a - b) for a, b in zip(_joints(), home_joints())) > 1.0:
from manipulation import arm_route
arm_route.goto(home())
@@ -1038,14 +1042,40 @@ def _give_up(reason, back=0.0):
"""Open, back up 100 mm (from a side grasp first `back` mm out sideways: the rim is wider than the hooks), home,
raise. Only used while the object is at (or just above) the table."""
log(f"{reason}: opening, backing up")
_held.clear()
gripper.open_()
if back:
_line("out sideways", back_off(motion.tcp(), back))
motion.move_linear(delta=[0, 0, ABOVE_MM], speed=HOLDING_SPEED)
_back_home()
_pick_way.clear()
raise SkillError(reason)
def back_out():
"""A pick stopped on its way in (_pick_way: the open hand beside the object or down around it): out the way it
came before anything else moves, a side grasp straight out against the tips' direction to its "side" point, then
straight up to its "above" height. Nothing when no pick was stopped there or the hand is no longer near its way."""
if not _pick_way:
return
now, way = motion.tcp(), _pick_way
above, grasp = way["above"], way["grasp"]
start = way.get("side", grasp)
near = np.hypot(start[0] - grasp[0], start[1] - grasp[1]) + BACK_OUT_NEAR_MM
if now[2] >= above[2] - 1.0 or now[2] < grasp[2] - BACK_OUT_NEAR_MM or \
np.hypot(now[0] - grasp[0], now[1] - grasp[1]) > near:
_pick_way.clear() # already up there, or moved away since: nothing to back out of
return
log("a pick was stopped here: backing out the way it came in")
if "side" in way:
d = float(np.dot(np.subtract(now[:2], start[:2]), tips_dir(yaw_of(now))))
if d > 1.0:
now = back_off(now, d)
_line("out sideways", now)
_line("up", [now[0], now[1], above[2]] + list(now[3:]))
_pick_way.clear()
def _do_pick(obj, waypoints, ja):
"""Pick with the planned joints `ja` above the object (pick_options); a side grasp goes down beside it first."""
way = dict(waypoints)
@@ -1055,8 +1085,11 @@ def _do_pick(obj, waypoints, ja):
if table is None:
table = table_z(obj) if table_z(obj) is not None else table_near(obj) # what put down needs: the object's height
log(f"it stands on a table at {table:.0f} mm" if table is not None else "the table under it is not in view")
_held.clear() # nothing held until the fingers close on it
_prepare()
_go_on()
_pick_way.clear()
_pick_way.update(way)
log(f"above: joint move to ({above[0]:.0f}, {above[1]:.0f}, {above[2]:.0f})")
motion.move_joints(ja, EMPTY_SPEED)
if back:
@@ -1068,14 +1101,17 @@ def _do_pick(obj, waypoints, ja):
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']} finger sensor {s['object_in_front']}")
if not s["holding"]:
_give_up("I missed it.", back)
# held from here on: a stop in the lift leaves it ready to put down
_held.update(top_mm=obj["top_mm"], x=obj["x"], y=obj["y"], yaw=yaw_of(grasp), table=table,
tips=grip_width(obj) < BELLY_MIN_MM, below=obj["top_mm"] - grasp_height(obj), back=back)
_pick_way.clear()
_line("lift", lift)
s = gripper.state()
log(f"AI_1 {s['ai'][0]:.0f} holding {s['holding']}")
if not s["holding"]:
_held.clear()
_line("slipped, back down", grasp)
_give_up("It slipped out of my hand.", back)
_held.update(top_mm=obj["top_mm"], x=obj["x"], y=obj["y"], yaw=yaw_of(grasp), table=table,
tips=grip_width(obj) < BELLY_MIN_MM, below=obj["top_mm"] - grasp_height(obj), back=back)
def _do_place(waypoints):