feat(leg_pattern): add LegPatternMatcher for 4-leg trolleys

Finds a 4-leg trolley in a raw LaserScan without line extraction:
shadow filter, leg clusters in ray order with free/occluded/attached edges,
pair hypotheses from cart_opening/cart_depth/diagonal, then a Gauss-Newton
pose fit over every leg point with an along-ray residual, Huber weights and
backtracking. Gates: pair spacing after the fit, see-through leg positions,
optional empty interior, entry side (entry tape / prior yaw / facing the
sensor), optional prior, confidence, and ambiguity between two carts.

LegProfile validates every key at load. Two gtests (7 + 23) run on a
synthetic ray-cast scan (test/leg_scan_sim.h). Used by trolley_detection_action.
This commit is contained in:
2026-10-28 13:43:56 +07:00
parent edc6b30431
commit c568e90c53
11 changed files with 3324 additions and 0 deletions

View File

@@ -65,6 +65,10 @@ add_library(dock_pattern_detector SHARED
src/arc_pattern_matcher.cpp
src/circle_fit.cpp
src/v_pattern_matcher.cpp
# Dò xe hàng 4 chân: đọc scan thô, không qua đoạn thẳng. Dùng bởi trolley_detection_action.
src/leg_profile.cpp
src/leg_pose_fit.cpp
src/leg_pattern_matcher.cpp
)
target_compile_options(dock_pattern_detector PRIVATE -Wall -Wextra)
@@ -230,4 +234,34 @@ if(CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
)
endif()
# Hai test của bộ dò xe hàng dùng chung bộ dựng scan tổng hợp `test/leg_scan_sim.h`.
foreach(leg_test leg_pose_fit_test leg_pattern_matcher_test)
catkin_add_gtest(${leg_test} test/${leg_test}.cpp)
if(TARGET ${leg_test})
# catkin_add_gtest đặt target EXCLUDE_FROM_ALL; mở ra để binary có mặt sau `catkin_make`
# thường, đúng quy trình verify của repo.
set_target_properties(${leg_test} PROPERTIES EXCLUDE_FROM_ALL FALSE)
target_compile_options(${leg_test} PRIVATE -Wall -Wextra)
target_include_directories(${leg_test}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/test
)
target_include_directories(${leg_test} SYSTEM
PRIVATE
${EIGEN3_INCLUDE_DIRS}
)
# catkin_add_gtest dùng target_link_libraries dạng plain, nên phần bổ sung cũng phải plain.
target_link_libraries(${leg_test}
dock_pattern_detector
pthread
)
endif()
endforeach()
endif()