Compare commits
2 Commits
95c7df9055
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b5f61111bc | |||
| 3c7b126f1e |
@@ -152,7 +152,10 @@ endif()
|
||||
# ========================================================
|
||||
# Tests
|
||||
# ========================================================
|
||||
if(CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
# Tests are OFF by default in both build modes; enable with -DBUILD_DOCK_PATTERN_DETECTOR_TESTS=ON.
|
||||
option(BUILD_DOCK_PATTERN_DETECTOR_TESTS "Build the dock_pattern_detector unit tests" OFF)
|
||||
|
||||
if(BUILD_DOCK_PATTERN_DETECTOR_TESTS AND CATKIN_ENABLE_TESTING AND BUILDING_WITH_CATKIN)
|
||||
|
||||
if(NOT COMMAND catkin_add_gtest)
|
||||
message(FATAL_ERROR "catkin_add_gtest NOT FOUND")
|
||||
|
||||
@@ -284,8 +284,10 @@ Cổng này không phân biệt được một vật sáng nằm trong giới h
|
||||
các mặt cần phân biệt. `wall_max_gap` phải bao phủ dải cộng cả hai skirt bloom tại tầm xa nhất. Kiểm kích thước,
|
||||
prior và quạt; hai cặp hợp lệ trở lên trả `ambiguous`, vượt giới hạn xử lý trả `capacity_*`.
|
||||
|
||||
`tape_core_intensity`, mask bloom và `edge_bias_bound` phải hiệu chuẩn theo cảm biến, vật liệu, góc và
|
||||
cự ly. Thấy core ổn định không chứng minh đó là mép vật lý, nhất là khi saturation/bloom. Cận mép
|
||||
`tape_min_intensity` là ngưỡng dải; `tape_core_intensity` tùy chọn, mặc định bằng ngưỡng này,
|
||||
và `tape_plateau_min_fraction` tùy chọn, mặc định 1.0. Chỉ cần khai hai khóa riêng khi lidar có
|
||||
bloom nằm giữa hai ngưỡng. Ngưỡng, mask bloom và `edge_bias_bound` phải hiệu chuẩn theo cảm biến,
|
||||
vật liệu, góc và cự ly. Thấy core ổn định không chứng minh đó là mép vật lý, nhất là khi saturation/bloom. Cận mép
|
||||
trả về chỉ gồm lượng tử góc và bound hiệu chuẩn, chưa bao gồm sai số fit tường, TF hay localization.
|
||||
Không có ground truth tường thật hoặc chứng nhận độ chính xác trong package. Cách dựng và cổng kiểm
|
||||
được mô tả trong [kế hoạch P1](../../../../Test/docs/wall_reflector_detection_action/WALL_REFLECTOR_DETECTION_PLAN.md)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace dock_pattern_detector
|
||||
/**
|
||||
* @brief Cấu hình hình học và các cổng kiểm của cặp dải trên một tường phẳng.
|
||||
*
|
||||
* Giá trị mặc định NaN là bắt buộc đo và khai; không phải cấu hình dùng được trên robot.
|
||||
* Giá trị NaN mặc định là bắt buộc đo và khai, trừ hai khóa core và plateau tùy chọn bên dưới.
|
||||
* Dung sai lớn giúp chịu nhiễu nhưng có thể nhận nhầm một vật khác. `validate()` kiểm mọi khóa
|
||||
* và ràng buộc chéo trước khi matcher nhận profile.
|
||||
*/
|
||||
@@ -32,7 +32,8 @@ struct ReflectorPairProfile
|
||||
/// [đơn vị driver] Ngưỡng tạo run sáng. Tăng giảm bloom nhưng có thể mất tia tape.
|
||||
double tape_min_intensity = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
/// [đơn vị driver] Ngưỡng core trong run. Tăng thu hẹp core, có thể bỏ mất dải ở xa.
|
||||
/// [đơn vị driver] Ngưỡng core tùy chọn; NaN dùng tape_min_intensity. Chỉ cần ngưỡng riêng
|
||||
/// khi lidar có bloom nằm giữa hai ngưỡng; tăng ngưỡng core có thể bỏ mất dải ở xa.
|
||||
double tape_core_intensity = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
/// [tia] Số tia core tối thiểu mỗi dải. Tăng chống nhiễu nhưng thu hẹp tầm hoặc góc phát hiện.
|
||||
@@ -41,7 +42,8 @@ struct ReflectorPairProfile
|
||||
/// [rad] Vùng mask mỗi phía run để tránh bloom vào fit tường. Tăng loại nhiều support hơn.
|
||||
double tape_bloom_max_angle = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
/// [-] Tỉ lệ tối thiểu core/run. Tăng loại run loang nhiều hơn nhưng có thể bỏ dải thật.
|
||||
/// [-] Tỉ lệ tối thiểu core/run tùy chọn; NaN dùng 1.0. Chỉ cần đặt riêng khi lidar có bloom
|
||||
/// nằm giữa tape_min_intensity và tape_core_intensity; tăng có thể bỏ dải thật.
|
||||
double tape_plateau_min_fraction = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
/// [m] Cận bias mép đã hiệu chuẩn; tăng làm uncertainty bảo thủ hơn, không tự sửa mép.
|
||||
|
||||
@@ -27,6 +27,10 @@ bool ReflectorPairMatcher::configure(const ReflectorPairProfile& profile, std::s
|
||||
return false;
|
||||
}
|
||||
profile_ = profile;
|
||||
if (std::isnan(profile_.tape_core_intensity))
|
||||
profile_.tape_core_intensity = profile_.tape_min_intensity;
|
||||
if (std::isnan(profile_.tape_plateau_min_fraction))
|
||||
profile_.tape_plateau_min_fraction = 1.0;
|
||||
configured_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ bool ReflectorPairProfile::validate(std::string& error) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!check("tape_core_intensity", tape_core_intensity, tape_core_intensity >= tape_min_intensity,
|
||||
if (!std::isnan(tape_core_intensity) &&
|
||||
!check("tape_core_intensity", tape_core_intensity, tape_core_intensity >= tape_min_intensity,
|
||||
"finite and >= tape_min_intensity [driver units]"))
|
||||
{
|
||||
return false;
|
||||
@@ -71,7 +72,8 @@ bool ReflectorPairProfile::validate(std::string& error) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!check("tape_plateau_min_fraction", tape_plateau_min_fraction,
|
||||
if (!std::isnan(tape_plateau_min_fraction) &&
|
||||
!check("tape_plateau_min_fraction", tape_plateau_min_fraction,
|
||||
tape_plateau_min_fraction > 0.0 && tape_plateau_min_fraction <= 1.0,
|
||||
"finite and in (0, 1]"))
|
||||
{
|
||||
|
||||
@@ -185,9 +185,8 @@ TEST(ReflectorPairProfile, RequiredFieldsRejectUnsetNonfiniteAndOutOfRange)
|
||||
const std::vector<std::pair<const char*, double ReflectorPairProfile::*>> fields = {
|
||||
{"tape_width", &ReflectorPairProfile::tape_width}, {"width_tolerance", &ReflectorPairProfile::width_tolerance},
|
||||
{"tape_spacing", &ReflectorPairProfile::tape_spacing}, {"spacing_tolerance", &ReflectorPairProfile::spacing_tolerance},
|
||||
{"tape_min_intensity", &ReflectorPairProfile::tape_min_intensity}, {"tape_core_intensity", &ReflectorPairProfile::tape_core_intensity},
|
||||
{"tape_min_intensity", &ReflectorPairProfile::tape_min_intensity},
|
||||
{"tape_bloom_max_angle", &ReflectorPairProfile::tape_bloom_max_angle},
|
||||
{"tape_plateau_min_fraction", &ReflectorPairProfile::tape_plateau_min_fraction},
|
||||
{"edge_bias_bound", &ReflectorPairProfile::edge_bias_bound}, {"max_edge_uncertainty", &ReflectorPairProfile::max_edge_uncertainty},
|
||||
{"wall_min_span", &ReflectorPairProfile::wall_min_span}, {"wall_max_rms", &ReflectorPairProfile::wall_max_rms},
|
||||
{"wall_max_residual", &ReflectorPairProfile::wall_max_residual}, {"wall_max_gap", &ReflectorPairProfile::wall_max_gap},
|
||||
@@ -209,6 +208,99 @@ TEST(ReflectorPairProfile, RequiredFieldsRejectUnsetNonfiniteAndOutOfRange)
|
||||
EXPECT_NE(error.find("tape_width"), std::string::npos);
|
||||
}
|
||||
|
||||
TEST(ReflectorPairProfile, OptionalThresholdsAcceptNanAndRejectInvalidValues)
|
||||
{
|
||||
const double nan = std::numeric_limits<double>::quiet_NaN();
|
||||
const double inf = std::numeric_limits<double>::infinity();
|
||||
std::string error;
|
||||
auto test_profile = profile();
|
||||
test_profile.tape_core_intensity = nan;
|
||||
test_profile.tape_plateau_min_fraction = nan;
|
||||
EXPECT_TRUE(test_profile.validate(error)) << error;
|
||||
|
||||
for (double bad : {inf, -inf, test_profile.tape_min_intensity - 1.0})
|
||||
{
|
||||
test_profile = profile();
|
||||
test_profile.tape_core_intensity = bad;
|
||||
EXPECT_FALSE(test_profile.validate(error));
|
||||
EXPECT_NE(error.find("tape_core_intensity"), std::string::npos) << error;
|
||||
}
|
||||
for (double bad : {inf, -inf, -0.1, 0.0, 1.01})
|
||||
{
|
||||
test_profile = profile();
|
||||
test_profile.tape_plateau_min_fraction = bad;
|
||||
EXPECT_FALSE(test_profile.validate(error));
|
||||
EXPECT_NE(error.find("tape_plateau_min_fraction"), std::string::npos) << error;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ReflectorPairProfile, UnsetCoreMatchesExplicitMinimum)
|
||||
{
|
||||
auto explicit_profile = profile();
|
||||
explicit_profile.tape_core_intensity = explicit_profile.tape_min_intensity;
|
||||
auto default_profile = explicit_profile;
|
||||
default_profile.tape_core_intensity = std::numeric_limits<double>::quiet_NaN();
|
||||
ReflectorPairMatcher matcher;
|
||||
std::string error;
|
||||
ASSERT_TRUE(matcher.configure(default_profile, error)) << error;
|
||||
EXPECT_EQ(matcher.profile().tape_core_intensity, explicit_profile.tape_min_intensity);
|
||||
|
||||
const wall_scan_sim::World world;
|
||||
const auto geometry = wall_scan_sim::geometry(kFrontStep);
|
||||
const auto expected = detect(explicit_profile, world, geometry);
|
||||
const auto actual = detect(default_profile, world, geometry);
|
||||
ASSERT_TRUE(expected.valid) << expected.reason;
|
||||
ASSERT_TRUE(actual.valid) << actual.reason;
|
||||
EXPECT_EQ(actual.marker.x, expected.marker.x);
|
||||
EXPECT_EQ(actual.marker.y, expected.marker.y);
|
||||
EXPECT_EQ(actual.marker.yaw, expected.marker.yaw);
|
||||
EXPECT_EQ(actual.target.x, expected.target.x);
|
||||
EXPECT_EQ(actual.target.y, expected.target.y);
|
||||
EXPECT_EQ(actual.target.yaw, expected.target.yaw);
|
||||
EXPECT_EQ(actual.widths, expected.widths);
|
||||
EXPECT_EQ(actual.spacing, expected.spacing);
|
||||
EXPECT_EQ(actual.wall_rms, expected.wall_rms);
|
||||
EXPECT_EQ(actual.wall_max_residual, expected.wall_max_residual);
|
||||
EXPECT_EQ(actual.wall_support, expected.wall_support);
|
||||
EXPECT_EQ(actual.edge_uncertainty, expected.edge_uncertainty);
|
||||
EXPECT_EQ(actual.candidate_count, expected.candidate_count);
|
||||
EXPECT_EQ(actual.valid_pairs, expected.valid_pairs);
|
||||
EXPECT_EQ(actual.tested_pairs, expected.tested_pairs);
|
||||
EXPECT_EQ(actual.rejected_runs, expected.rejected_runs);
|
||||
EXPECT_EQ(actual.reason, expected.reason);
|
||||
}
|
||||
|
||||
TEST(ReflectorPairProfile, UnsetPlateauUsesOneAndRejectsBloomOutsideCore)
|
||||
{
|
||||
wall_scan_sim::World world;
|
||||
world.x = 1.2;
|
||||
world.bloom_left = 1;
|
||||
world.bloom_right = 2;
|
||||
auto explicit_profile = profile();
|
||||
explicit_profile.tape_bloom_max_angle = 2 * kFrontStep;
|
||||
explicit_profile.tape_plateau_min_fraction = 1.0;
|
||||
auto default_profile = explicit_profile;
|
||||
default_profile.tape_plateau_min_fraction = std::numeric_limits<double>::quiet_NaN();
|
||||
ReflectorPairMatcher matcher;
|
||||
std::string error;
|
||||
ASSERT_TRUE(matcher.configure(default_profile, error)) << error;
|
||||
EXPECT_EQ(matcher.profile().tape_plateau_min_fraction, 1.0);
|
||||
|
||||
const auto geometry = wall_scan_sim::geometry(kFrontStep);
|
||||
const auto expected = detect(explicit_profile, world, geometry);
|
||||
const auto actual = detect(default_profile, world, geometry);
|
||||
EXPECT_FALSE(expected.valid);
|
||||
EXPECT_FALSE(actual.valid);
|
||||
EXPECT_EQ(actual.reason, expected.reason);
|
||||
EXPECT_EQ(actual.candidate_count, expected.candidate_count);
|
||||
EXPECT_EQ(actual.rejected_runs, expected.rejected_runs);
|
||||
EXPECT_GT(actual.rejected_runs, 0u);
|
||||
|
||||
explicit_profile.tape_plateau_min_fraction = 0.45;
|
||||
const auto relaxed = detect(explicit_profile, world, geometry);
|
||||
EXPECT_TRUE(relaxed.valid) << relaxed.reason;
|
||||
}
|
||||
|
||||
TEST(ReflectorPairProfile, ValidationErrorIncludesValueAndRange)
|
||||
{
|
||||
auto test_profile = profile();
|
||||
|
||||
Reference in New Issue
Block a user