From 775c16820b3213a1cc1f6dc0e805c7bf19edfa55 Mon Sep 17 00:00:00 2001 From: duongtd Date: Fri, 30 Oct 2026 14:21:38 +0700 Subject: [PATCH] feat: warn at boot about tape keys ignored while the tape is off --- README.md | 5 +++++ doc/MEASURE_AND_CONFIGURE.md | 3 +++ plugins/trolley_detection_action_handler.cpp | 7 +++++++ test/config/action_handlers_params.yaml | 12 ++++++++++++ test/trolley_detection_action_test.cpp | 9 +++++++++ 5 files changed, 36 insertions(+) diff --git a/README.md b/README.md index 819a7fa..eae0d71 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,11 @@ Khoá handler và profile: xem khối `detect_trolley` trong số, đo xe thật): `Test/docs/trolley_detection_action/TROLLEY_LEG_DETECTION_PLAN.md` của workspace phát triển. +Khi `tape_enabled: false`, `tape_bloom_max_angle`, `tape_range_bias_sigma`, +`tape_plateau_min_fraction` và `tape_range_bias_all_max_std` bị bỏ qua; cảnh báo lúc boot liệt kê +các giá trị khác 0 để có thể giữ giá trị đã chỉnh khi tháo dải. Miền giá trị vẫn được kiểm tra; +`tape_legs: entry` vẫn bị từ chối khi tape tắt vì nó xác định cạnh vào. + ## Sim - **Chạy thử chui gầm: dùng model đơn giản của gói** (`sim/models`, sinh bằng diff --git a/doc/MEASURE_AND_CONFIGURE.md b/doc/MEASURE_AND_CONFIGURE.md index 66e1f48..9731527 100644 --- a/doc/MEASURE_AND_CONFIGURE.md +++ b/doc/MEASURE_AND_CONFIGURE.md @@ -242,6 +242,9 @@ khớp. Dải phản quang trên chân cho xe một "chữ ký". - Phủ ít nhất `h_sensor ± 5 cm` theo chiều đứng (robot chúi 1° làm mặt quét lệch ~2.6 cm ở 1.5 m). - `tape_min_points` [tia], mặc định 1: số tia sáng tối thiểu để một chân được coi là có dải. - `tape_legs: entry` mà `tape_enabled: false` thì handler từ chối nạp. +- Khi `tape_enabled: false`, bốn khoá `tape_bloom_max_angle`, `tape_range_bias_sigma`, + `tape_plateau_min_fraction`, `tape_range_bias_all_max_std` bị bỏ qua; cảnh báo lúc boot liệt kê + giá trị khác 0, nên có thể giữ giá trị đã chỉnh khi tháo dải. Miền giá trị vẫn được kiểm tra. **Bộ lọc bloom và range bias** (tuỳ chọn): diff --git a/plugins/trolley_detection_action_handler.cpp b/plugins/trolley_detection_action_handler.cpp index efac17c..569d527 100644 --- a/plugins/trolley_detection_action_handler.cpp +++ b/plugins/trolley_detection_action_handler.cpp @@ -513,6 +513,13 @@ private: return false; } + const std::string ignored_tape_keys = profile.ignoredTapeKeys(); + if (!ignored_tape_keys.empty()) + { + robot::log_warning("[trolley_detection] '%s': profile '%s': tape off, ignoring %s.", + name_.c_str(), profile_name.c_str(), ignored_tape_keys.c_str()); + } + profiles_[profile_name] = profile; } diff --git a/test/config/action_handlers_params.yaml b/test/config/action_handlers_params.yaml index bcaeabf..8f8db33 100644 --- a/test/config/action_handlers_params.yaml +++ b/test/config/action_handlers_params.yaml @@ -40,6 +40,18 @@ actions_trolley: # [m] σ tối đa cho bias khi mọi góc đều sáng; 0 tắt. Tăng nhận xa hơn nhưng dễ sai pose; # giảm bỏ nhiều trường hợp. Ngưỡng lớn nguy hiểm do bias lẫn với tịnh tiến; miền 0–0.1. tape_range_bias_all_max_std: 0.0 + # Khi tape_enabled: false, bốn khoá tape dưới đây bị bỏ qua và được liệt kê lúc boot; + # có thể giữ giá trị đã chỉnh khi tháo dải. Miền giá trị vẫn được kiểm tra. + tci_trolley_tape_off: + cart_opening: 0.517 + cart_depth: 0.720 + leg_shape: box + leg_width: 0.030 + tape_enabled: false + tape_bloom_max_angle: 0.10 + tape_range_bias_sigma: 0.05 + tape_plateau_min_fraction: 0.65 + tape_range_bias_all_max_std: 0.02 tci_trolley_plateau: cart_opening: 0.517 # [m] Khoảng cách chân cạnh vào của xe test. cart_depth: 0.720 # [m] Khoảng cách chân dọc xe test. diff --git a/test/trolley_detection_action_test.cpp b/test/trolley_detection_action_test.cpp index c5b24d1..c2bd9d9 100644 --- a/test/trolley_detection_action_test.cpp +++ b/test/trolley_detection_action_test.cpp @@ -508,6 +508,15 @@ TEST(TrolleyDetectionAction, RefusesAnUnknownProfile) EXPECT_FALSE(h->start(makeAction("DetectTrolley", "khong_co_profile_nay"), robot::Time(10.0))); } +TEST(TrolleyDetectionAction, LoadsYamlProfileWithTapeOffAndTunedKeys) +{ + Rig rig; + ASSERT_TRUE(rig.loaded); + ActionHandler* handler = rig.registry.find("DetectTrolley"); + ASSERT_NE(handler, nullptr); + EXPECT_TRUE(handler->start(makeAction("DetectTrolley", "tci_trolley_tape_off"), robot::Time(10.0))); +} + TEST(TrolleyDetectionAction, LoadsPlateauFromYamlAndRejectsInvalidValue) { Rig rig;