Commit Graph

7 Commits

Author SHA1 Message Date
efa8f4bb48 feat: route a profile to the matcher its pattern names, and add an arc dock model
The handler held one concrete VPatternMatcher, so a profile declaring
pattern: arc could not reach the arc matcher at all. It now picks by pattern at
start(), reads the arc_* keys from YAML, and calls whichever matcher the
profile named.

An explicit switch, not a virtual interface: the set of patterns is a closed
enum, each matcher weighs one DockProfile, and adding a shape is one member and
two branches - cheaper than an abstraction layer over two implementations. Each
matcher refuses a profile that is not its own, so a branch missing from that
switch shows up at BOOT with the pattern named, not at runtime as "it never
detects".

Intensities go only to the V matcher. findTape walks the ray span of a fitted
line segment and an arc produces none, so an arc profile that sets tape_enabled
is already refused when the config loads.

sim/models/dock_cradle_arc is a concave cradle, radius 0.40 m over 2.0 rad, for
testing this in Gazebo. Its origin sits ON the deepest point, unlike
dock_plate_v whose origin is 0.2121 m off the apex and has caused confusion:
the detector reports the deepest point, so here that is the same number you
spawn at, with nothing to subtract.

It is 24 flat facets rather than a mesh, because Gazebo classic has no arc
primitive and a mesh means a binary file in the repo. The approximation error
is the sagitta of one chord, 0.35 mm - an order below the 3 mm range noise, so
the circle fit cannot tell it from a real curve.

Two tests pin the routing rather than the matching rules, which have their own
tests in dock_pattern_detector: a cradle under an arc profile writes the goal
frame at the deepest point, and a V plate under the same arc profile is
rejected. Without the second one, a change that broke arc detection outright
would look exactly like the gate doing its job.
2026-08-26 20:15:05 +07:00
487396a491 feat: pass scan intensities to the matcher and load the tape profile keys
The tape gate reads intensity by ray index, so it is only correct when the
intensity array and the ranges array come from the same scan and have the same
length. The handler hands scan->intensities straight across - not rebuilt, not
buffered, not remembered from an earlier scan.

That is a joint, and joints are what the unit tests below cannot see, so it has
its own coverage: ATapeProfileOnAScanWithoutIntensitiesSaysWhy feeds the exact
plate being looked for on a scan that carries no intensities and requires the
handler to say "no intensity data". A handler that passed a fabricated array
would never produce that line.

One log line per action run, on the first detection that matches, and only when
the tape check is on: how many bright rays each wing returned, the measured
spacing and widths, each against the profile value and tolerance. This is the
number whoever installs a dock needs - tape stuck a few centimetres off still
detects today and then fails outright once it is dusty or damp, and without
this line nobody knows it was already at the edge. Once, because it is a
commissioning number and not a heartbeat.
2026-08-26 16:46:46 +07:00
duongtd
633291054b Widen the tape: 5 cm gives two rays, and two rays is not a centroid
laser_retro reaches intensities - the check came back with 2000.0 - but only on
two rays. nanoscan3 puts 690 samples across 272 degrees, so 0.00689 rad per
ray, coarser than the resolution the 5 cm strip was sized against. On a wing
raked 45 degrees to the line of sight a 5 cm strip covers 2.6 rays at 2 m and
1.7 at 3 m. Below three rays a centroid carries no useful position and the
width cannot be measured at all, so the strip is present but useless exactly
where docking starts.

At 12 cm it is 6.2 rays at 2 m and 4.1 at 3 m.

The requirement generalises and belongs with the physical station, not just
this model: n = w * cos(rake) / (r * angular_step), so at least three rays at
range r needs w >= 3*r*0.00689/0.707 - about 9 cm at 3 m. Tape narrower than
that loses the target at range, and the cause is in that formula rather than
anywhere in the detector.
2026-08-26 15:37:54 +07:00
duongtd
9dc31e9b88 Warn that Gazebo will not spawn over an existing plate
Spawning the plate a second time fails with "entity already exists" and leaves
the previous one in the world. Edit the model, spawn again, and nothing
changes - which reads as a broken model rather than a refused spawn. It cost a
round trip here: the tape was added, the plate was respawned, and intensities
stayed at zero because the plate standing in the world was the one from before
the tape existed.

The launch and the README now say to delete first, and the README lists the
stale-plate case ahead of the two real ways intensities can come back empty, in
the order worth checking them.
2026-08-26 15:34:12 +07:00
duongtd
4033939ff8 Give the simulated plate reflective tape, and correct where its apex is
/f_scan/intensities comes back all zeros in simulation. That is not a missing
feature: libgazebo_ros_laser fills intensities from the laser_retro of the
collision a ray hits, and nothing in the world declares one. Without a surface
that reflects, an intensity-based layer has nothing to work with and would
look broken rather than unconfigured.

The plate now carries two 0.05 m strips at laser_retro 2000 against a
background of 0, spaced 0.1945 m centre to centre, standing 2.5 mm proud of
the wing so rays hit the tape and not the wing behind it. Those two numbers
are what a profile would be given.

Also fixes the model's own description, which said the apex sits at the model
origin with the wings opening toward +X. Working it out from the wing poses,
the apex is at (0.2121, 0) and the V opens toward -X - which is why the spawn
launch turns it by pi. Left as it was, anyone placing the plate would be off
by 0.21 m and would be comparing the model origin against a detector that
reports the apex.
2026-08-26 15:15:45 +07:00
duongtd
4ca57355ba Add a V plate model so the detector has something to find in simulation
The chain was testable but not runnable: simulation fakes the dock entirely
(use_simulated_goal writes an invented pose 1.6 m ahead of base_link), so no
physical object exists for a laser to see. Nothing in the worlds under
Test/simulators is a dock either.

This is the missing half - an SDF plate whose geometry matches the v_std
profile exactly: 90 degree interior angle, 0.30 m wings. 0.02 m thick so
min_split_dist does not read the two faces of one wing as two segments, and
0.6 m tall from the floor so a planar laser at any plausible mounting height
cuts through it.

The plate and the profile have to agree. Change the model and the wing_length
gate rejects the very object that was just spawned, which is the kind of
failure that looks like a broken detector.
2026-08-26 13:14:02 +07:00
duongtd
8269e20576 Run the dock detector as an action, from raw scan to goal frame
This is the layer that turns the geometry into something the robot actually
runs. It pulls a raw scan from the shared store, extracts lines, matches the
dock pattern, transforms into the global frame and writes the result as a
static transform - the same output contract FrameSampler has, so the charge
sequence keeps working and nothing in move_base2, dock_planner or
mission_adapters changes. Swapping detectors is one word in the YAML.

It is also the only place in the chain allowed to know about TF, actions and
the sensor store. The three packages beneath it stay free of all that, which
is what lets their tests build a world, cast rays and finish in a millisecond
with no runtime around them.

Three things only break once the pieces are joined, and no core test can see
them:

The scan cursor. A 30 Hz control loop reading a 29 Hz lidar ticks more often
than scans arrive. Without the cursor the same scan counts as several samples,
min_samples stops meaning anything, and the handler commits on one measurement.

TF arriving after the scan. The two come from different sources, so TF running
a few milliseconds behind is routine. The store's cursor has already moved past
that scan, so dropping the sample loses a detection outright every time TF is
late. The detection is now held and transformed on a later tick, without
re-running the match - the shape was already found, only the transform was
missing. The regression test fails without that, which is how it earned its
place.

Transforming at the scan's own stamp rather than at the latest. The pose just
computed belongs to the moment the scan was taken; looking up at another moment
mixes two instants into one measurement. The error from "latest" is small but
nobody knows how small, and a stamp on the wrong clock shows up exactly here.

Rejections happen at boot, not at detection time: no sensor store, a scan_topic
the store does not carry (listing the ones it does - a mistyped topic looks
exactly like a dead sensor), no profiles, a pattern that is not implemented,
a default_profile that does not exist. Every profile is validated, not just the
default one, because a typo in the fifth profile that only surfaces at four in
the afternoon is the worst kind.

An order asking for a profile that does not exist fails and says which ones do.
It does not quietly fall back to the default: using the wrong geometry means
docking in the wrong place, not being slightly slower.

The timeout message says which gate failed. Nothing matched, matched too
rarely, or matched but never settled need opposite responses, and one failure
line cannot carry that.
2026-08-26 13:03:22 +07:00