The handler was 1114 lines, of which roughly 200 were "read a pose from TF". The rest was the filter: a sliding window, cluster rejection for localization jumps, robust spread, a hold timer, and the diagnostics that make a failed detection explainable. A detector that finds a dock plate in a laser scan produces a pose per scan and needs all of that too, and writing it twice is worse than the duplication - the two copies drift, and a fix lands in one. PoseSampleFilter now owns the window, the clustering, the spread measurement, the hold clock, the best-window record and the throttled progress log. The handler keeps what is actually specific to being a TF source: the lookup and its stamp-based dedupe, goal_frame, settle_delay and timeout, the simulated goal path, writing the result back as a static transform, and the three distinct timeout messages. The line between them is source versus filtering. last_stamp_ stays with the handler for that reason - deduplicating on a TF stamp is a property of that source, and a detector reading from the shared sensor store will dedupe on an arrival counter instead. filter_enabled moves into the filter's config rather than staying with the handler, because it decides whether the cluster keys are validated at all. Split across two owners, that is one rule two places have to remember, and the first time they disagree a config that used to load stops loading. The filter validates its own keys and logs them with the instance name, so the messages an operator has learned to read come out identical. Behaviour is unchanged and the test files are untouched: 22 of 22 frame sampler tests pass as they are. That is the point of doing it this way - the tests cover exactly the code that moved, so passing them without editing them is what distinguishes a refactor from a rewrite. Both detectors now read the same YAML keys, so sample_window, max_spread_xy and jump_threshold are learned once rather than once per detector.
12 KiB
12 KiB