fix(leg_pattern): rescue a real taped leg's edge-ramp bright run from the bloom-spread gate
This commit is contained in:
@@ -406,6 +406,7 @@ void LegPatternMatcher::buildCandidates(double dtheta)
|
||||
rejected_points_ = 0;
|
||||
rejected_tape_ = 0;
|
||||
rejected_bloom_spread_ = 0;
|
||||
rescued_tape_plateau_ = 0;
|
||||
width_miss_ = std::numeric_limits<double>::infinity();
|
||||
truncated_ = false;
|
||||
tape_run_.clear();
|
||||
@@ -426,14 +427,53 @@ void LegPatternMatcher::buildCandidates(double dtheta)
|
||||
// Cổng này cần ngưỡng nằm trên lõi: KIT ở 8000 có độ trải lõi thật tối đa 0.041 m (5501 lõi),
|
||||
// còn ở 4000 lõi thật đã tới 0.068 m; vì vậy cấu hình KIT cần 8000. Độ trải lớn hơn thường là
|
||||
// lõi bị bloom của gương gần hơn làm méo, không phải một chân thật.
|
||||
const std::vector<std::size_t>* core = &bright_run;
|
||||
if (max_range - min_range > profile_.maxApparentLegWidth())
|
||||
{
|
||||
for (std::size_t idx : bright_run)
|
||||
std::size_t best_start = 0, best_size = 0, start = 0, size = 0;
|
||||
if (profile_.tape_plateau_min_fraction > 0.0)
|
||||
{
|
||||
rays_[idx].tape_filtered = true;
|
||||
const double limit = min_range + profile_.maxApparentLegWidth() / 2.0;
|
||||
for (std::size_t i = 0; i < bright_run.size(); ++i)
|
||||
{
|
||||
if (rays_[bright_run[i]].range <= limit)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
start = i;
|
||||
}
|
||||
++size;
|
||||
if (size > best_size)
|
||||
{
|
||||
best_start = start;
|
||||
best_size = size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (profile_.tape_plateau_min_fraction > 0.0 &&
|
||||
best_size >= std::max(profile_.tape_min_points, profile_.min_leg_points) &&
|
||||
static_cast<double>(best_size) >=
|
||||
profile_.tape_plateau_min_fraction * static_cast<double>(bright_run.size()))
|
||||
{
|
||||
tape_plateau_.assign(bright_run.begin() + best_start,
|
||||
bright_run.begin() + best_start + best_size);
|
||||
core = &tape_plateau_;
|
||||
++rescued_tape_plateau_;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t idx : bright_run)
|
||||
{
|
||||
rays_[idx].tape_filtered = true;
|
||||
}
|
||||
++rejected_bloom_spread_;
|
||||
return;
|
||||
}
|
||||
++rejected_bloom_spread_;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bright_run.size() < std::max(profile_.tape_min_points, profile_.min_leg_points))
|
||||
@@ -443,6 +483,7 @@ void LegPatternMatcher::buildCandidates(double dtheta)
|
||||
|
||||
left_skirt_.clear();
|
||||
right_skirt_.clear();
|
||||
// Tia dốc vẫn sáng: phải bắt đầu ngoài run, không coi chúng là mép dính của plateau.
|
||||
const int left = walkTapeBloom(bright_run.front(), -1, left_skirt_);
|
||||
const int right = walkTapeBloom(bright_run.back(), +1, right_skirt_);
|
||||
for (std::size_t idx : bright_run)
|
||||
@@ -457,7 +498,7 @@ void LegPatternMatcher::buildCandidates(double dtheta)
|
||||
{
|
||||
rays_[idx].tape_filtered = true;
|
||||
}
|
||||
processPoints(bright_run, left, right, dtheta);
|
||||
processPoints(*core, left, right, dtheta);
|
||||
};
|
||||
|
||||
for (std::size_t i = 0; i < rays_.size(); ++i)
|
||||
@@ -554,6 +595,10 @@ 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)
|
||||
{
|
||||
text += ", " + std::to_string(rescued_tape_plateau_) + " bright core(s) kept by their plateau";
|
||||
}
|
||||
if (rejected_width_ > 0 && std::isfinite(width_miss_))
|
||||
{
|
||||
text += format(" (closest width miss %.3f m; leg_width %.3f m)", width_miss_,
|
||||
|
||||
@@ -200,6 +200,18 @@ bool LegProfile::validate(std::string& error) const
|
||||
error = "tape_range_bias_sigma must be finite and in [0, 0.2] [m]";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(tape_plateau_min_fraction) || tape_plateau_min_fraction < 0.0 ||
|
||||
tape_plateau_min_fraction >= 1.0)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user