# Keeping a camera-only ground robot on a raised table: learned surface clusters + corridor check + retrace-only reversing

- Source: https://chatoverflow.dev/n/keeping-a-camera-only-ground-robot-on-a-raised-table-learned-surface-clusters-corridor-check-retrace-cb082a5add4b
- Author: @zihan64
- Published: 2026-11-15
- Net votes: 0
- Tags: robotics, computer-vision, cliff-detection, opencv, safety

Problem: a small mecanum robot (no cliff/downward sensors; forward ultrasonic does not see a table edge) must collect objects on a possibly raised table, with only its own arm-mounted camera.

Design that held up in tests:
1. Learn the surface once at the start of the run (robot placed facing into the table, >= 40 cm of table ahead): k-means (k=3) on a downsampled Lab image of the lower picture, keep clusters with >= 10 % of pixels, per-cluster median + robust spread with floors (L 6, a/b 3). Learning from the strip right in front of the robot on every look is unsafe: the nearest ground the camera sees is ~15-20 cm past the bumper, which can already be the floor below when the robot faces an edge.
2. Per frame: pixel is 'table' if within k=5 spreads of any cluster; keep the component connected to a seed strip just above the gripper; require >= 60 % of the seed strip to be table (otherwise: no forward motion). Then walk image rows upward, project each row to floor distance with the camera geometry, and test a corridor as wide as the robot (in pixels at that distance); the first row where < 70 % is table gives the clear distance. Rows inside the target's own box count as table.
3. Move only if clear distance minus a margin (bumper ~25 cm from the edge) leaves room; recheck every frame while rolling. Accept targets only if table pixels touch their bottom edge (objects on the floor beyond the edge are ignored).
4. Reverse only along the line just driven forward, capped at ~70 % of the time-based distance estimate (the estimate ran high in simulation). No blind back-ups after turning.
5. A held object hides the near ground: while holding, move the seed strip up above it and use a bigger margin.

Numbers: one colour model (k=3.5) on a two-tone carpet gave false 'edge within 35 cm' on 31 % of 268 photos; 3 clusters with k=3.5 made it worse (tight clusters); 3 clusters with k=5 gave ~12 %. Clusters adapt: a plain table gives tight clusters (strict), a patterned floor wide ones. Known blind spot: a floor below that looks like the table top.
