feat: add entry_direction and derive an upside-down lidar from TF

The charger goal heading always pointed out of the station, so only robots
that reverse onto the charger were supported. Front-charging robots now set
`entry_direction: forward` (goal yaw + pi, position unchanged) together with
a front `scan_topic`. The default stays `backward`, so existing configs keep
their behaviour.

Once per run the handler looks up base_link <- scan frame and:
- fails the action if the scan plane is tilted more than 5 deg;
- fails the action if the lidar faces the side opposite to entry_direction,
  instead of writing a reversed goal;
- mirrors the bearings when the lidar is mounted upside down (roll pi),
  as the trolley handler does. No config key is needed for that.

Tests: forward vs backward, direction mismatch, upside-down V / taped V /
arc, tilted scan plane, invalid entry_direction.
This commit is contained in:
2026-11-10 15:06:00 +07:00
parent 5bbcf37f1d
commit c125bd069c
5 changed files with 287 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ actions:
detect_lidar: # tên action, tuỳ cây config
action_types: [DetectCharger]
scan_topic: /b_scan
entry_direction: backward
...
default_profile: v_std
profiles:
@@ -29,6 +30,18 @@ actions:
- Handler đọc và **kiểm mọi profile lúc boot**. Sửa YAML xong phải khởi động lại nav, nếu không nav
vẫn chạy với config cũ. Một profile sai miền giá trị làm handler từ chối nạp và log rõ khoá nào sai.
## Hướng vào trạm và TF LiDAR
`backward` (mặc định) chọn LiDAR sau: robot lùi vào, heading goal hướng ra khỏi trạm. `forward`
chọn LiDAR trước: robot tiến vào, heading hướng vào trạm. Khi đổi hướng, đổi `scan_topic` sang
LiDAR cùng phía. Handler kiểm TF từ frame scan tới `robot_base_frame`: sai phía hoặc mặt phẳng
nghiêng quá 5° thì action fail, không ghi goal. LiDAR lộn ngược được nhận tự động qua TF, không có
khoá flip. Kiểm TF và hướng LiDAR trên robot trước khi vận hành.
Các offset giữ hệ hình: x từ đỉnh ra phía robot, y sang trái hệ hình. Khi `forward`, robot quay
mặt vào trạm nên `offset_y` dương nằm bên phải robot. Tính khoảng hở `offset_x` theo footprint sau
khi `backward`, footprint trước khi `forward`.
## Thứ tự làm
1. Xác định dạng trạm: `pattern`, `v_shape`.
@@ -248,6 +261,7 @@ Các khoá này nằm ngay dưới action, áp cho mọi profile.
| Khoá | Đơn vị | Mặc định | Dùng khi |
|---|---|---|---|
| `scan_topic` | — | — | Topic `LaserScan` có trong sensor store của nav core. |
| `entry_direction` | — | backward | `backward` lùi vào; `forward` tiến vào, chọn LiDAR cùng phía. |
| `line_extraction/max_range` | m | 30.0 | **Giới hạn tầm tìm.** Tia xa hơn bị bỏ trước khi trích đoạn, nên vật ở xa không thành ứng viên. Đặt lớn hơn khoảng cách xa nhất mà robot bấm dò, cộng nửa chiều dài cánh. |
| `line_extraction/min_range` | m | 0.05 | Bỏ tia trúng chính thân xe. |
| `line_extraction/min_split_dist` | m | 0.04 | Đặt nhỏ hơn bề dày tấm thì hai mặt của một cánh bị tách thành hai đoạn. |