fix(leg_profile): ignore tuned tape keys when tape_enabled is false instead of rejecting the profile

This commit is contained in:
2026-10-30 14:21:38 +07:00
parent a6c09f2386
commit bce0d5570e
6 changed files with 127 additions and 12 deletions

View File

@@ -595,7 +595,8 @@ std::string LegPatternMatcher::describeClusterRejections() const
format("%.3f", profile_.maxApparentLegWidth()) +
" m in range (bloom from a nearer mirror)";
}
if (profile_.tape_plateau_min_fraction > 0.0)
if (profile_.tape_enabled && profile_.tape_bloom_max_angle > 0.0 &&
profile_.tape_plateau_min_fraction > 0.0)
{
text += ", " + std::to_string(rescued_tape_plateau_) + " bright core(s) kept by their plateau";
}

View File

@@ -9,6 +9,8 @@
#include <dock_pattern_detector/leg_profile.h>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <string>
namespace dock_pattern_detector
@@ -206,7 +208,7 @@ bool LegProfile::validate(std::string& error) const
error = "tape_range_bias_all_max_std must be finite and in [0, 0.1] [m]";
return false;
}
if (tape_range_bias_all_max_std > 0.0 && (!tape_enabled || tape_range_bias_sigma <= 0.0))
if (tape_enabled && tape_range_bias_all_max_std > 0.0 && tape_range_bias_sigma <= 0.0)
{
error = "non-zero tape_range_bias_all_max_std requires tape_enabled: true and "
"tape_range_bias_sigma > 0";
@@ -218,17 +220,12 @@ bool LegProfile::validate(std::string& error) const
error = "tape_plateau_min_fraction must be finite and in [0, 1)";
return false;
}
if (tape_plateau_min_fraction > 0.0 && (!tape_enabled || tape_bloom_max_angle <= 0.0))
if (tape_enabled && tape_plateau_min_fraction > 0.0 && tape_bloom_max_angle <= 0.0)
{
error = "non-zero tape_plateau_min_fraction requires tape_enabled: true and "
"tape_bloom_max_angle > 0";
return false;
}
if (!tape_enabled && (tape_bloom_max_angle > 0.0 || tape_range_bias_sigma > 0.0))
{
error = "non-zero tape_bloom_max_angle or tape_range_bias_sigma requires tape_enabled: true";
return false;
}
if (std::fabs(cart_opening - cart_depth) < 2.0 * cart_dim_tolerance)
{
// Xe gần vuông: hình học không biết cạnh nào là cạnh vào. Dò ra cạnh bên là robot chui ngang
@@ -275,4 +272,29 @@ bool LegProfile::validate(std::string& error) const
return true;
}
std::string LegProfile::ignoredTapeKeys() const
{
if (tape_enabled)
{
return "";
}
std::ostringstream out;
out << std::fixed << std::setprecision(3);
const auto append = [&out](const char* name, double value) {
if (value != 0.0)
{
if (out.tellp() > 0)
{
out << ", ";
}
out << name << " " << value;
}
};
append("tape_bloom_max_angle", tape_bloom_max_angle);
append("tape_range_bias_sigma", tape_range_bias_sigma);
append("tape_plateau_min_fraction", tape_plateau_min_fraction);
append("tape_range_bias_all_max_std", tape_range_bias_all_max_std);
return out.str();
}
} // namespace dock_pattern_detector