Go to the documentation of this file.00001 #include <ndt_visualisation/ndt_viz.h>
00002 #include <boost/program_options.hpp>
00003
00004 namespace po = boost::program_options;
00005
00006
00007 void printUsage() {
00008 fprintf(stderr,"========== USAGE =========\n");
00009 fprintf(stderr,"[h] help\n");
00010 fprintf(stderr,"[o] Just plot acording to occupancy \n");
00011 fprintf(stderr,"[c] plot acording to class and occupancy \n");
00012 fprintf(stderr,"[p] plot acording to cost-to-go from the path planner \n");
00013 fprintf(stderr,"[t] plot traversability map \n");
00014 fprintf(stderr,"[q] quit \n");
00015 fprintf(stderr,"==========================\n");
00016 }
00017
00018 int main(int argc, char **argv){
00019
00020 std::string base_name;
00021 double resolution;
00022
00023 po::options_description desc("Allowed options");
00024 desc.add_options()
00025 ("help", "produce help message")
00026 ("file-name", po::value<std::string>(&base_name), "location of the ndt map you want to view")
00027 ("resolution", po::value<double>(&resolution)->default_value(1.), "resolution of the map (necessary due to bug in loading, should be fixed soon)")
00028 ;
00029
00030 po::variables_map vm;
00031 po::store(po::parse_command_line(argc, argv, desc), vm);
00032 po::notify(vm);
00033
00034 if (!vm.count("file-name") || !vm.count("resolution"))
00035 {
00036 std::cout << "Missing arguments.\n";
00037 std::cout << desc << "\n";
00038 return 1;
00039 }
00040 if (vm.count("help"))
00041 {
00042 std::cout << desc << "\n";
00043 return 1;
00044 }
00045
00046 std::cout<<"loading "<<base_name<<" at resolution "<<resolution<<std::endl;
00047 printUsage();
00048
00049
00050 lslgeneric::NDTMap ndmap(new lslgeneric::LazyGrid(resolution));
00051 ndmap.loadFromJFF(base_name.c_str());
00052
00053 NDTViz *viewer = new NDTViz(true);
00054
00055 viewer->win3D->start_main_loop_own_thread();
00056 viewer->plotNDTSAccordingToOccupancy(-1,&ndmap);
00057 while(viewer->win3D->isOpen()){
00058
00059 if (viewer->win3D->keyHit())
00060 {
00061 int key = viewer->win3D->getPushedKey();
00062 printf("Key pushed: %c (%i)\n",char(key),key);
00063
00064 if(key =='o'){
00065 viewer->plotNDTSAccordingToOccupancy(-1,&ndmap);
00066 }
00067 if(key =='c'){
00068 viewer->plotNDTSAccordingToClass(-1,&ndmap);
00069 }
00070 if(key =='p'){
00071 viewer->plotNDTSAccordingToCost(-1,10000,&ndmap);
00072 }
00073 if(key =='t'){
00074 viewer->plotNDTTraversabilityMap(&ndmap);
00075 }
00076 if(key =='h'){
00077 printUsage();
00078 }
00079
00080 if(key =='q'){
00081 break;
00082 }
00083 }
00084 usleep(1000);
00085 }
00086 delete viewer;
00087
00088
00089 }
00090