The gate used to fire at settle_delay + sample_window and abort, throwing away
whatever remained of the timeout. Four field runs failed there with spreads
between 1.3 m and 3.2 m while the detector reported the pallet to within a
millimetre, and a retry seconds later at the same spot succeeded - the
detection needed longer to settle than the window allowed, and the handler was
not willing to wait.
samples_ is now a sliding window of sample_window seconds: each tick adds the
new sample and drops the expired ones. Once the window is full the spread is
evaluated every tick, and a spread over the limit only means "not yet" - the
handler keeps sampling until it converges or the timeout runs out. The timeout
becomes the real deadline instead of the window.
hold_time requires the spread to stay under the limit for that long before the
result is published, so a momentarily quiet window cannot be mistaken for a
settled one. 0 keeps the previous behaviour of publishing on the first good
window.
Convergence is logged once a second, not per tick, so it is possible to see
whether the sample set is tightening without drowning a 30 Hz loop. median and
robustSpread now take their buffer by reference and sort it in place, since
they run on every tick rather than once per detection.
The spread number alone cannot separate two failures that need opposite
responses: a handful of samples landing far away while the rest agree, which
is a mis-detection at the source, versus every sample drifting, which means
the detection genuinely is not settled and the robot should re-detect or move
closer.
Four field runs hit this gate with spreads between 1.3 m and 3.2 m while the
detector itself reported the pallet to within a millimetre and the robot stood
still. Each run eliminated one theory and offered nothing to replace it,
because a single scalar cannot say where the samples went.
On failure the handler now logs the sample count, the filtered centre, the
deviation at p50, p90 and max, and the bounding box in the fixed frame.
Comparing p50 against p90 separates the two cases, and the box says where the
stray samples ended up - sitting on the robot's own position means something
very different from being scattered around the target.
Runs once per failed detection, never on the sampling path.