Files
dock_pattern_action/sim/models/dock_cradle_arc/model.sdf
duongtd 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

284 lines
14 KiB
XML

<?xml version="1.0"?>
<!--
Máng cong LÕM — biên dạng `arc`.
Hình học phải KHỚP profile arc trong action_handlers_params.yaml:
arc_radius = 0.40 m
arc_span = 2.00 rad (115 độ)
GỐC MODEL ĐẶT ĐÚNG TẠI ĐIỂM SÂU NHẤT của máng — khác hẳn `dock_plate_v`, nơi gốc lệch 0.2121 m
so với đỉnh và đã gây nhầm lẫn. Ở đây bộ dò báo toạ độ điểm sâu nhất, và đó chính là chỗ anh
spawn model. Hai con số trùng nhau, không phải trừ đi cái gì.
tâm đường tròn = (-0.40, 0) trong hệ model, tức nằm PHÍA ROBOT so với mặt cong.
Đó là điều phân biệt máng lõm với trụ tròn, và matcher kiểm đúng chỗ đó: nhận nhầm trụ thành
máng là pose đích rơi ra SAU mặt trụ, tức robot được lệnh lái vào trong vật.
Máng mở về phía -X của model. Launch spawn mặc định `yaw:=3.14159` để lật lại, khi đó lòng máng
hướng về +X của world và robot đứng phía +X nhìn vào.
DỰNG BẰNG 24 TẤM PHẲNG thay vì một mặt cong: Gazebo classic không có primitive cung tròn, và
dùng mesh thì phải kèm một file nhị phân vào repo. Sai lệch của phép xấp xỉ là độ võng của một
dây cung:
s = R * (1 - cos(span/2N)) = 0.35 mm
Nhỏ hơn nhiễu tầm của nanoscan3 (3 mm) một bậc, nên phép khớp tròn không phân biệt được nó với
một mặt cong thật — đúng ý đồ. Tăng 24 lên thì nhỏ hơn nữa nhưng nặng thêm cho engine vật lý.
⚠ KHÔNG khai `laser_retro`: profile `arc` TỪ CHỐI `tape_enabled` ngay lúc boot, vì `findTape`
quét theo chỉ số tia của một ĐOẠN THẲNG mà cung không sinh ra đoạn nào. Dán dải lên máng thì
phải viết lại đường tìm vệt theo chuỗi điểm của cung trước đã.
Cao 0.6 m và đáy sát sàn: LiDAR phẳng gắn ở độ cao nào trong khoảng đó cũng cắt qua máng. Dày
0.02 m để `min_split_dist` (0.02 m) không nhầm hai mặt của cùng một tấm thành hai đoạn.
-->
<sdf version="1.6">
<model name="dock_cradle_arc">
<static>true</static>
<link name="cradle">
<collision name="c0">
<pose>-0.170046 -0.327294 0.300 0 0 -0.958333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v0">
<pose>-0.170046 -0.327294 0.300 0 0 -0.958333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c1">
<pose>-0.143601 -0.307017 0.300 0 0 -0.875000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v1">
<pose>-0.143601 -0.307017 0.300 0 0 -0.875000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c2">
<pose>-0.118936 -0.284610 0.300 0 0 -0.791667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v2">
<pose>-0.118936 -0.284610 0.300 0 0 -0.791667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c3">
<pose>-0.096221 -0.260228 0.300 0 0 -0.708333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v3">
<pose>-0.096221 -0.260228 0.300 0 0 -0.708333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c4">
<pose>-0.075615 -0.234039 0.300 0 0 -0.625000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v4">
<pose>-0.075615 -0.234039 0.300 0 0 -0.625000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c5">
<pose>-0.057260 -0.206226 0.300 0 0 -0.541667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v5">
<pose>-0.057260 -0.206226 0.300 0 0 -0.541667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c6">
<pose>-0.041284 -0.176982 0.300 0 0 -0.458333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v6">
<pose>-0.041284 -0.176982 0.300 0 0 -0.458333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c7">
<pose>-0.027797 -0.146509 0.300 0 0 -0.375000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v7">
<pose>-0.027797 -0.146509 0.300 0 0 -0.375000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c8">
<pose>-0.016894 -0.115020 0.300 0 0 -0.291667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v8">
<pose>-0.016894 -0.115020 0.300 0 0 -0.291667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c9">
<pose>-0.008649 -0.082732 0.300 0 0 -0.208333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v9">
<pose>-0.008649 -0.082732 0.300 0 0 -0.208333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c10">
<pose>-0.003121 -0.049870 0.300 0 0 -0.125000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v10">
<pose>-0.003121 -0.049870 0.300 0 0 -0.125000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c11">
<pose>-0.000347 -0.016662 0.300 0 0 -0.041667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v11">
<pose>-0.000347 -0.016662 0.300 0 0 -0.041667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c12">
<pose>-0.000347 0.016662 0.300 0 0 0.041667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v12">
<pose>-0.000347 0.016662 0.300 0 0 0.041667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c13">
<pose>-0.003121 0.049870 0.300 0 0 0.125000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v13">
<pose>-0.003121 0.049870 0.300 0 0 0.125000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c14">
<pose>-0.008649 0.082732 0.300 0 0 0.208333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v14">
<pose>-0.008649 0.082732 0.300 0 0 0.208333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c15">
<pose>-0.016894 0.115020 0.300 0 0 0.291667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v15">
<pose>-0.016894 0.115020 0.300 0 0 0.291667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c16">
<pose>-0.027797 0.146509 0.300 0 0 0.375000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v16">
<pose>-0.027797 0.146509 0.300 0 0 0.375000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c17">
<pose>-0.041284 0.176982 0.300 0 0 0.458333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v17">
<pose>-0.041284 0.176982 0.300 0 0 0.458333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c18">
<pose>-0.057260 0.206226 0.300 0 0 0.541667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v18">
<pose>-0.057260 0.206226 0.300 0 0 0.541667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c19">
<pose>-0.075615 0.234039 0.300 0 0 0.625000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v19">
<pose>-0.075615 0.234039 0.300 0 0 0.625000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c20">
<pose>-0.096221 0.260228 0.300 0 0 0.708333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v20">
<pose>-0.096221 0.260228 0.300 0 0 0.708333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c21">
<pose>-0.118936 0.284610 0.300 0 0 0.791667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v21">
<pose>-0.118936 0.284610 0.300 0 0 0.791667</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c22">
<pose>-0.143601 0.307017 0.300 0 0 0.875000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v22">
<pose>-0.143601 0.307017 0.300 0 0 0.875000</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
<collision name="c23">
<pose>-0.170046 0.327294 0.300 0 0 0.958333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="v23">
<pose>-0.170046 0.327294 0.300 0 0 0.958333</pose>
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
</visual>
</link>
</model>
</sdf>