00001 #include "pcl/point_cloud.h"
00002 #include <boost/program_options.hpp>
00003 #include "pcl/io/pcd_io.h"
00004
00005 namespace po = boost::program_options;
00006 using namespace std;
00007
00008 void parseLogFile(std::string filename, pcl::PointCloud<pcl::PointXYZ> &pcloud) {
00009 FILE *fin = fopen (filename.c_str(), "r");
00010 if(fin == NULL) return;
00011 char *line = NULL;
00012 size_t len;
00013 getline(&line,&len,fin);
00014
00015 free(line);
00016 double t,in;
00017 int ids,idp;
00018 pcl::PointXYZ pt;
00019
00020 pcloud.points.clear();
00021 while(fscanf(fin,"%lf,%f,%f,%f,%lf,%d,%d",&t,&pt.x,&pt.y,&pt.z,&in,&ids,&idp) > 0) {
00022 pcloud.points.push_back(pt);
00023 }
00024 pcloud.width=1;
00025 pcloud.height=pcloud.points.size();
00026
00027
00028 fclose(fin);
00029 }
00030
00031 int main(int argc, char **argv) {
00032 std::string base_name, point_type;
00033 double resolution;
00034 int n_scans;
00035 bool doFuser;
00036
00037 po::options_description desc("Allowed options");
00038 desc.add_options()
00039 ("help", "produce help message")
00040 ("base-name", po::value<string>(&base_name), "pre-string of the files to be loaded, relative to current working directory")
00041 ("number", po::value<int>(&n_scans)->default_value(1), "number of scans to process")
00042 ("fuser", po::value<bool>(&doFuser)->default_value(false), "run ndt fuser instead")
00043 ("resolution", po::value<double>(&resolution)->default_value(1.), "resolution of the map for ndt fuser")
00044 ;
00045
00046 po::variables_map vm;
00047 po::store(po::parse_command_line(argc, argv, desc), vm);
00048 po::notify(vm);
00049
00050 if (!vm.count("base-name") || !vm.count("number"))
00051 {
00052 cout << "Missing arguments.\n";
00053 cout << desc << "\n";
00054 return 1;
00055 }
00056 if (vm.count("help"))
00057 {
00058 cout << desc << "\n";
00059 return 1;
00060 }
00061
00062 pcl::PointCloud<pcl::PointXYZ> cloud;
00063
00064 for(int i=0; i<n_scans; ++i) {
00065 char buf[1000];
00066 snprintf(buf,999,"%s%d.csv",base_name.c_str(),i);
00067 std::cerr<<"parsing file "<<buf<<std::endl;
00068 parseLogFile(buf,cloud);
00069 snprintf(buf,999,"%s%d.pcd",base_name.c_str(),i);
00070 pcl::io::savePCDFileBinary (buf, cloud);
00071
00072 }
00073 }
00074