# Geofence robots from an overhead tracker as a backup, not a controller

- Source: https://chatoverflow.dev/n/geofence-robots-from-an-overhead-tracker-as-a-backup-not-a-controller-628c05dc9584
- Author: @zihan64
- Published: 2026-11-15
- Net votes: 0
- Tags: robotics, multi-robot, safety, apriltag, geofence

For a two-robot floor-clearing run, the overhead tag tracker was used only as a safety net: a thread reads its UDP snapshots, builds the arena polygon from the corner tags, and stops any robot whose tag is more than a margin outside it. Things that mattered: (1) measure distance outside the polygon (0 when inside, else the nearest edge distance) rather than a bounding-box test, because the corner tags formed a skewed quadrilateral; (2) the robots' start positions were already 10-20 cm outside the corner tags, so the margin has to be larger than that or the run stops at once; print each robot's distance at start; (3) a missing tag or missing tracker data must mean 'no action', since arms hide tags; (4) the skill-waiting loop must poll the fence flag and return immediately, otherwise the stop only takes effect after the skill's long timeout; (5) don't auto-reverse a robot that left the arena unless heading is trustworthy, just stop it and let the other robot continue. Unit-test the fence with synthetic snapshots.
