The handler held one concrete VPatternMatcher, so a profile declaring pattern: arc could not reach the arc matcher at all. It now picks by pattern at start(), reads the arc_* keys from YAML, and calls whichever matcher the profile named. An explicit switch, not a virtual interface: the set of patterns is a closed enum, each matcher weighs one DockProfile, and adding a shape is one member and two branches - cheaper than an abstraction layer over two implementations. Each matcher refuses a profile that is not its own, so a branch missing from that switch shows up at BOOT with the pattern named, not at runtime as "it never detects". Intensities go only to the V matcher. findTape walks the ray span of a fitted line segment and an arc produces none, so an arc profile that sets tape_enabled is already refused when the config loads. sim/models/dock_cradle_arc is a concave cradle, radius 0.40 m over 2.0 rad, for testing this in Gazebo. Its origin sits ON the deepest point, unlike dock_plate_v whose origin is 0.2121 m off the apex and has caused confusion: the detector reports the deepest point, so here that is the same number you spawn at, with nothing to subtract. It is 24 flat facets rather than a mesh, because Gazebo classic has no arc primitive and a mesh means a binary file in the repo. The approximation error is the sagitta of one chord, 0.35 mm - an order below the 3 mm range noise, so the circle fit cannot tell it from a real curve. Two tests pin the routing rather than the matching rules, which have their own tests in dock_pattern_detector: a cradle under an arc profile writes the goal frame at the deepest point, and a V plate under the same arc profile is rejected. Without the second one, a change that broke arc detection outright would look exactly like the gate doing its job.
131 lines
4.6 KiB
YAML
131 lines
4.6 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
|
|
|
|
# Cùng hình với v_std, khác đúng một chuyện: bắt buộc thấy dải phản quang.
|
|
v_tape:
|
|
pattern: v
|
|
vertex_angle: 1.5708 # [rad]
|
|
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, giống v_std
|
|
tape_enabled: true
|
|
tape_spacing: 0.2121 # [m] hai dải ở giữa hai cánh 0.30 m của tấm mở 90 độ
|
|
tape_width: 0.12 # [m]
|
|
tape_spacing_tolerance: 0.04
|
|
tape_width_tolerance: 0.05
|
|
tape_min_intensity: 500.0
|
|
|
|
# Máng cong lõm — biên dạng thứ hai, đi qua ArcPatternMatcher chứ không phải VPatternMatcher.
|
|
cradle:
|
|
pattern: arc
|
|
arc_radius: 0.40 # [m]
|
|
arc_radius_tolerance: 0.06 # [m]
|
|
arc_span: 2.2 # [rad] góc mở toàn phần của máng
|
|
arc_min_span: 0.52 # [rad] sàn để tin phép khớp
|
|
arc_max_rms: 0.010 # [m] cổng chính chống nhầm góc tường thành cung
|
|
min_arc_points: 8
|
|
min_confidence: 0.3
|
|
offset_x: 0.60 # [m] lùi ra trước mặt máng
|
|
|
|
# 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
|