Improve put-down checks from the side

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 03:52:23 +09:00
co-authored by Claude Opus 5.5
parent 3f392343bf
commit ac13ced892
4 changed files with 18 additions and 15 deletions
+2 -2
View File
@@ -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
+7 -4
View File
@@ -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