From b00d320094bb4fbcc65e42521ccfb0a6d24046b2 Mon Sep 17 00:00:00 2001 From: duongtd Date: Fri, 30 Oct 2026 10:58:56 +0700 Subject: [PATCH] feat: read tape_range_bias_all_max_std and log the bias std --- README.md | 6 ++++++ plugins/trolley_detection_action_handler.cpp | 14 ++++++++------ test/config/action_handlers_params.yaml | 8 ++++++++ test/trolley_detection_action_test.cpp | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e968d4a..819a7fa 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,9 @@ catkin_make --pkg dock_pattern_detector trolley_detection_action ./devel/lib/dock_pattern_detector/leg_pattern_matcher_test ./devel/lib/trolley_detection_action/trolley_detection_action_test ``` + +`tape_range_bias_all_max_std` [m] mặc định 0 tắt fit bias khi không có chân trần. +Khi bật tape, `tape_legs: all` và sigma bias dương, fit chỉ được nhận nếu σ hậu nghiệm không vượt +ngưỡng; nếu vượt, handler nhận kết quả fit 3-DoF cũ. Tăng ngưỡng nhận ở xa hơn nhưng có thể bù +sai pose; giảm làm gate bảo thủ hơn. KIT dán cả 4 chân dùng 0.02 m (chọn từ replay 3 bag, xem +README `dock_pattern_detector`); chưa chạy trên robot. diff --git a/plugins/trolley_detection_action_handler.cpp b/plugins/trolley_detection_action_handler.cpp index bb71389..efac17c 100644 --- a/plugins/trolley_detection_action_handler.cpp +++ b/plugins/trolley_detection_action_handler.cpp @@ -335,13 +335,14 @@ public: const dock_pattern_detector::LegProfile& p = found->second; robot::log_info("[trolley_detection][debug] '%s': detecting profile '%s' (cart %.3f x %.3f m, " "leg %s %.3f m, min_legs %d, attached legs %s, tape %s/%s, bloom %.3f rad, " - "plateau %.3f, range bias sigma %.3f m, offset_yaw %.3f, prior %s in '%s') on '%s', entry " + "plateau %.3f, range bias sigma %.3f m, all max std %.3f m, offset_yaw %.3f, prior %s in '%s') on '%s', entry " "%s -> '%s'.", name_.c_str(), profile_name.c_str(), p.cart_opening, p.cart_depth, dock_pattern_detector::toString(p.leg_shape), p.leg_width, p.min_legs, p.accept_attached_legs ? "on" : "off", p.tape_enabled ? "on" : "off", dock_pattern_detector::toString(p.tape_legs), - p.tape_bloom_max_angle, p.tape_plateau_min_fraction, p.tape_range_bias_sigma, p.offset_yaw, + p.tape_bloom_max_angle, p.tape_plateau_min_fraction, p.tape_range_bias_sigma, + p.tape_range_bias_all_max_std, p.offset_yaw, p.has_prior ? "on" : "off", prior_frame_.c_str(), scan_topic_.c_str(), toString(entry_direction_), output_frame_.c_str()); } @@ -466,6 +467,7 @@ private: nh_param(p_nh, "tape_bloom_max_angle", profile.tape_bloom_max_angle); nh_param(p_nh, "tape_plateau_min_fraction", profile.tape_plateau_min_fraction); nh_param(p_nh, "tape_range_bias_sigma", profile.tape_range_bias_sigma); + nh_param(p_nh, "tape_range_bias_all_max_std", profile.tape_range_bias_all_max_std); nh_param(p_nh, "leg_cluster_gap", profile.leg_cluster_gap); nh_param(p_nh, "leg_min_depth_gap", profile.leg_min_depth_gap); nh_param(p_nh, "accept_attached_legs", profile.accept_attached_legs); @@ -797,22 +799,22 @@ private: { robot::log_info("[trolley_detection][debug] '%s': cart at (%.3f, %.3f) yaw %.3f in '%s'%s, " "legs seen %d (partial %d, attached %d, occluded %d, out of view %d), " - "measured %.3f x %.3f m, fit rms %.4f m, tape range bias %.3f m, confidence " + "measured %.3f x %.3f m, fit rms %.4f m, tape range bias %.3f m (std %.4f m; 0 = unavailable), confidence " "%.2f.", name_.c_str(), d.center_x, d.center_y, d.center_yaw, pending_frame_.c_str(), scan_flipped_ ? " (upright view)" : "", d.legs_seen, d.legs_partial, d.legs_attached, d.legs_occluded, d.legs_out_of_view, d.measured_opening, - d.measured_depth, d.fit_rms, d.tape_range_bias, d.confidence); + d.measured_depth, d.fit_rms, d.tape_range_bias, d.tape_range_bias_std, d.confidence); } else { robot::log_info("[trolley_detection][debug] '%s': cart at (%.3f, %.3f) yaw %.3f in '%s'%s, " "legs seen %d (partial %d, attached %d, occluded %d, out of view %d), " - "measured %.3f x %.3f m, fit rms %.4f m, confidence %.2f.", + "measured %.3f x %.3f m, fit rms %.4f m, bias off (std %.4f m; 0 = unavailable), confidence %.2f.", name_.c_str(), d.center_x, d.center_y, d.center_yaw, pending_frame_.c_str(), scan_flipped_ ? " (upright view)" : "", d.legs_seen, d.legs_partial, d.legs_attached, d.legs_occluded, d.legs_out_of_view, d.measured_opening, - d.measured_depth, d.fit_rms, d.confidence); + d.measured_depth, d.fit_rms, d.tape_range_bias_std, d.confidence); } } diff --git a/test/config/action_handlers_params.yaml b/test/config/action_handlers_params.yaml index 4385241..bcaeabf 100644 --- a/test/config/action_handlers_params.yaml +++ b/test/config/action_handlers_params.yaml @@ -37,6 +37,9 @@ actions_trolley: # Ngưỡng quá thấp nguy hiểm vì pose sai; phải nhỏ hơn 1. KIT dán băng gương dùng 0.65 để giữ # chân có dốc ở mép và loại lõi bị bloom; chỉ dùng sau khi kiểm chứng trên scan của lidar. tape_plateau_min_fraction: 0.0 + # [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 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. @@ -47,6 +50,11 @@ actions_trolley: # [-] Ngưỡng plateau: tăng loại nhiều lõi dốc hơn, giảm dễ nhận lõi méo gây sai pose; # 0 tắt, phải nhỏ hơn 1 và cần tape cùng bloom. KIT băng gương dùng 0.65 để cứu mép dốc. tape_plateau_min_fraction: 0.65 + # [m] σ tối đa cho bias mọi góc sáng; 0 tắt, cần tape và sigma > 0. + # Tăng nhận xa hơn nhưng dễ sai pose; giảm từ chối nhiều hơn; > 0.1 nguy hiểm và bị cấm. + # 0.02 chỉ để test, KIT cần replay xác nhận trước khi sử dụng. + tape_range_bias_sigma: 0.05 + tape_range_bias_all_max_std: 0.02 tci_trolley_prior: cart_opening: 0.517 cart_depth: 0.720 diff --git a/test/trolley_detection_action_test.cpp b/test/trolley_detection_action_test.cpp index 4b28c38..c5b24d1 100644 --- a/test/trolley_detection_action_test.cpp +++ b/test/trolley_detection_action_test.cpp @@ -529,6 +529,23 @@ TEST(TrolleyDetectionAction, LoadsPlateauFromYamlAndRejectsInvalidValue) rig.nh.setParam(key, 0.65); } +TEST(TrolleyDetectionAction, LoadsAllBrightBiasThresholdAndRejectsInvalidValue) +{ + Rig rig; + ASSERT_TRUE(rig.loaded); + const std::string key = "actions_trolley/detect_trolley/profiles/tci_trolley_plateau/" + "tape_range_bias_all_max_std"; + double value = 0.0; + ASSERT_TRUE(rig.nh.getParam(key, value)); + EXPECT_DOUBLE_EQ(value, 0.02); + rig.nh.setParam(key, 0.101); + ActionRegistry invalid; + invalid.setContext(rig.ctx); + EXPECT_FALSE(invalid.loadFromConfig(rig.nh, kNamespace)); + EXPECT_EQ(invalid.find("DetectTrolley"), nullptr); + rig.nh.setParam(key, 0.02); +} + TEST(TrolleyDetectionAction, RefusesToLoadWithoutASensorStore) { robot::NodeHandle nh;