Accept a V whose far wing is foreshortened by the viewing angle
A run in simulation matched the pattern 23 times in 15 seconds out of roughly 435 scans - about five percent - and every miss reported the right vertex angle with the wrong wing length. Measuring it: noise is not the cause (93 to 100 percent at the sensor's own 3 mm sigma) and neither is range (clean detections out to 5 m). Viewing angle is. Turn the plate and the far wing goes nearly edge-on to the beam, so few rays land on it and the extracted segment comes out short. Past thirty degrees the detection rate falls to zero. Requiring both wings at full length only works when the robot happens to face the plate squarely, which is not something the approach guarantees. Occlusion only ever shortens a wing; it cannot lengthen one. So the rule is no longer symmetric: no wing may be LONGER than wing_length + tolerance, and at least one must be within tolerance of it. A pallet corner still fails, because a pallet has both sides long - that gate is untouched, and the test that covers it still passes. Confidence scores the length of the long wing rather than the short one. The short wing is allowed to be short by the rule above, so penalising it again is charging twice for the same thing, and it created a cliff: candidates cleared the length gate only to fall at min_confidence. "Too little of it is visible to trust" is already carried by the support term, which counts the rays on the thinner wing and degrades smoothly. With min_wing_points at 5, thirty degrees at 2.5 m goes from 0 to 77 percent, forty degrees at 1.2 m from 0 to 80, fifty degrees from 0 to 82. The rejection message also carries the measured vertex angle, both wing lengths and the apex position now. Without them, "a wing 0.22 m because something is in the way" and "a wing 0.80 m because that is a pallet" print the same line.
This commit is contained in:
@@ -251,6 +251,51 @@ TEST(VPatternMatcher, AWiderPlateIsFoundWhenTheProfileSaysSo)
|
||||
// 2. Từ chối — phần quan trọng nhất
|
||||
// ================================================================================================
|
||||
|
||||
TEST(VPatternMatcher, AWingHiddenByAnObliqueViewIsStillAV)
|
||||
{
|
||||
DockProfile p = vProfile();
|
||||
p.min_wing_points = 5;
|
||||
|
||||
Rig rig(p);
|
||||
ASSERT_TRUE(rig.ok_) << rig.error_;
|
||||
|
||||
// Cánh xa bị nhìn nghiêng nên chỉ thấy 0.18 m thay vì 0.30 m. Che khuất chỉ làm NGẮN đi, không
|
||||
// bao giờ dài ra — nên đây vẫn là chữ V thật. Bắt cả hai cánh đủ 0.30 m nghĩa là chỉ dò được khi
|
||||
// robot đứng gần chính diện; đo được: nghiêng 40 độ là tỉ lệ trúng về 0.
|
||||
const double ax = 1.20;
|
||||
const std::vector<Segment> world = {
|
||||
{ ax, 0.0, ax - 0.2121, 0.2121 }, // cánh đủ
|
||||
{ ax, 0.0, ax - 0.1273, -0.1273 }, // cánh chỉ thấy 0.18 m
|
||||
};
|
||||
|
||||
const Detection d = rig.run(world);
|
||||
ASSERT_TRUE(d.valid) << d.reason;
|
||||
EXPECT_NEAR(d.apex_x, ax, 0.03);
|
||||
EXPECT_NEAR(std::max(d.measured_wing_length[0], d.measured_wing_length[1]), 0.30, 0.04);
|
||||
EXPECT_LT(std::min(d.measured_wing_length[0], d.measured_wing_length[1]), 0.24);
|
||||
}
|
||||
|
||||
TEST(VPatternMatcher, AWingLongerThanTheProfileIsStillRejected)
|
||||
{
|
||||
DockProfile p = vProfile();
|
||||
p.min_wing_points = 5;
|
||||
|
||||
Rig rig(p);
|
||||
ASSERT_TRUE(rig.ok_) << rig.error_;
|
||||
|
||||
// Luật bất đối xứng chỉ nới phía NGẮN. Một cạnh dài hơn `wing_length + tol` vẫn phải bị loại —
|
||||
// đó là thứ giữ nguyên tác dụng chặn góc pallet, và pallet có CẢ HAI cạnh dài.
|
||||
const double ax = 1.20;
|
||||
const std::vector<Segment> world = {
|
||||
{ ax, 0.0, ax - 0.2121, 0.2121 }, // cánh đủ 0.30 m
|
||||
{ ax, 0.0, ax - 0.4243, -0.4243 }, // cạnh 0.60 m — quá dài
|
||||
};
|
||||
|
||||
const Detection d = rig.run(world);
|
||||
EXPECT_FALSE(d.valid);
|
||||
EXPECT_NE(d.reason.find("wing length"), std::string::npos) << d.reason;
|
||||
}
|
||||
|
||||
TEST(VPatternMatcher, APalletCornerIsNotADock)
|
||||
{
|
||||
Rig rig;
|
||||
|
||||
Reference in New Issue
Block a user