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:
+79
-8
@@ -31,7 +31,7 @@ for yaw in (-30, 45): # a t
|
||||
p = dict(skills.plan_place(-200, 600, cup["top_mm"], yaw=yaw))["place"]
|
||||
assert np.allclose(np.array(p[:3]) + calib.rpy_matrix(*p[3:]) @ skills.GRASP_OFFSET, [-200, 600, g[2] + 3])
|
||||
|
||||
for bad in (88, 30, 50): # seen widths: +SEEN_UNDER_MM over 92, under 61
|
||||
for bad in (95, 30, 50): # seen widths: +SEEN_UNDER_MM over 97, under 61
|
||||
try:
|
||||
skills.plan_pick({**cup, "width_mm": bad})
|
||||
raise AssertionError(f"width {bad} accepted")
|
||||
@@ -221,7 +221,7 @@ skills.flat_points = real_flat
|
||||
print("skills fresh / flat ok")
|
||||
|
||||
# ---------- a pick stores what put down needs: the table under the object, also when its bottom was not in view ------
|
||||
skills._prepare = lambda: None
|
||||
real_prepare, skills._prepare = skills._prepare, lambda: None
|
||||
skills._cancel.clear() # cancel() above
|
||||
skills.motion.move_joints = lambda j, speed=None: None
|
||||
skills.gripper.close = lambda: {"ai": [3500.0], "holding": True, "object_in_front": False}
|
||||
@@ -365,29 +365,29 @@ print("skills on_table ok")
|
||||
|
||||
# ---------- side grasp: a cup too wide at the top for the hooks to come down over it, narrower lower down ----------
|
||||
top = cup["top_mm"]
|
||||
wide = {**cup, "width_mm": 90.0, "height_mm": 120.0, # 98 the fingers would meet: over MAX_WIDTH
|
||||
"profile": [(top - 10.0 * i, 88.0 if i < 4 else 72.0) for i in range(12)]} # 96 at the rim, 80 from 40 mm down
|
||||
wide = {**cup, "width_mm": 92.0, "height_mm": 120.0, # 100 the fingers would meet: over MAX_WIDTH
|
||||
"profile": [(top - 10.0 * i, 100.0 if i < 4 else 72.0) for i in range(12)]} # 100 at the rim, 72 from 40 mm down
|
||||
assert skills.side(wide) and not skills.side(cup)
|
||||
d = skills.tips_dir()
|
||||
assert np.isclose(np.linalg.norm(d), 1.0) and d[1] > 0.5 # the tips point away from the robot
|
||||
z = skills.side_height(wide)
|
||||
assert z == top - 65.0, z # nearest SIDE_AT of its 120 mm (50 mm up, top - 70) where the band is all 72
|
||||
short = {**wide, "top_mm": top - 50.0, "height_mm": 70.0, # a 70 mm cup on the same table
|
||||
"profile": [(top - 50.0 - 10.0 * i, 88.0 if i < 2 else 74.0) for i in range(7)]}
|
||||
"profile": [(top - 50.0 - 10.0 * i, 100.0 if i < 2 else 74.0) for i in range(7)]}
|
||||
assert skills.side_height(short) == top - 50.0 - 45.0 # 25 mm up: the hooks' bottom 17 over it
|
||||
way = skills.plan_pick(wide)
|
||||
assert [n for n, _ in way] == ["above", "side", "grasp", "lift"], way
|
||||
p = dict(way)
|
||||
assert np.isclose(p["side"][2], p["grasp"][2]) and p["side"][3:] == p["grasp"][3:] # in level at the grasp height
|
||||
back = skills.side_back(wide)
|
||||
assert np.isclose(back, 98.0 / 2 + np.linalg.norm(skills.TIPS_OFFSET) + skills.SIDE_CLEAR_MM)
|
||||
assert np.isclose(back, 100.0 / 2 + np.linalg.norm(skills.TIPS_OFFSET) + skills.SIDE_CLEAR_MM)
|
||||
assert np.allclose(np.subtract(p["grasp"][:2], p["side"][:2]), d * back) # it goes in along the tips' direction
|
||||
assert np.allclose(np.subtract(p["above"][:3], p["side"][:3]), [0, 0, skills.clear_above(top - z)])
|
||||
g = np.array(p["grasp"][:3]) + calib.rpy_matrix(*p["grasp"][3:]) @ skills.GRASP_OFFSET
|
||||
assert np.allclose(g, [wide["x"], wide["y"], z]) # the hooks' point on the cup axis
|
||||
assert [n for n, _ in skills.plan_pick(cup)] == ["above", "grasp", "lift"] # a cup whose top fits: from above, as before
|
||||
for bad in ([(top - 10.0 * i, 88.0) for i in range(12)], # wide all the way down
|
||||
[(top - 10.0 * i, 88.0 if i < 10 else 72.0) for i in range(12)], # narrow only where the hooks hit the table
|
||||
for bad in ([(top - 10.0 * i, 100.0) for i in range(12)], # wide all the way down
|
||||
[(top - 10.0 * i, 100.0 if i < 10 else 72.0) for i in range(12)], # narrow only where the hooks hit the table
|
||||
None): # its widths down its height not measured
|
||||
try:
|
||||
skills.plan_pick({**wide, "profile": bad})
|
||||
@@ -428,3 +428,74 @@ assert [n for n, _ in lines_] == ["side", "grasp", "out sideways", "up"], lines_
|
||||
assert np.allclose(np.subtract(p["grasp"][:2], lines_[2][1][:2]), d * back)
|
||||
skills._held.clear()
|
||||
print("skills side grasp ok")
|
||||
|
||||
# ---------- a pick stopped on its way in (the open hand beside / around the cup): the next pick backs out the way it
|
||||
# came first, never a diagonal move from there; a stop once the fingers hold it leaves it ready to put down ----------
|
||||
def stop_at(where, at): # STOP while moving to waypoint `where`: the hand ends at `at`
|
||||
def line(name, pose):
|
||||
lines_.append((name, pose))
|
||||
if name == where:
|
||||
skills.motion.tcp = lambda: list(at)
|
||||
raise skills.SkillError("Stopped.")
|
||||
skills.motion.tcp = lambda: list(pose)
|
||||
return line
|
||||
skills.gripper.close = lambda: {"ai": [3500.0], "holding": True, "object_in_front": False}
|
||||
skills.gripper.state = lambda: {"ai": [150.0], "holding": False} # open: the stop came before the close
|
||||
skills._joints = skills.home_joints = lambda: [0.0] * 6 # back at home after backing out: no route
|
||||
mid = list(np.add(p["side"], p["grasp"]) / 2) # half way in, beside the cup
|
||||
for way_, where, at, want in ((way, "grasp", mid, ["out sideways", "up"]), # side grasp, half way in
|
||||
(way, "grasp", p["grasp"], ["out sideways", "up"]), # ... around it
|
||||
(way, "side", p["side"], ["up"]), # ... still coming down
|
||||
(skills.plan_pick(cup), "grasp", grasp, ["up"])): # down around it from above
|
||||
w = dict(way_)
|
||||
skills._held.update(top_mm=-1.0, x=0.0, y=0.0) # from an earlier pick
|
||||
lines_.clear()
|
||||
skills._line = stop_at(where, at)
|
||||
try:
|
||||
skills._do_pick(wide if "side" in w else cup, way_, READY)
|
||||
raise AssertionError("not stopped")
|
||||
except skills.SkillError:
|
||||
pass
|
||||
try: # "put it down": nothing is held, nothing moves
|
||||
skills.put_down()
|
||||
raise AssertionError("put down with an open hand")
|
||||
except skills.SkillError as e:
|
||||
assert e.args[0] == "I'm not holding anything I picked.", e.args
|
||||
lines_.clear()
|
||||
real_prepare() # "take the cup" again
|
||||
assert [n for n, _ in lines_] == want, (where, lines_)
|
||||
out, top_ = lines_[-2][1] if len(lines_) > 1 else at, lines_[-1][1]
|
||||
start_ = w.get("side", w["grasp"])
|
||||
assert np.allclose(out[:3], [start_[0], start_[1], at[2]], atol=1e-6), (out, start_) # out along the way in
|
||||
assert np.allclose(top_[:3], [start_[0], start_[1], w["above"][2]], atol=1e-6) # then straight up to above
|
||||
lines_.clear()
|
||||
real_prepare() # backed out once: nothing more
|
||||
assert not lines_, lines_
|
||||
skills.motion.tcp = lambda: [0.0, 300.0, 0.0] + list(skills.GRASP_RPY) # moved away since (another task): no lines
|
||||
skills._line = stop_at("grasp", grasp)
|
||||
try:
|
||||
skills._do_pick(cup, skills.plan_pick(cup), READY)
|
||||
except skills.SkillError:
|
||||
pass
|
||||
skills.motion.tcp = lambda: [0.0, 300.0, 0.0] + list(skills.GRASP_RPY)
|
||||
lines_.clear()
|
||||
real_prepare()
|
||||
assert not lines_ and not skills._pick_way, lines_
|
||||
# STOP in the lift, the fingers holding it: put down knows it (as at the end of a pick), the next pick backs out nothing
|
||||
for way_, obj_ in ((way, wide), (skills.plan_pick(cup), cup)):
|
||||
skills._held.clear()
|
||||
skills._line = stop_at("lift", dict(way_)["grasp"])
|
||||
try:
|
||||
skills._do_pick(obj_, way_, READY)
|
||||
raise AssertionError("not stopped")
|
||||
except skills.SkillError:
|
||||
pass
|
||||
assert skills._held["top_mm"] == obj_["top_mm"] and np.isclose(skills._held["back"], back if obj_ is wide else 0.0)
|
||||
assert np.isclose(skills._held["below"], obj_["top_mm"] - skills.grasp_height(obj_)) and not skills._pick_way
|
||||
placed = []
|
||||
real_place_first, skills._place_first = skills._place_first, lambda tries, refusal: placed.append(tries[0])
|
||||
skills.put_down(back=True)
|
||||
skills._place_first = real_place_first
|
||||
assert placed == [(obj_["x"], obj_["y"])], placed
|
||||
skills._held.clear()
|
||||
print("skills stopped pick ok")
|
||||
|
||||
Reference in New Issue
Block a user