3 #include "gtest/gtest.h" 9 class PCLConversionTests :
public ::testing::Test {
11 virtual void SetUp() {
12 pcl_image.header.frame_id =
"pcl";
16 pcl_image.is_bigendian =
true;
17 pcl_image.encoding =
"bgr8";
18 pcl_image.data.resize(2);
19 pcl_image.data[0] = 0x42;
20 pcl_image.data[1] = 0x43;
22 pcl_pc2.header.frame_id =
"pcl";
25 pcl_pc2.point_step = 1;
27 pcl_pc2.is_bigendian =
true;
28 pcl_pc2.is_dense =
true;
29 pcl_pc2.fields.resize(2);
30 pcl_pc2.fields[0].name =
"XYZ";
31 pcl_pc2.fields[0].datatype = pcl::PCLPointField::INT8;
32 pcl_pc2.fields[0].count = 3;
33 pcl_pc2.fields[0].offset = 0;
34 pcl_pc2.fields[1].name =
"RGB";
35 pcl_pc2.fields[1].datatype = pcl::PCLPointField::INT8;
36 pcl_pc2.fields[1].count = 3;
37 pcl_pc2.fields[1].offset = 8 * 3;
38 pcl_pc2.data.resize(2);
39 pcl_pc2.data[0] = 0x42;
40 pcl_pc2.data[1] = 0x43;
43 pcl::PCLImage pcl_image;
44 sensor_msgs::Image image;
46 pcl::PCLPointCloud2 pcl_pc2;
47 sensor_msgs::PointCloud2 pc2;
51 void test_image(T &image) {
52 EXPECT_EQ(std::string(
"pcl"), image.header.frame_id);
53 EXPECT_EQ(1, image.height);
54 EXPECT_EQ(2, image.width);
55 EXPECT_EQ(1, image.step);
56 EXPECT_TRUE(image.is_bigendian);
57 EXPECT_EQ(std::string(
"bgr8"), image.encoding);
58 EXPECT_EQ(2, image.data.size());
59 EXPECT_EQ(0x42, image.data[0]);
60 EXPECT_EQ(0x43, image.data[1]);
63 TEST_F(PCLConversionTests, imageConversion) {
66 pcl::PCLImage pcl_image2;
68 test_image(pcl_image2);
73 EXPECT_EQ(std::string(
"pcl"), pc.header.frame_id);
74 EXPECT_EQ(1, pc.height);
75 EXPECT_EQ(2, pc.width);
76 EXPECT_EQ(1, pc.point_step);
77 EXPECT_EQ(1, pc.row_step);
78 EXPECT_TRUE(pc.is_bigendian);
79 EXPECT_TRUE(pc.is_dense);
80 EXPECT_EQ(
"XYZ", pc.fields[0].name);
81 EXPECT_EQ(pcl::PCLPointField::INT8, pc.fields[0].datatype);
82 EXPECT_EQ(3, pc.fields[0].count);
83 EXPECT_EQ(0, pc.fields[0].offset);
84 EXPECT_EQ(
"RGB", pc.fields[1].name);
85 EXPECT_EQ(pcl::PCLPointField::INT8, pc.fields[1].datatype);
86 EXPECT_EQ(3, pc.fields[1].count);
87 EXPECT_EQ(8 * 3, pc.fields[1].offset);
88 EXPECT_EQ(2, pc.data.size());
89 EXPECT_EQ(0x42, pc.data[0]);
90 EXPECT_EQ(0x43, pc.data[1]);
93 TEST_F(PCLConversionTests, pointcloud2Conversion) {
96 pcl::PCLPointCloud2 pcl_pc2_2;
112 pcl::uint64_t pcl_stamp;
118 TEST(PCLConversionStamp, Stamps)
146 int main(
int argc,
char **argv) {
148 ::testing::InitGoogleTest(&argc, argv);
149 return RUN_ALL_TESTS();
150 }
catch (std::exception &e) {
151 std::cerr <<
"Unhandled Exception: " << e.what() << std::endl;
int main(int argc, char **argv)
void fromPCL(const pcl::uint64_t &pcl_stamp, ros::Time &stamp)
TEST(PCLConversionStamp, Stamps)
StampTestData(const ros::Time &stamp)
void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)