Go to the documentation of this file.00001 #include <ndt_visualisation/ndt_viz.h>
00002 #include <boost/program_options.hpp>
00003 namespace po = boost::program_options;
00004
00005 using namespace mrpt;
00006 using namespace mrpt::gui;
00007 using namespace mrpt::opengl;
00008
00009 int main(int argc, char **argv){
00010
00011 std::string base_name, point_type;
00012 double resolution;
00013
00014 po::options_description desc("Allowed options");
00015 desc.add_options()
00016 ("help", "produce help message")
00017 ("file-name", po::value<string>(&base_name), "location of the ndt map you want to view")
00018 ("point-type", po::value<string>(&point_type), "type of the underlying index. supported types are XYZ (default), XYZI and XYZRGB")
00019 ("resolution", po::value<double>(&resolution)->default_value(1.), "resolution of the map (necessary due to bug in loading, should be fixed soon)")
00020 ;
00021
00022 po::variables_map vm;
00023 po::store(po::parse_command_line(argc, argv, desc), vm);
00024 po::notify(vm);
00025
00026 if (!vm.count("file-name") || !vm.count("resolution"))
00027 {
00028 cout << "Missing arguments.\n";
00029 cout << desc << "\n";
00030 return 1;
00031 }
00032 if (vm.count("help"))
00033 {
00034 cout << desc << "\n";
00035 return 1;
00036 }
00037
00038 std::cout<<"loading "<<base_name<<" at resolution "<<resolution<<" with point type "<<point_type<<std::endl;
00039
00040 if(point_type == "XYZI") {
00041
00042 lslgeneric::NDTMap<pcl::PointXYZI> ndmap(new lslgeneric::LazyGrid<pcl::PointXYZI>(resolution));
00043 ndmap.loadFromJFF(base_name.c_str());
00044
00045 NDTViz<pcl::PointXYZI> *viewer = new NDTViz<pcl::PointXYZI>(true);
00046
00047 viewer->plotNDTSAccordingToOccupancy(-1,&ndmap);
00048 while(viewer->win3D->isOpen()){
00049 if (viewer->win3D->keyHit())
00050 {
00051 mrptKeyModifier kmods;
00052 int key = viewer->win3D->getPushedKey(&kmods);
00053 printf("Key pushed: %c (%i) - modifiers: 0x%04X\n",char(key),key,kmods);
00054
00055 if (key==MRPTK_RIGHT) viewer->win3D->setCameraAzimuthDeg( viewer->win3D->getCameraAzimuthDeg() + 5 );
00056 if (key==MRPTK_LEFT) viewer->win3D->setCameraAzimuthDeg( viewer->win3D->getCameraAzimuthDeg() - 5 );
00057
00058 if(key =='o'){
00059 viewer->plotNDTSAccordingToOccupancy(-1,&ndmap);
00060 }
00061 if(key =='c'){
00062 viewer->plotNDTSAccordingToClass(-1,&ndmap);
00063 }
00064 if(key =='p'){
00065 viewer->plotNDTSAccordingToCost(-1,10000,&ndmap);
00066 }
00067
00068 if(key =='h'){
00069 fprintf(stderr,"[h] help\n");
00070 fprintf(stderr,"[o] Just plot acording to occupancy \n");
00071 fprintf(stderr,"[c] plot acording to class and occupancy \n");
00072 fprintf(stderr,"[p] plot acording to cost-to-go from the path planner \n");
00073 }
00074
00075 if(key =='q'){
00076 break;
00077 }
00078 }
00079 usleep(100*1000);
00080 }
00081 delete viewer;
00082 } else {
00083
00084 lslgeneric::NDTMap<pcl::PointXYZ> ndmap(new lslgeneric::LazyGrid<pcl::PointXYZ>(resolution));
00085 ndmap.loadFromJFF(base_name.c_str());
00086
00087 NDTViz<pcl::PointXYZ> *viewer = new NDTViz<pcl::PointXYZ>(true);
00088
00089 viewer->plotNDTSAccordingToOccupancy(-1,&ndmap);
00090 while(viewer->win3D->isOpen()){
00091 if (viewer->win3D->keyHit())
00092 {
00093 mrptKeyModifier kmods;
00094 int key = viewer->win3D->getPushedKey(&kmods);
00095 printf("Key pushed: %c (%i) - modifiers: 0x%04X\n",char(key),key,kmods);
00096
00097 if (key==MRPTK_RIGHT) viewer->win3D->setCameraAzimuthDeg( viewer->win3D->getCameraAzimuthDeg() + 5 );
00098 if (key==MRPTK_LEFT) viewer->win3D->setCameraAzimuthDeg( viewer->win3D->getCameraAzimuthDeg() - 5 );
00099
00100 if(key =='q'){
00101 break;
00102 }
00103 }
00104 usleep(100*1000);
00105 }
00106 delete viewer;
00107
00108 }
00109
00110 }
00111