fix: two segments adjacent by ray number can still be metres apart

Grouping segments into an arc candidate keyed only on ray index, and that is
not the same question as whether they lie on one surface: the next ray along
can land on something several metres away.

Found in Gazebo, not in a synthesized scene. The four segments of a cradle sat
two rays away from a 6.6 m wall behind it, so the wall was absorbed into the
group; the circle fitted over all of it came out at radius 3.2 m with a 0.11 m
residual, and the real cradle was rejected because of something that was not
part of it. The regression test reproduces the same signature - radius 1.38 m,
residual 0.20 m - and passes once the gap is checked.

arc_max_point_gap is the euclidean distance between the two facing endpoints,
and it belongs at or below the extractor's max_line_gap. Set it higher and the
matcher rejoins exactly what the extractor just separated, which it separated
for a reason.
This commit is contained in:
2026-08-26 20:39:37 +07:00
parent a45694f625
commit 791c838da8
5 changed files with 56 additions and 2 deletions

View File

@@ -225,6 +225,34 @@ TEST(ArcPatternMatcher, APartlyOccludedArcStillGivesTheSameDeepestPoint)
EXPECT_NEAR(half.apex_y, full.apex_y, 0.03);
}
TEST(ArcPatternMatcher, AWallJustPastTheArcIsNotAbsorbedIntoIt)
{
// Hồi quy cho một lỗi CHỈ SIM MỚI LỘ. Ban đầu phép gom chỉ xét khoảng cách theo SỐ TIA, và trong
// world Gazebo bức tường ngay sau máng chỉ cách 2 tia — lọt ngưỡng. Bốn đoạn của máng bị gom
// cùng bức tường 6.6 m, khớp tròn trên cả cụm cho bán kính 3.2 m và sai số 0.11 m, nên cái máng
// thật bị loại vì một thứ không thuộc về nó.
//
// Liền nhau theo số tia KHÔNG có nghĩa là liền nhau trong không gian: tia kế tiếp có thể rơi
// xuống một mặt cách đó vài mét.
Rig rig;
ASSERT_TRUE(rig.ok_) << rig.error_;
// Máng ở 2 m; mép của nó nằm quanh bearing +-0.17 rad.
std::vector<Segment> world = concaveCradle(1.60, 0.40, 2.0);
// Tường ở 4 m, bắt đầu ngay sát mép máng theo GÓC nhưng cách xa theo KHÔNG GIAN.
const double a0 = 0.18;
const double a1 = 0.95;
world.push_back({ 4.0 * std::cos(a0), 4.0 * std::sin(a0), 4.0 * std::cos(a1),
4.0 * std::sin(a1) });
const Detection d = rig.run(world);
ASSERT_TRUE(d.valid) << d.reason;
EXPECT_NEAR(d.apex_x, 2.00, 0.03);
EXPECT_NEAR(d.measured_arc_radius, 0.40, 0.03);
EXPECT_LT(d.measured_arc_rms, 0.010) << "sai so khop no ra = da nuot ca buc tuong";
}
// ================================================================================================
// 2. Từ chối — phần quan trọng nhất
// ================================================================================================