Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00049 double srr, srt, str, stt;
00050
00051 double xmin, ymin, xmax, ymax, delta;
00052 OrientedPoint initialPose;
00053
00054 double lsigma, lgain;
00055 unsigned int lskip;
00056
00057 double linearUpdate, angularUpdate;
00058
00059 unsigned int particles;
00060 double resampleThreshold;
00061
00062 bool drawFromObservation;
00063
00064 const char * outFileName;
00065 };
00066
00067 struct MatchingParameters{
00068
00069 double maxrange, urange;
00070
00071 double ssigma, sreg, scrit;
00072 unsigned int ksize;
00073
00074 double lstep, astep;
00075 unsigned int iterations;
00076 };
00077
00078 void refreshParameters();
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
00128 GridSlamProcessorThread* gfs_thread;
00129 GridSlamProcessorThread::EventDeque history;
00130
00131
00132 virtual void mousePressEvent(QMouseEvent*);
00133 virtual void mouseReleaseEvent(QMouseEvent*);
00134 virtual void mouseMoveEvent(QMouseEvent*);
00135 QPoint draggingPos;
00136 bool dragging;
00137
00138
00139 virtual void keyPressEvent ( QKeyEvent* e );
00140
00141
00142 double mapscale;
00143 Point viewCenter;
00144 Point bestParticlePose;
00145 ScanMatcherMap * bestMap;
00146
00147
00148 bool showPaths;
00149 bool showBestPath;
00150
00151
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