feat(reflector_pair): make tape_core_intensity and tape_plateau_min_fraction optional
An unset core threshold defaults to tape_min_intensity and an unset plateau fraction to 1.0, resolved once in ReflectorPairMatcher::configure(). Every deployed profile already set the two thresholds equal (no bloom on the robot lidar), so operators now configure one threshold. Profiles that set both keys match exactly as before.
This commit is contained in:
@@ -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