feat: take the detection frame from robot_base_frame, drop prior_frame

The search fan, prior and mount checks are now expressed in the context's
robot_base_frame, like DockPatternActionHandler. A leftover prior_frame equal
to it loads with one warning; a different one fails init.
This commit is contained in:
2026-11-12 17:01:54 +07:00
parent 775c16820b
commit 641932b601
5 changed files with 115 additions and 44 deletions

View File

@@ -274,16 +274,16 @@ Mặc định **tắt**: robot đứng ở đâu cũng dò được, miễn th
lấy xe điểm tin cao nhất. Hai xe điểm sát nhau ở hai chỗ thì từ chối cả lượt (`ambiguous`), không
đoán. Xe đỗ thành dãy sát nhau trong tầm lidar thì cần prior.
Prior khai trong `prior_frame` (mặc định `base_link`): xe **kỳ vọng** ở đâu khi robot đứng ở điểm dò.
Prior khai trong frame thân robot `robot_base_frame` của move_base2 (`base_link` trên robot này): xe **kỳ vọng** ở đâu khi robot đứng ở điểm dò.
| Khoá | Đơn vị | Ý nghĩa |
|---|---|---|
| `has_prior` | bool | Bật prior. |
| `prior_x`, `prior_y` | m | Tâm xe kỳ vọng trong `base_link`. Lùi vào: `prior_x` âm. |
| `prior_x`, `prior_y` | m | Tâm xe kỳ vọng trong frame thân robot. Lùi vào: `prior_x` âm. |
| `prior_yaw` | rad | Hướng pháp tuyến cạnh vào **trỏ về robot**. Tiến vào ≈ 3.14159, lùi vào ≈ 0. |
| `prior_yaw_tolerance` | rad | Dung sai quanh `prior_yaw`. < π/2 thì còn dùng để chọn cạnh vào. π = không dùng yaw. |
| `search_radius` | m | Tâm xe xa prior hơn ngần này thì loại. |
| `search_fov` | rad | Nửa góc quạt quanh trục x của `prior_frame`. 0 = không giới hạn. |
| `search_fov` | rad | Nửa góc quạt quanh trục x của `robot_base_frame`. 0 = không giới hạn. |
**Cách đo prior**: lái robot tới đúng điểm dò trên server, để `has_prior: false`, `debug/detect: true`,
dò một lần. Log cho hai dòng:
@@ -309,12 +309,12 @@ thoả thì phải đặt điểm dò chính xác hơn.
## 8. Khoá theo cảm biến và bộ lọc
Các khoá này nằm ngay dưới action, áp cho mọi profile.
Các khoá này nằm ngay dưới action, áp cho mọi profile. `prior_frame` là khóa cũ: nếu bằng
`robot_base_frame` thì handler cảnh báo để xóa khóa; nếu khác frame thì cấu hình thất bại.
| Khoá | Đơn vị | Mặc định code | Gợi ý chui gầm | Dùng khi |
|---|---|---|---|---|
| `scan_topic` | — | — | `/f_scan` | Topic `LaserScan` có trong sensor store của nav core; sai tên thì boot báo lỗi kèm danh sách topic. |
| `prior_frame` | — | `base_link` | `base_link` | Frame của `prior_*` và `search_fov`. |
| `min_range` | m | 0.10 | 0.10 | Bỏ tia trúng chính thân robot. |
| `max_range` | m | 3.0 | 3.0 | Tia xa hơn bị bỏ. Phải ≥ khoảng cách lidar → chân xa ở điểm dò xa nhất. Tăng không làm dò xa hơn (mục 2), chỉ thêm vật nhiễu. |
| `range_sigma` | m | 0.01 | đo | σ nhiễu range, làm trọng số khớp và mẫu số của điểm tin. 0.01 là số của S300 sim: lidar thật thường 0.015–0.03, **phải đo** (bên dưới). Đặt thấp hơn nhiễu thật thì điểm tin tụt dù xe đúng. |
@@ -394,7 +394,7 @@ quả khi tăng/giảm.
Sau khi sửa YAML, khởi động lại nav rồi dò một lần. Log của handler:
```text
[trolley_detection] 'detect_trolley': 1 profile(s), default 'tci_trolley', scan '/f_scan', entry_direction forward, prior_frame 'base_link', range [0.10, 3.00] m, sigma 0.010 m, zero range = blocked, debug/detect on.
[trolley_detection] 'detect_trolley': 1 profile(s), default 'tci_trolley', scan '/f_scan', entry_direction forward, robot_base_frame 'base_link', range [0.10, 3.00] m, sigma 0.010 m, zero range = blocked, debug/detect on.
[trolley_detection][debug] 'detect_trolley': detecting profile 'tci_trolley' (cart 0.517 x 0.720 m, leg box 0.030 m, min_legs 3, attached legs off, tape off/all, bloom 0.000 rad, range bias sigma 0.000 m, offset_yaw 0.000, prior off in 'base_link') on '/f_scan', entry forward -> 'dock_target'.
[trolley_detection][debug] 'detect_trolley': scan frame 'front_laser_link' in 'base_link': (0.454, 0.000) yaw 0.000 rad, tilt 0.000 rad, mounted upside down: bearings mirrored.
[trolley_detection][debug] 'detect_trolley': cart at (1.218, 0.010) yaw -3.091 in 'front_laser_link' (upright view), legs seen 4 (partial 0, attached 0, occluded 0, out of view 0), measured 0.516 x 0.731 m, fit rms 0.0078 m, confidence 1.00.