voxel: chi giu o >= 3 node thay; obstacle_z_min 0.15

This commit is contained in:
trung09122002
2026-09-25 15:57:22 +07:00
parent 185814f0ec
commit ccd6d5954a
7 changed files with 210 additions and 36 deletions

View File

@@ -333,3 +333,52 @@ TEST(NodeCloud, KhongCoDepthThiRong) {
NodeCloudFromSensorData(data, Opt(0.05), &pts);
EXPECT_TRUE(pts.empty());
}
TEST(VoxelHitCounter, ChiGiuVoxelDuNodeThay) {
// Voxel (0,0,5) duoc 3 node thay -> giu. Voxel (10,0,5) chi node dau thay
// -- kieu mot diem bay -> bo.
VoxelExportOptions o = Opt(0.10);
o.min_node_hits = 3;
VoxelHitCounter h(o);
for (int n = 0; n < 3; ++n) {
h.BeginNode();
h.AddPoint(0.05, 0.05, 0.55);
if (n == 0) h.AddPoint(1.05, 0.05, 0.55);
h.EndNode();
}
VoxelGrid g;
h.Finish(&g);
ASSERT_EQ(g.cells.size(), 1u);
EXPECT_TRUE(Has(g.cells, 0, 0, 5));
}
TEST(VoxelHitCounter, MotNodeNhieuDiemVanChiTinhMotLan) {
// 10 diem cung mot voxel nhung chi tu MOT node -> van la 1 lan thay.
VoxelExportOptions o = Opt(0.10);
o.min_node_hits = 2;
VoxelHitCounter h(o);
h.BeginNode();
for (int i = 0; i < 10; ++i) h.AddPoint(0.05, 0.05, 0.55);
h.EndNode();
VoxelGrid g;
h.Finish(&g);
EXPECT_TRUE(g.cells.empty());
}
TEST(VoxelHitCounter, CatZVanDungNhuVoxelAccumulator) {
// Diem ngoai [z_min, z_max] bi bo ngay tu AddPoint, du duoc nhieu node thay.
VoxelExportOptions o = Opt(0.10); // z_min 0.05, z_max 2.00
o.min_node_hits = 2;
VoxelHitCounter h(o);
for (int n = 0; n < 2; ++n) {
h.BeginNode();
h.AddPoint(0.05, 0.05, 0.01); // duoi z_min
h.AddPoint(0.05, 0.05, 2.50); // tren z_max
h.AddPoint(0.05, 0.05, 1.05); // trong dai
h.EndNode();
}
VoxelGrid g;
h.Finish(&g);
ASSERT_EQ(g.cells.size(), 1u);
EXPECT_TRUE(Has(g.cells, 0, 0, 10));
}