gfs_simplegui.cpp
Go to the documentation of this file.
00001 /*****************************************************************
00002  *
00003  * This file is part of the GMAPPING project
00004  *
00005  * GMAPPING Copyright (c) 2004 Giorgio Grisetti, 
00006  * Cyrill Stachniss, and Wolfram Burgard
00007  *
00008  * This software is licensed under the "Creative Commons 
00009  * License (Attribution-NonCommercial-ShareAlike 2.0)" 
00010  * and is copyrighted by Giorgio Grisetti, Cyrill Stachniss, 
00011  * and Wolfram Burgard.
00012  * 
00013  * Further information on this license can be found at:
00014  * http://creativecommons.org/licenses/by-nc-sa/2.0/
00015  * 
00016  * GMAPPING is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied 
00018  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00019  * PURPOSE.  
00020  *
00021  *****************************************************************/
00022 
00023 
00024 #include "qparticleviewer.h"
00025 #include "qgraphpainter.h"
00026 #include <qapplication.h>
00027 #include <qframe.h>
00028 #include <qlabel.h>
00029 #include <qlayout.h>
00030 #include <qvbox.h>
00031 #include <qmainwindow.h>
00032 
00033 class GFSMainWindow: public QMainWindow{
00034 public:
00035   GFSMainWindow(GridSlamProcessorThread* t){
00036     gsp_thread=t;
00037     QVBoxLayout* layout=new QVBoxLayout(this);
00038     pviewer=new QParticleViewer(this,0,0,gsp_thread);
00039     pviewer->setGeometry(0,0,500,500);
00040     pviewer->setFocusPolicy(QParticleViewer::ClickFocus);
00041     layout->addWidget(pviewer);
00042                                                 
00043     gpainter=new QGraphPainter(this);
00044     gpainter->setFixedHeight(100);
00045     layout->addWidget(gpainter);
00046     gpainter->setRange(0,1);
00047     gpainter->setTitle("Neff");
00048                 
00049     help = new QLabel(QString("+/- - zoom | b - show/hide best path | p - show/hide all paths | c - center robot "),this); 
00050     help->setMaximumHeight(30);
00051     layout->addWidget(help);
00052         
00053     QObject::connect( pviewer, SIGNAL(neffChanged(double) ), gpainter, SLOT(valueAdded(double)) );
00054     setTabOrder(pviewer, pviewer);
00055   }
00056                 
00057   void start(int c){
00058     pviewer->start(c);
00059     gpainter->start(c);
00060   }
00061 
00062 protected:
00063   GridSlamProcessorThread* gsp_thread;
00064   QVBoxLayout* layout;
00065   QParticleViewer* pviewer;
00066   QGraphPainter* gpainter;
00067   QLabel* help;
00068 };
00069 
00070 
00071 int  main (int argc, char ** argv){
00072   cerr << "GMAPPING copyright 2004 by Giorgio Grisetti, Cyrill Stachniss," << endl ;
00073   cerr << "and Wolfram Burgard. To be published under the CreativeCommons license," << endl;
00074   cerr << "see: http://creativecommons.org/licenses/by-nc-sa/2.0/" << endl << endl;
00075 
00076 
00077   GridSlamProcessorThread* gsp=  new GridSlamProcessorThread;
00078   if (gsp->init(argc, argv)){
00079     cerr << "GridFastSlam: Initialization Error!" << endl;
00080     cerr << "(Did you specified an input file for reading?)" << endl;
00081     return -1;
00082   }
00083   if (gsp->loadFiles()){
00084     cerr <<"Error reading file!"<< endl;
00085     return -2;
00086   }
00087   cerr <<"File successfully loaded!"<< endl;
00088   QApplication app(argc, argv);
00089   GFSMainWindow* mainWin=new GFSMainWindow(gsp);
00090   app.setMainWidget(mainWin);
00091   mainWin->show();
00092   gsp->setEventBufferSize(10000);
00093   gsp->start();
00094   mainWin->start(1000);
00095   return app.exec();
00096 }
00097 


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Fri Aug 28 2015 11:56:21