Commit Graph

5 Commits

Author SHA1 Message Date
d58d08eda3 feat: confirm a candidate with reflective tape when the profile asks for it
Geometry alone cannot answer the question that matters in a warehouse. Every
wall corner and every pair of pallets stacked at a right angle is a V of some
size, and enough of them are the right size. None of them carry two strips of
reflective tape at the expected spacing.

Off by default: with tape_enabled false the matcher never reads the intensity
array and nothing about the existing behaviour changes.

On, it is an extra criterion, not a fifth pattern type. Shape still decides
where the apex is and the pose that comes out is still entirely from shape;
the tape only answers whether this is the dock. The check runs after every
geometric gate, because it is the expensive one and geometry has already
thrown out nearly every candidate by then - measured at +0.11 us per scan
against the 508 us the line extraction ahead of it already costs.

On each wing it takes the longest consecutive run of bright rays, then:
  - the two run centres must be tape_spacing apart;
  - each run must be tape_width long, checked only when the run has 2 or more
    rays. One ray tells you it is bright but not how wide, and at the range
    where that happens the tape is what you needed most, so the criterion is
    skipped rather than guessed.

Runs are searched across the whole ray span the wing covers, not only the rays
that supported the fitted line: tape that stands proud of the wing surface can
be split off into its own segment, and then the very rays being looked for no
longer belong to any wing.

The measured width is always short - the outermost bright rays land inside the
strip, not on its edges, so the span between them misses up to one ray spacing.
At 3 m one nanoscan3 ray spacing is 0.021 m, 17% of a 0.12 m strip. That is
systematic, not noise, so it is corrected: n bright rays span exactly n-1 gaps,
and adding one gap adds half a gap at each edge. The gap comes from the run
itself, so it self-calibrates for range and for how obliquely the plate is
seen, with no extra parameter. On a deliberately coarse 200-ray scan it reads
0.119 m against a true 0.120 m.

tape_min_intensity carries each sensor's own units and has no common scale -
Gazebo passes laser_retro straight through, a real nanoscan3 does not. When the
profile asks for tape and the scan carries no intensities at all, the reason
says so, because that symptom is otherwise identical to "the dock is not in
range" and only one of the two is fixable in config.
2026-08-26 16:46:33 +07:00
duongtd
5e39ca2639 Report how many segments the scan produced when a match is refused
A run reported "10 pair(s) of lines cross but do not end at the crossing" over
and over. Ten pairs implies five segments, which is a very different scene from
two, and the message did not say which. A scan fragmenting into a dozen short
pieces and a scan holding only the two far walls print the same line today, yet
they need opposite adjustments: min_split_dist and min_line_length for the
first, a different place to stand for the second.

Every refusal now ends with the segment count, and Detection carries it so a
caller can act on it rather than parse a string.
2026-08-26 15:41:56 +07:00
duongtd
bb38260c07 Drop the separate calibration terms, keep one set of offsets
The split existed to stop a footprint change from silently discarding a field
correction tuned into the same number. Two knobs per axis is a cost paid on
every read of the config, and the person tuning these is the one who knows
which part is which, so the simpler shape wins.

The derivation stays where it matters: the formula for offset_x - half the
robot, the padding, the wing projection, the clearance - is written out in the
runtime config next to the value, so recomputing it after a footprint change
does not start from a guess.
2026-08-26 15:11:26 +07:00
duongtd
000374791b Separate the measured calibration from the derived offset
offset_x/y/yaw carried two different things at once. Part of it is geometry
that can be worked out on paper - half the robot, the footprint padding, how
far the wings project toward the robot, the clearance. The rest is whatever
the real station turns out to need: a laser mounted slightly off, odometry
bias, a systematic lean in the detection.

Folded into one number, changing the footprint silently discards the field
correction that was tuned into it, and nobody can look at the value later and
say which half is which. The first time someone re-derives the geometry, the
calibration is gone and nothing says so.

calib_x/y/yaw are added on top, in the same frame, defaulting to zero. Dock,
measure how far base_link ended up from where it should have, subtract it
here. The geometry stays derivable and the correction stays visible.

They are bounded to 0.30 m and 0.20 rad. Field calibration is centimetres and
degrees; needing half a metre means offset_x is wrong, and taping over that
with a calibration term hides the cause until the next footprint change makes
it worse.
2026-08-26 15:07:24 +07:00
duongtd
a694d5abe2 Find a dock plate in a laser scan and say where the robot must stop
The detection chain had a gap between line segments and a navigation goal.
This is that step: segments plus the geometry of one charger, out comes the
pose base_link has to reach, in the scan's own frame.

Pure geometry, no TF and no action, so it is testable the same way the line
extractor is - build the world, cast the rays, and the answer is known before
the code runs. The tests exercise the real chain end to end, from synthetic
world through robot_line_extraction into the matcher.

The output is the goal pose, not the charger's pose. dock_planner deliberately
carries no standoff key: it derives which edge of the robot meets the dock from
which side of the goal the robot stands on, and that only works because the
goal already is where base_link must end up. The standoff is also a property of
the charger - how deep its contacts sit - so it belongs to the profile.
apex_x/apex_y keep the pre-offset vertex, because a wrong offset and a wrong
detection look identical from the final pose alone.

Matching a V:

The vertex is the intersection of the two fitted lines, not the midpoint of
their endpoints. A line is a least-squares fit over tens of rays; an endpoint
is one ray and much noisier.

Both segments must END near that intersection. Any two non-parallel walls cross
somewhere, and without this gate a corridor corner reads as a dock.

The vertex angle is measured between the two wing vectors from the apex, not
between the two normals. The two agree at exactly 90 degrees and diverge
everywhere else, so confusing them is a silent error at every other opening.

Wing length is what rejects a pallet corner: a pallet has a perfect right
angle, it just has metre-long sides.

Yaw is the bisector pointing back at the sensor, and its sign is chosen by
comparing against the sensor position rather than by the order of the two
wings. That order flips with which side the robot approaches from, and being
180 degrees out here means reversing into the plate instead of driving in.

Confidence is the worst of the three criteria, not their mean. A mean lets a
shape with a badly wrong angle through on the strength of the other two.

The search gate is not optional in a warehouse: any two perpendicular pallets
are a V. candidate_count reports how many survived every gate, so an ambiguous
scene is visible to the layer above rather than silently resolved.

A failed detection reports which gate it failed. "Nothing there" and "something
there but the wrong length" need opposite responses, and one failure line
cannot carry that.

Declaring a pattern that is not implemented is refused at configure time.
Accepting it would produce a detector that never finds anything, which looks
exactly like a charger out of range.
2026-08-26 12:38:29 +07:00