Files
dock_pattern_action/test/config/action_handlers_params.yaml
duongtd 8269e20576 Run the dock detector as an action, from raw scan to goal frame
This is the layer that turns the geometry into something the robot actually
runs. It pulls a raw scan from the shared store, extracts lines, matches the
dock pattern, transforms into the global frame and writes the result as a
static transform - the same output contract FrameSampler has, so the charge
sequence keeps working and nothing in move_base2, dock_planner or
mission_adapters changes. Swapping detectors is one word in the YAML.

It is also the only place in the chain allowed to know about TF, actions and
the sensor store. The three packages beneath it stay free of all that, which
is what lets their tests build a world, cast rays and finish in a millisecond
with no runtime around them.

Three things only break once the pieces are joined, and no core test can see
them:

The scan cursor. A 30 Hz control loop reading a 29 Hz lidar ticks more often
than scans arrive. Without the cursor the same scan counts as several samples,
min_samples stops meaning anything, and the handler commits on one measurement.

TF arriving after the scan. The two come from different sources, so TF running
a few milliseconds behind is routine. The store's cursor has already moved past
that scan, so dropping the sample loses a detection outright every time TF is
late. The detection is now held and transformed on a later tick, without
re-running the match - the shape was already found, only the transform was
missing. The regression test fails without that, which is how it earned its
place.

Transforming at the scan's own stamp rather than at the latest. The pose just
computed belongs to the moment the scan was taken; looking up at another moment
mixes two instants into one measurement. The error from "latest" is small but
nobody knows how small, and a stamp on the wrong clock shows up exactly here.

Rejections happen at boot, not at detection time: no sensor store, a scan_topic
the store does not carry (listing the ones it does - a mistyped topic looks
exactly like a dead sensor), no profiles, a pattern that is not implemented,
a default_profile that does not exist. Every profile is validated, not just the
default one, because a typo in the fifth profile that only surfaces at four in
the afternoon is the worst kind.

An order asking for a profile that does not exist fails and says which ones do.
It does not quietly fall back to the default: using the wrong geometry means
docking in the wrong place, not being slightly slower.

The timeout message says which gate failed. Nothing matched, matched too
rarely, or matched but never settled need opposite responses, and one failure
line cannot carry that.
2026-08-26 13:03:22 +07:00

101 lines
3.3 KiB
YAML

# =================================================================================================
# Cây config của test — KHÔNG phải bản chạy thật. Mỗi khối là một ca kiểm riêng.
# =================================================================================================
# Ca thường: một profile chữ V, bộ lọc nhẹ để test không phải bơm hàng chục scan.
actions_dock:
handlers:
- {name: detect, type: DockPatternActionHandler}
detect:
action_types: [DetectCharger]
output_frame: dock_target
scan_topic: /f_scan
settle_delay: 0.0 # [s] test tự điều khiển đồng hồ
timeout: 5.0 # [s]
default_profile: v_std
profile_param_key: dock_profile
sample_window: 1.0 # [s]
min_samples: 3
max_spread_xy: 0.05 # [m]
max_spread_yaw: 0.10 # [rad]
line_extraction:
min_split_dist: 0.02 # [m]
max_line_gap: 0.08 # [m]
min_line_length: 0.05 # [m]
min_line_points: 5
profiles:
v_std:
pattern: v
vertex_angle: 1.5708 # [rad] tấm mở 90 độ
wing_length: 0.30 # [m]
angle_tolerance: 0.20 # [rad]
length_tolerance: 0.06 # [m]
vertex_gap: 0.05 # [m]
min_wing_points: 5
min_confidence: 0.3
offset_x: 0.60 # [m] lùi ra trước mặt sạc
v_wide:
pattern: v
vertex_angle: 2.0944 # [rad] 120 độ
wing_length: 0.25 # [m]
angle_tolerance: 0.20
length_tolerance: 0.06
vertex_gap: 0.05
min_wing_points: 5
min_confidence: 0.3
offset_x: 0.50
# scan_topic không có trong kho -> phải từ chối LÚC BOOT kèm danh sách topic có thật.
actions_dock_bad_topic:
handlers:
- {name: detect, type: DockPatternActionHandler}
detect:
action_types: [DetectCharger]
output_frame: dock_target
scan_topic: /front_scan
default_profile: v_std
profiles:
v_std: {pattern: v, vertex_angle: 1.5708, wing_length: 0.30, vertex_gap: 0.05}
# Không khai profile nào -> không có gì để dò.
actions_dock_no_profile:
handlers:
- {name: detect, type: DockPatternActionHandler}
detect:
action_types: [DetectCharger]
output_frame: dock_target
scan_topic: /f_scan
# pattern chưa hiện thực -> nói thẳng, đừng nhận rồi không bao giờ dò ra gì.
actions_dock_unimplemented:
handlers:
- {name: detect, type: DockPatternActionHandler}
detect:
action_types: [DetectCharger]
output_frame: dock_target
scan_topic: /f_scan
default_profile: pillar
profiles:
pillar: {pattern: cylinder, vertex_angle: 1.5708, wing_length: 0.30, vertex_gap: 0.05}
# default_profile trỏ vào profile không tồn tại.
actions_dock_bad_default:
handlers:
- {name: detect, type: DockPatternActionHandler}
detect:
action_types: [DetectCharger]
output_frame: dock_target
scan_topic: /f_scan
default_profile: khong_co
profiles:
v_std: {pattern: v, vertex_angle: 1.5708, wing_length: 0.30, vertex_gap: 0.05}
# Bảng symbol -> thư viện cho Boost.DLL.
DockPatternActionHandler:
library_path: libdock_pattern_action_handler