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