qparticleviewer.h
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 #ifndef QPARTICLEVIEWER_H
00025 #define QPARTICLEVIEWER_H
00026 
00027 #include <qpainter.h>
00028 #include <qpixmap.h>
00029 #include <qwidget.h>
00030 #include <qmatrix.h>
00031 #include <qtextstream.h>
00032 #include <vector>
00033 #include <assert.h>
00034 #include <sstream>
00035 #include <iostream>
00036 #include <qimage.h>
00037 #include <QTextStream>
00038 
00039 #include <utils/point.h>
00040 #include "gsp_thread.h"
00041 
00042 namespace GMapping {
00043 
00044 class QParticleViewer :  public QWidget{
00045         Q_OBJECT
00046         public:
00047                 struct StartParameters{
00048                         //motionmodel
00049                         double srr, srt, str, stt;
00050                         //map
00051                         double xmin, ymin, xmax, ymax, delta;
00052                         OrientedPoint initialPose;
00053                         //likelihood
00054                         double lsigma, lgain;
00055                         unsigned int lskip;
00056                         //update
00057                         double linearUpdate, angularUpdate;
00058                         //filter
00059                         unsigned int particles;
00060                         double resampleThreshold;
00061                         //mode
00062                         bool drawFromObservation;
00063                         //output
00064                         const char * outFileName;
00065                 };
00066                 
00067                 struct MatchingParameters{
00068                         //ranges
00069                         double maxrange, urange;
00070                         //score
00071                         double ssigma, sreg, scrit;
00072                         unsigned int ksize;
00073                         //search
00074                         double lstep, astep;
00075                         unsigned int iterations;
00076                 };
00077 
00078                 void refreshParameters(); //reads the parameters from the thread
00079                 inline void setGSP( GridSlamProcessorThread* thread){gfs_thread=thread;}
00080                 
00081                 
00082                 typedef std::vector<OrientedPoint> OrientedPointVector;
00083                 QParticleViewer( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0, GridSlamProcessorThread* thread=0 );
00084                 virtual ~QParticleViewer();
00085                 virtual void timerEvent(QTimerEvent * te);
00086                 virtual void resizeEvent(QResizeEvent *);
00087                 
00088                 void drawFromFile();
00089                 void drawFromMemory();
00090                 void drawMap(const ScanMatcherMap& map);
00091                 void start(int period);
00092                 QTextStream* tis;
00093                 
00094                 MatchingParameters matchingParameters;
00095                 StartParameters startParameters;
00096                 
00097                 int writeToFile;
00098         public slots:
00099                 void setMatchingParameters(const MatchingParameters& mp);
00100                 void setStartParameters(const StartParameters& mp);
00101                 void start();
00102                 void stop();
00103                 void loadFile(const char *);
00104         signals:
00105                 void neffChanged(double);
00106                 void poseEntropyChanged(double, double, double);
00107                 void trajectoryEntropyChanged(double, double, double);
00108                 void mapsEntropyChanged(double);
00109                 void mapsIGainChanged(double);
00110                 
00111         protected:
00112                 ifstream inputStream;
00113                 ofstream outputStream;
00114                 
00115                         
00116         protected:
00117                 inline Point pic2map(const IntPoint& p) 
00118                         {return viewCenter+Point(p.x/mapscale, -p.y/mapscale); }
00119                 inline IntPoint map2pic(const Point& p)
00120                         {return IntPoint((int)((p.x-viewCenter.x)*mapscale),(int)((viewCenter.y-p.y)*mapscale)); }
00121                 
00122                 int timer;
00123                 virtual void paintEvent ( QPaintEvent *paintevent );
00124                 void drawParticleMove(const OrientedPointVector& start, const OrientedPointVector& end); 
00125                 QPixmap* m_pixmap;
00126                 
00127                 //thread interaction
00128                 GridSlamProcessorThread* gfs_thread;
00129                 GridSlamProcessorThread::EventDeque history;
00130                 
00131                 //mouse movement
00132                 virtual void mousePressEvent(QMouseEvent*);
00133                 virtual void mouseReleaseEvent(QMouseEvent*);
00134                 virtual void mouseMoveEvent(QMouseEvent*);
00135                 QPoint draggingPos;
00136                 bool dragging;
00137                 
00138                 //particle plotting
00139                 virtual void keyPressEvent ( QKeyEvent* e );
00140                 
00141                 //map painting
00142                 double mapscale;
00143                 Point viewCenter;
00144                 Point bestParticlePose;
00145                 ScanMatcherMap * bestMap;
00146                 
00147                 // view mode
00148                 bool showPaths;
00149                 bool showBestPath;
00150                 
00151                 // file plotting
00152                 QParticleViewer::OrientedPointVector m_oldPose, m_newPose;
00153                 unsigned int m_particleSize;
00154                 bool m_refresh;
00155                 int count;
00156 };
00157 
00158 };
00159 
00160 #endif
00161 


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Thu Jun 6 2019 19:25:13