feat(leg_pattern): add LegPatternMatcher for 4-leg trolleys

Finds a 4-leg trolley in a raw LaserScan without line extraction:
shadow filter, leg clusters in ray order with free/occluded/attached edges,
pair hypotheses from cart_opening/cart_depth/diagonal, then a Gauss-Newton
pose fit over every leg point with an along-ray residual, Huber weights and
backtracking. Gates: pair spacing after the fit, see-through leg positions,
optional empty interior, entry side (entry tape / prior yaw / facing the
sensor), optional prior, confidence, and ambiguity between two carts.

LegProfile validates every key at load. Two gtests (7 + 23) run on a
synthetic ray-cast scan (test/leg_scan_sim.h). Used by trolley_detection_action.
This commit is contained in:
2026-10-28 13:43:56 +07:00
parent edc6b30431
commit c568e90c53
11 changed files with 3324 additions and 0 deletions

View File

@@ -151,11 +151,31 @@ config rồi không bao giờ dò ra gì — hai thứ đó nhìn giống hệt
tại, hoặc trượt cái hình có thật. Giá trị mặc định trong code chỉ để test chạy, **không phải** giá
trị cho trạm thật.
## Xe hàng 4 chân — `LegPatternMatcher`
Bộ dò thứ ba, **không** thuộc enum `PatternType` và không dùng `DockProfile`: profile riêng
`LegProfile` (`leg_profile.h`), đầu vào là `ranges` + `intensities` THÔ chứ không phải đoạn thẳng —
chân xe chỉ là một cụm vài tia. Handler dùng nó là gói `trolley_detection_action`; chuỗi sạc
(`dock_pattern_action`) không đổi.
Các bước: lọc điểm kéo đuôi → tách cụm theo thứ tự tia → phân loại mép cụm (tự do / bị che / dính
tường) và bề rộng biểu kiến → giả thuyết từ cặp chân khớp `cart_opening` / `cart_depth` / đường chéo
→ gán chân vào 4 góc, khớp tư thế Gauss-Newton trên **mọi điểm chân** theo mô hình biên chân
(`leg_pose_fit.h`) → kiểm khoảng cách từng cặp chân → bằng chứng phủ định (tia đi xuyên chỗ một chân
phải đứng thì loại) → lòng xe trống → chọn cạnh vào (dải `entry`, prior, hoặc cạnh quay về cảm
biến) → cổng prior → từ chối khi hai xe điểm sát nhau ở hai chỗ.
Quy ước đầu ra giống V/arc: `center_yaw` là pháp tuyến cạnh vào hướng về cảm biến; lật theo cách
robot chui (tiến/lùi) là việc của handler. Plan đầy đủ: `Test/docs/trolley_detection_action/` của
workspace phát triển.
## Build và test
```bash
catkin_make --pkg dock_pattern_detector
./devel/lib/dock_pattern_detector/v_pattern_matcher_test # 16 test
./devel/lib/dock_pattern_detector/leg_pose_fit_test
./devel/lib/dock_pattern_detector/leg_pattern_matcher_test
```
Test chạy đúng chuỗi mà handler sẽ chạy: dựng thế giới → chiếu tia → `robot_line_extraction` →