test_pointcloud2.cpp
Go to the documentation of this file.
00001 /*
00002  * test_pose_conversions.cpp
00003  *
00004  *  Created on: Mar 15, 2012
00005  *      Author: Pablo IƱigo Blasco
00006  */
00007 
00008 #include <mrpt/slam/CSimplePointsMap.h>
00009 #include <mrpt/slam/CColouredPointsMap.h>
00010 #include <mrpt_bridge/point_cloud2.h>
00011 #include <pcl/ros/conversions.h>
00012 #include <pcl/point_cloud.h>
00013 #include <pcl_conversions/pcl_conversions.h>
00014 #include <gtest/gtest.h>
00015 
00016 TEST(PointCloud2, basicTest)
00017 {
00018   pcl::PointCloud<pcl::PointXYZ> point_cloud;
00019 
00020   point_cloud.height = 10;
00021   point_cloud.width = 10;
00022   point_cloud.is_dense = true;
00023 
00024   int num_points = point_cloud.height * point_cloud.width;
00025   point_cloud.points.resize(num_points);
00026 
00027   float i_f = 0;
00028   for (int i = 0; i < num_points; i++)
00029   {
00030     pcl::PointXYZ & point = point_cloud.points[i];
00031     point.x = i_f;
00032     point.y = -i_f;
00033     point.z = -2 * i_f;
00034     i_f += 1.0;
00035   }
00036 
00037   sensor_msgs::PointCloud2 point_cloud2_msg;
00038   //pcl_conversions::fromPCL(point_cloud, point_cloud2_msg);
00039   pcl::toROSMsg(point_cloud, point_cloud2_msg);
00040 
00041   mrpt::slam::CSimplePointsMap mrpt_pc;
00042   //printf("step 3\n");
00043   mrpt_bridge::copy(point_cloud2_msg, mrpt_pc);
00044 
00045   i_f = 0;
00046   for (int i = 0; i < num_points; i++)
00047   {
00048     float mrpt_x, mrpt_y, mrpt_z;
00049     mrpt_pc.getPoint(i, mrpt_x, mrpt_y, mrpt_z);
00050     EXPECT_FLOAT_EQ(mrpt_x, i_f);
00051     EXPECT_FLOAT_EQ(mrpt_y, -i_f);
00052     EXPECT_FLOAT_EQ(mrpt_z, -2*i_f);
00053 
00054     i_f += 1.0;
00055   }
00056   //;
00057 }


mrpt_bridge
Author(s):
autogenerated on Mon Aug 11 2014 11:23:21