Improve put-down checks from the side
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ Every value here is a constant at the top of its file, with a comment on what it
|
||||
| `tasks/fetch.py` | `WAIST_SCAN_MAX` | 120° | The waist turns up to this in the search (body limit ±140° absolute), the head turns the rest |
|
||||
| `tasks/fetch.py` | `SEARCH_BASE_DEG` | 180°, 90° | Then the base turns towards the busier side, the first of these whose sweep is clear, and all again |
|
||||
| `tasks/fetch.py` | `LIFT_TRIES` | 0, 105 mm (`LIFT_RANGE`) | Nothing found: all of it again at the other end |
|
||||
| `tasks/fetch.py` | `APPROACH_TRIES` | 5 | Base moves to bring an object into reach before asking the person |
|
||||
| `tasks/fetch.py` | `APPROACH_TRIES` | 8 | Base moves to bring an object into reach before asking the person |
|
||||
| `tasks/fetch.py` | `PROGRESS_MM` | 40 mm | A base move that brought the object less than this nearer its goal (odometry) did nothing: that way is not tried again from there |
|
||||
| `tasks/fetch.py` | `GOAL_SHIFTS_MM` | 0, −120, +120 mm | The straight way in aims the object at the pick zone, then this far to either side of it (a small turn and in) |
|
||||
| `tasks/fetch.py` | `APPROACH_SIDES` | 0, ±45, ±90, ±135, 180° | Then navigation to each of these sides of the object, once; a side where the base can't stand near enough is skipped |
|
||||
|
||||
@@ -458,7 +458,7 @@ def surface_points(points_xy, guess_z=-400.0, camera=objects.CAMERA, T=None):
|
||||
|
||||
|
||||
def flat_points(points_xy, guess_z=-400.0, camera=objects.CAMERA, T=None):
|
||||
"""Like surface_points, but only where the camera sees a level surface (a table top, a seat, the floor): the depth
|
||||
"""Like surface_points (also (x, y, z) given whole), but only where the camera sees a level surface (a table top, a seat, the floor): the depth
|
||||
pixels around the sight line's pixel (FLAT_PATCH) lie on a plane leaning less than FLAT_DEG. (x, y, z) mm, arm base
|
||||
frame, is the middle of that patch; None where it is not level (a chair's back, a table's edge, a person), out of
|
||||
view or without depth."""
|
||||
@@ -469,7 +469,7 @@ def flat_points(points_xy, guess_z=-400.0, camera=objects.CAMERA, T=None):
|
||||
return [None] * len(points_xy)
|
||||
K = np.array([[intr["fx"], 0, intr["cx"]], [0, intr["fy"], intr["cy"]], [0, 0, 1]])
|
||||
dist, Ti = np.array(intr["dist"]), np.linalg.inv(T)
|
||||
P = np.array([[p[0], p[1], guess_z] for p in points_xy], float)
|
||||
P = np.array([[p[0], p[1], p[2] if len(p) > 2 else guess_z] for p in points_xy], float)
|
||||
cam = (Ti[:3, :3] @ P.T + Ti[:3, 3:4]).T
|
||||
uv = np.round(cv2.projectPoints(cam, np.zeros(3), np.zeros(3), K, dist)[0].reshape(-1, 2)).astype(int)
|
||||
step, half = FLAT_PATCH
|
||||
@@ -562,8 +562,8 @@ def table_near(obj):
|
||||
|
||||
|
||||
def on_table(spots_xy, table_mm=None):
|
||||
"""The (x, y) spots where the torso depth camera sees table: the centre and TABLE_RING_MM around it, each within
|
||||
TABLE_TOL_MM of `table_mm` (None: of each other). Points the camera can't see count as not table, but one on the
|
||||
"""The (x, y) spots where the torso depth camera sees level table (flat_points): the centre and TABLE_RING_MM
|
||||
around it, each within TABLE_TOL_MM of `table_mm` (None: of each other). Points the camera can't see count as not table, but one on the
|
||||
near side (y below the centre's) is checked again at TABLE_NEAR_RING_MM: the camera sees a table only from
|
||||
y ~640 on, where the arm hardly reaches past y 700."""
|
||||
angles = np.linspace(0, 2 * math.pi, 8, endpoint=False)
|
||||
@@ -571,10 +571,10 @@ def on_table(spots_xy, table_mm=None):
|
||||
inner = [(0.0, 0.0)] + [(TABLE_NEAR_RING_MM * math.cos(a), TABLE_NEAR_RING_MM * math.sin(a)) for a in angles]
|
||||
guess = table_mm if table_mm is not None else -400.0 # only to find the pixels; the depth decides
|
||||
|
||||
def heights(pts): # z of the surface at each point: the sight line aimed again at the height
|
||||
first = surface_points(pts, guess) # it met must meet it at the point itself (a line just past the near
|
||||
aim = [(p[0], p[1], q[2]) for p, q in zip(pts, first) if q is not None] # edge meets the top further on)
|
||||
second = dict(zip([a[:2] for a in aim], surface_points(aim) if aim else []))
|
||||
def heights(pts): # z of the level surface at each point: the sight line aimed again at the
|
||||
first = flat_points(pts, guess) # height it met must meet it at the point itself (a line just past the
|
||||
aim = [(p[0], p[1], q[2]) for p, q in zip(pts, first) if q is not None] # near edge meets the top further
|
||||
second = dict(zip([a[:2] for a in aim], flat_points(aim) if aim else [])) # on, or the edge's face)
|
||||
out = []
|
||||
for p, q in zip(pts, first):
|
||||
r = None if q is None else second[(p[0], p[1])]
|
||||
|
||||
@@ -57,7 +57,7 @@ ROUND = {"c": (-160.0, 1020.0), "r": 400.0} # the round table, arm fra
|
||||
|
||||
def depth(pts, guess_z=-400.0):
|
||||
out = []
|
||||
for x, y in pts:
|
||||
for x, y, *_ in pts:
|
||||
on = math.hypot(x - ROUND["c"][0], y - ROUND["c"][1]) <= ROUND["r"]
|
||||
out.append(None if y < VIEW_Y else TABLE_Z if on else -1000.0) # the floor beyond the table
|
||||
return out
|
||||
@@ -67,7 +67,7 @@ FLAT_REAL = skills.flat_points
|
||||
|
||||
|
||||
def flat(pts, guess_z=-400.0, camera="torso", T=None):
|
||||
return [None if z is None else (x, y, z) for (x, y), z in zip(pts, depth(pts))]
|
||||
return [None if z is None else (p[0], p[1], z) for p, z in zip(pts, depth(pts))]
|
||||
|
||||
|
||||
skills.surface_heights, skills.flat_points = depth, flat
|
||||
|
||||
@@ -324,17 +324,20 @@ assert np.allclose((np.array(fixed[:3]) + Rt @ new)[:2], np.array([-100.0, 600.0
|
||||
print("skills offset ok")
|
||||
|
||||
# on_table: a spot whose near ring point is just off the table's near edge is not table, though that sight line, aimed
|
||||
# a little too high, meets the top a bit further on at table height (X1's sweep, a cup put down 17 mm off the edge)
|
||||
# a little too high, meets the top a bit further on at table height, or the top's edge face (not level) (X1's sweep:
|
||||
# cups put down 3-10 mm inside the edge)
|
||||
CAM, EDGE_Y, TOP = np.array([-258.0, 14.0, -41.0]), 600.0, -420.0
|
||||
def cast(pts, guess_z=-400.0):
|
||||
def cast(pts, guess_z=-400.0): # flat_points' answer: level top / floor, None on the face
|
||||
out = []
|
||||
for p in pts:
|
||||
p = np.array([p[0], p[1], p[2] if len(p) > 2 else guess_z])
|
||||
d = (p - CAM) / np.linalg.norm(p - CAM)
|
||||
q = CAM + d * (TOP - CAM[2]) / d[2] # where the line meets the table's plane
|
||||
out.append(tuple(q) if q[1] >= EDGE_Y else tuple(CAM + d * (-900.0 - CAM[2]) / d[2])) # else the floor
|
||||
face = CAM + d * (EDGE_Y - CAM[1]) / d[1] # ... and the plane of its near face
|
||||
out.append(tuple(q) if q[1] >= EDGE_Y else None if TOP - 30.0 <= face[2] <= TOP
|
||||
else tuple(CAM + d * (-900.0 - CAM[2]) / d[2]))
|
||||
return out
|
||||
skills.surface_points = cast
|
||||
skills.flat_points = cast
|
||||
assert skills.on_table([(-100.0, 700.0)], -400.0) == [(-100.0, 700.0)] # well on it, table read 20 mm high
|
||||
assert skills.on_table([(-100.0, 620.0)], -400.0) == [] # its near ring point 5 mm off the edge
|
||||
assert skills.on_table([(-100.0, 700.0)]) == [(-100.0, 700.0)] # table height not given
|
||||
|
||||
Reference in New Issue
Block a user