A docking global planner has no way to learn which marker the leg is for: BaseGlobalPlanner::initialize() takes only the plugin name and the costmap, and the plugin builds its own NodeHandle to read parameters. The only channel left is the parameter tree, so copy the marker's keys into the planner's namespace before the instance is built - the same shape as Costmap2DROBOT::copyParentParameters() pouring parameters into each layer. PlannerPort::bindDockingMarker() is called at the request gate, right before swapPlanner(), because swapPlanner is where the instance is built and reads its parameters. Copying afterwards would be a no-op: initialize() runs once. - The destination is whatever global_planner the profile names, so a marker bound to a planner other than DockPlanner writes into that planner's namespace. Only DockPlanner reads footprint_dock today; the config documents that the value is inert elsewhere. - The namespace is verified after construction. robot::NodeHandle silently falls back to its parent when a namespace does not resolve, so a mistyped marker would otherwise read footprint from ROOT - the robot footprint - and use it as the dock's size. - The cached instance is rebuilt when the marker changes, and swapPlanner no longer short-circuits on an unchanged planner name, otherwise the second dock would run with the first dock's geometry. Rebuilds are skipped when the same marker is bound again. - The replaced instance is retired rather than destroyed: the planner thread captures the active pointer and releases the mutex before calling into the plugin, so destroying it from the control thread is a use-after-free. Add eight PlannerRunner tests. The test plugin now exports its initialize() count and the footprint it read, which is the only way to observe from outside that the rebuild actually happened. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
107 lines
7.1 KiB
YAML
107 lines
7.1 KiB
YAML
# =================================================================================================
|
|
# action_core / mission_adapters — compound action: "phải dò rồi mới biết đích".
|
|
#
|
|
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = sửa thế nào cho đúng.
|
|
#
|
|
# Đây là bảng mở rộng của `VDA5050SourceAdapter`: một action của fleet được DỊCH thành một chuỗi
|
|
# chặng (nav + action) trước khi xuống navigation. Fleet chỉ gửi `charge`; `DetectCharger` và
|
|
# `startCharging` là actionType NỘI BỘ do adapter sinh ra, không bao giờ xuất hiện trong order JSON.
|
|
#
|
|
# File riêng thay vì sửa `mission_adapters_params.yaml`: file đó là symlink sang cây config của
|
|
# `pnkx_nav_core` (submodule). `robot::NodeHandle` gộp mọi file YAML trong thư mục config vào một
|
|
# cây, nên khoá `vda5050_src` ở đây hợp nhất với khoá cùng tên bên kia.
|
|
#
|
|
# ── Bảng này chỉ giữ CẤU TRÚC ────────────────────────────────────────────────────────────────────
|
|
#
|
|
# Tên frame cụ thể đến từ `actionParameters` của chính order, nên thêm một trạm sạc mới KHÔNG phải
|
|
# sửa file này.
|
|
#
|
|
# Bốn từ khoá của một step, phải có ĐÚNG MỘT:
|
|
# action: <type> chặng chỉ-action; mang nguyên actionParameters của action gốc
|
|
# move_to: <frame> chặng nav, frame cố định
|
|
# move_to_param: <key> chặng nav, frame lấy từ actionParameters[<key>] của action gốc
|
|
# move: <mét> chặng nav tương đối; dương = tiến, âm = lùi
|
|
#
|
|
# Tuỳ chọn cho step navigation: profile (position | docking | go_straight | rotate), marker.
|
|
# `marker` chỉ hợp lệ với `profile: docking`: nó chọn override trong
|
|
# maker_sources.yaml/docking_marker_profiles. Không khai = dùng cặp docking mặc định.
|
|
# Tolerance thuộc YAML riêng của local planner đang được profile chọn, không khai ở đây.
|
|
#
|
|
# ── Ba quy tắc khi sửa ───────────────────────────────────────────────────────────────────────────
|
|
# 1. Mỗi `action: X` thêm mới PHẢI có handler nhận `X` trong `action_handlers_params.yaml`
|
|
# (`action_types`), nếu không chặng đó ABORT.
|
|
# 2. `clear_queue_on_failure: true` (mission_adapters_params.yaml) là thứ ngăn robot chạy bước
|
|
# thiết bị khi bước dò/bước tiến vào đã hỏng — đừng tắt khi còn dùng compound action.
|
|
# 3. Thứ tự step là hợp đồng an toàn: dò -> vào vị trí -> mới thao tác thiết bị. Đảo thứ tự nghĩa
|
|
# là đóng relay / nâng càng khi chưa vào đúng chỗ.
|
|
# =================================================================================================
|
|
|
|
vda5050_src:
|
|
compound_actions:
|
|
# --- charge: vào trạm sạc ---------------------------------------------------------------------
|
|
charge:
|
|
steps:
|
|
# 1. Dò: đứng yên lấy mẫu frame thô, lọc nhiễu, ghi ra `dock_target`.
|
|
# Robot không phát cmd_vel trong EXECUTING_ACTIONS nên đây đúng là lúc để lọc.
|
|
# Tham số lọc (sample_window, max_spread_*) nằm ở khối `detect` bên action_handlers.
|
|
- {action: DetectCharger}
|
|
|
|
# 2. Tiến vào đích vừa dò được bằng profile docking. Sai số do local planner đọc từ YAML
|
|
# của chính plugin đó (hybrid_local_planner_params.yaml), KHÔNG khai ở đây.
|
|
- {move_to: dock_target, profile: docking, marker: charger}
|
|
|
|
# 3. Thao tác thiết bị. Chặng 1 hoặc 2 hỏng thì `clear_queue_on_failure` xoá chặng này —
|
|
# robot không bao giờ đóng relay khi chưa vào được vị trí.
|
|
- {action: startCharging}
|
|
|
|
# --- PickUp: lấy kệ ---------------------------------------------------------------------------
|
|
PickUp:
|
|
steps:
|
|
- {action: DetectPallet}
|
|
- {move_to: dock_target, profile: docking, marker: pallet}
|
|
- {action: LiftFork}
|
|
# Lùi ra khỏi khe kệ. Quãng đường tương đối được quy ra pose tuyệt đối tại `submit`, từ pose
|
|
# LÚC ĐÓ — lúc adapter sinh chặng thì robot còn chưa tới nơi.
|
|
# ► Chỉnh: [m] âm = lùi. Đặt đủ dài để càng nâng ra hẳn khỏi khe kệ trước khi robot xoay;
|
|
# quá ngắn thì kệ quệt vào giá, quá dài thì tốn thời gian và có thể lùi vào lối đi chung.
|
|
- {move: -0.5, profile: go_straight}
|
|
|
|
dockTo:
|
|
steps:
|
|
- {action: DetectPallet}
|
|
- {move_to: dock_target, profile: docking, marker: trolley}
|
|
- {action: LiftFork}
|
|
# Lùi ra khỏi khe kệ. Quãng đường tương đối được quy ra pose tuyệt đối tại `submit`, từ pose
|
|
# LÚC ĐÓ — lúc adapter sinh chặng thì robot còn chưa tới nơi.
|
|
# ► Chỉnh: [m] âm = lùi. Đặt đủ dài để càng nâng ra hẳn khỏi khe kệ trước khi robot xoay;
|
|
# quá ngắn thì kệ quệt vào giá, quá dài thì tốn thời gian và có thể lùi vào lối đi chung.
|
|
- {move: -0.5, profile: go_straight}
|
|
|
|
# --- UnDockFromStation: lùi ra khỏi trạm --------------------------------------------------------
|
|
# Trước đây action này chạy phía host bằng `moveStraightTo`, một entry point đã bị gỡ vì nó đẩy
|
|
# goal thẳng vào lõi và cướp được chặng mà mission layer đang chạy. Ở đây nó là một chặng bình
|
|
# thường: cùng mission id, cùng lifecycle, cùng đường cancel.
|
|
#
|
|
# ⚠ Khác biệt so với bản host cũ: quãng lùi giờ là HẰNG SỐ CỦA CẤU HÌNH, không còn lấy từ
|
|
# `actionParameters.distance` của từng order — step `move:` chỉ nhận số, không có biến thể đọc
|
|
# param. Trạm nào cần quãng lùi khác thì phải khai một compound action riêng.
|
|
UnDockFromStation:
|
|
steps:
|
|
# ► Chỉnh: [m] âm = lùi. Đủ dài để robot ra hẳn khỏi trạm trước khi được phép xoay. Profile
|
|
# `go_straight` KHÔNG tránh vật cản — chỉ đúng khi phía sau trạm là vùng đã biết là trống.
|
|
- {move: -1.0, profile: go_straight}
|
|
|
|
# --- GoStraight / Rotate: hai lệnh chuyển động trần, dùng để kiểm thử và cho quy trình đơn giản
|
|
GoStraight:
|
|
steps:
|
|
# ► Chỉnh: [m] dương = tiến, âm = lùi. Profile `go_straight` không tránh vật cản dọc đường —
|
|
# chỉ dùng cho quãng ngắn đã biết là trống.
|
|
- {move: 1.0, profile: go_straight}
|
|
|
|
Rotate:
|
|
steps:
|
|
# ► Chỉnh: `move: 0.0` = không tịnh tiến; góc quay lấy từ actionParameters của order.
|
|
# Profile `rotate` dùng PNKXRotateLocalPlanner, tham số ở YAML của plugin đó.
|
|
- {move: 0.0, profile: rotate}
|
|
|