00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <pcl/io/pcd_io.h>
00043 #include <pcl/point_types.h>
00044 #include <tf/tf.h>
00045 #include <pcl_ros/transforms.h>
00046
00047 typedef pcl::PointXYZ PointT;
00048
00049 int
00050 main (int argc, char** argv)
00051 {
00052
00053 pcl::PCDReader reader;
00054
00055 pcl::PCDWriter writer;
00056
00057
00058 pcl::PointCloud<PointT>::Ptr input_cloud (new pcl::PointCloud<PointT> ());
00059 pcl::PointCloud<PointT>::Ptr output_cloud (new pcl::PointCloud<PointT> ());
00060
00061
00062 reader.read (std::string(argv[1]), *input_cloud);
00063 ROS_INFO ("PointCloud has: %zu data points.", input_cloud->points.size ());
00064
00065 std::vector<btTransform> poses_first (100);
00066 std::vector<btTransform> poses_last (100);
00067 btTransform bt1,bt2,bt1_inverse,bt2_inverse,bt_relative;
00068 Eigen::Matrix4f transform_matrix;
00069 poses_first[0]=btTransform(btQuaternion(0.998846824056,0.0321420649378,-0.0347925244179,-0.00783517578594) ,btVector3(0.794980231638,2.61825838228,0.793744988276));
00070 poses_last[0]=btTransform(btQuaternion(0.998752133384,0.0207771171007,-0.0400542187211,-0.0214043693847) ,btVector3(0.196217134071,2.58788842192,0.802082517919));
00071 poses_first[11]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.854595096684,2.1117762422,0.83581194444));
00072 poses_last[11]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.304168821189,2.0881359323,0.835223245908));
00073 poses_first[12]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.87515422062,2.1264438802,0.688548777959));
00074 poses_last[12]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.226732063269,2.0704584748,0.677043344612));
00075 poses_first[20]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.794980231638,1.7,0.783785592596));
00076 poses_last[20]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.196217134071,1.67243435547,0.794664770984));
00077 poses_first[30]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.708097227301,1.12431635089,0.783785592596));
00078 poses_last[30]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.15762123548,1.09807397523,0.783569963996));
00079 poses_first[31]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.707196010134,1.15281266082,0.64182772675));
00080 poses_last[31]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.108505198317,1.11737966783,0.631973685219));
00081 poses_first[32]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.720480791782,1.14081120967,0.349637179347));
00082 poses_last[32]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.169155951244,1.09290312037,0.352896361082));
00083 poses_first[40]=btTransform(btQuaternion(0.69988310609,0.0125240341376,0.0516863610901,0.712274740852) ,btVector3(0.759088815798,0.447555838799,0.788543972139));
00084 poses_last[40]=btTransform(btQuaternion(0.679154223135,-0.182616350164,0.209965139294,0.679202068704) ,btVector3(0.328294951431,0.455333579402,0.536777352992));
00085 poses_first[50]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.811475455459,-0.159275054725,0.64285697828));
00086 poses_last[50]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.262167086028,-0.189935857791,0.635715051788));
00087 poses_first[60]=btTransform(btQuaternion(-0.0231417985797,-0.004722980116,0.0150256782545,0.999608113017) ,btVector3(0.970785923351,-0.51177511333,0.987374139302));
00088 poses_last[60]=btTransform(btQuaternion(-0.0757567991896,-0.0338534608379,0.714338624073,0.694863425951) ,btVector3(0.481417937933,-1.13998831455,0.975107082045));
00089 poses_first[61]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.985176471098,-0.75775319426,0.467585908667));
00090 poses_last[61]=btTransform(btQuaternion(1,0,0,0) ,btVector3(0.486508365334,-0.797871464651,0.460385745908));
00091 bt1=poses_first[std::atoi(argv[1])];
00092 bt2=poses_last[std::atoi(argv[1])];
00093 bt1_inverse=bt1.inverse();
00094 bt2_inverse=bt2.inverse();
00095 bt_relative=bt1_inverse * bt2;
00096 bt_relative=bt1 * bt2_inverse;
00097 ROS_INFO("The transform bt1 is %f, %f, %f ",bt1.getOrigin().x(),bt1.getOrigin().y(),bt1.getOrigin().z());
00098 ROS_INFO("The transform bt2 is%f, %f, %f ",bt2.getOrigin().x(),bt2.getOrigin().y(),bt2.getOrigin().z());
00099 ROS_INFO("The transform is %f, %f, %f ",bt_relative.getOrigin().x(),bt_relative.getOrigin().y(),bt_relative.getOrigin().z());
00100 ROS_INFO("The orientation is %f, %f, %f, %f",bt_relative.getRotation().x(),bt_relative.getRotation().y(),bt_relative.getRotation().z(),bt_relative.getRotation().w());
00101
00102 pcl_ros::transformAsMatrix (bt_relative, transform_matrix);
00103 pcl::transformPointCloud(*input_cloud, *output_cloud,transform_matrix);
00104
00105 std::string s="data/transformed_" + std::string(argv[1]);
00106 ROS_INFO("String is: %s ",s.c_str());
00107 ROS_INFO ("PointCloud representing the planar component: %zu data points.", output_cloud->points.size ());
00108 writer.write (s.c_str(), *output_cloud, false);
00109 return (0);
00110 }
00111