30 #include <pcl/point_types.h> 35 #include <gtest/gtest.h> 37 TEST(PointCloudUniformSampler, Sampling)
39 pcl::PointCloud<pcl::PointXYZ>::Ptr pc_input(
new pcl::PointCloud<pcl::PointXYZ>);
42 pc_input->header.frame_id =
"frame0";
43 pc_input->header.stamp = 12345;
45 const float points_ref[][3] =
51 for (
const auto& p_ref : points_ref)
53 pc_input->push_back(pcl::PointXYZ(p_ref[0], p_ref[1], p_ref[2]));
58 for (
size_t num = 1; num < 4; num++)
60 pcl::PointCloud<pcl::PointXYZ>::Ptr pc_output = sampler.
sample(pc_input, num);
63 ASSERT_EQ(pc_output->header.frame_id, pc_input->header.frame_id);
64 ASSERT_EQ(pc_output->header.stamp, pc_input->header.stamp);
65 ASSERT_EQ(pc_output->height, 1u);
66 ASSERT_EQ(pc_output->width, num);
69 for (
const pcl::PointXYZ& p : *pc_output)
72 for (
const auto& p_ref : points_ref)
74 if (p_ref[0] == p.x && p_ref[1] == p.y && p_ref[2] == p.z)
80 ASSERT_TRUE(found) <<
"A sampled point is not in the original points array";
85 pcl::PointCloud<pcl::PointXYZ>::Ptr pc_output0 = sampler.
sample(pc_input, 0);
86 ASSERT_EQ(pc_output0->points.size(), 0u);
89 int main(
int argc,
char** argv)
91 testing::InitGoogleTest(&argc, argv);
93 return RUN_ALL_TESTS();
TEST(PointCloudUniformSampler, Sampling)
int main(int argc, char **argv)