25 #include "moc_qparticleviewer.cpp" 33 setMinimumSize(500,500);
61 if (event->button()==LeftButton){
77 if (event->button()==LeftButton){
86 case Qt::Key_Plus:
mapscale *=1.25;
break;
87 case Qt::Key_Minus:
mapscale/=1.25;
break;
97 cerr <<
"QParticleViewer::resizeEvent" << sizeev->size().width()<<
" " << sizeev->size().height() << endl;
102 assert(oldPose.size()==newPose.size());
104 painter.setPen(Qt::red);
105 OrientedPointVector::const_iterator nit=newPose.begin();
106 for(OrientedPointVector::const_iterator it=oldPose.begin(); it!=oldPose.end(); it++, nit++){
110 (
int)(p0.
x), (
int)(p0.
y), (
int)(p1.
x), (
int)(p1.
y)
120 QTextIStream&
is=*
tis;
122 string line=is.readLine();
123 istringstream lineStream(line);
125 lineStream >> recordType;
126 if (recordType==
"LASER_READING"){
128 cout <<
"l" << flush;
130 if (recordType==
"ODO_UPDATE"){
141 for (
unsigned int i=0; i< size; i++){
146 lineStream >> p.
theta;
150 cout <<
"o" << flush;
152 if (recordType==
"SM_UPDATE"){
162 for (
unsigned int i=0; i< size; i++){
167 lineStream >> p.
theta;
171 cout <<
"u" << flush;
173 if (recordType==
"RESAMPLE"){
180 for (
unsigned int i=0; i< size; i++){
186 cout <<
"r" << flush;
197 painter.setPen(Qt::black);
198 m_pixmap->fill(QColor(200,200,255));
199 unsigned int count=0;
210 for(
int x=0; x<
m_pixmap->width(); x++)
211 for(
int y=0; y<
m_pixmap->height(); y++){
218 double v=map.
cell(p);
220 int grayValue=255-(int)(255.*v);
221 painter.setPen(QColor(grayValue, grayValue, grayValue));
222 painter.drawPoint(x,y);
234 for (GridSlamProcessorThread::EventDeque::const_iterator it=events.begin(); it!=events.end();it++){
260 unsigned int particleSize=0;
261 std::vector<OrientedPoint> oldPose, newPose;
262 vector<unsigned int> indexes;
264 GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin();
265 while (!particleSize && it!=
history.rend()){
271 particleSize=resample->
indexes.size();
277 unsigned int bestIdx=0;
279 for (
unsigned int i=0; i<particleSize; i++){
280 unsigned int currentIndex=i;
282 for(GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin(); it!=
history.rend()&& !done; it++){
288 bestIdx=currentIndex;
298 currentIndex=resample->
indexes[currentIndex];
305 for (
unsigned int i=0; i<particleSize+1; i++){
306 painter.setPen(Qt::yellow);
307 unsigned int currentIndex=i;
309 currentIndex=bestIdx;
310 painter.setPen(Qt::red);
314 for(GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin(); it!=
history.rend(); it++){
321 painter.drawPoint(p0.
x, p0.
y);
323 painter.drawLine(p0.
x, p0.
y, p1.x, p1.y);
331 if (resample && ! first){
332 currentIndex=resample->
indexes[currentIndex];
339 sprintf(name,
"dump-%05d.png",
count/writeToFile);
340 cout <<
" Writing " << name <<
" ..." << flush;
341 QImage image=
m_pixmap->convertToImage();
342 bool rv=image.save(name,
"PNG");
354 if (te->timerId()==
timer) {
366 timer=startTimer(period);
const char *const *argv double delta
virtual ~QParticleViewer()
Cell & cell(int x, int y)
void setMatchingParameters(const MatchingParameters &mp)
const ParticleVector & getParticles() const
unsigned int m_particleSize
void drawMap(const ScanMatcherMap &map)
int loadFiles(const char *fn=0)
void setMatchingParameters(double urange, double range, double sigma, int kernsize, double lopt, double aopt, int iterations, double likelihoodSigma=1, double likelihoodGain=1, unsigned int likelihoodSkip=0)
MatchingParameters matchingParameters
QParticleViewer::OrientedPointVector m_oldPose
OrientedPoint initialPose
std::vector< double > weightSums
virtual void resizeEvent(QResizeEvent *)
QParticleViewer::OrientedPointVector m_newPose
std::vector< OrientedPoint > OrientedPointVector
void loadFile(const char *)
void resample(std::vector< int > &indexes, const WeightVector &weights, unsigned int nparticles=0)
virtual void mouseReleaseEvent(QMouseEvent *)
void setUpdateDistances(double linear, double angular, double resampleThreshold)
StartParameters startParameters
IntPoint map2pic(const Point &p)
void setStartParameters(const StartParameters &mp)
deque< Event * > EventDeque
virtual void paintEvent(QPaintEvent *paintevent)
void drawParticleMove(const OrientedPointVector &start, const OrientedPointVector &end)
QParticleViewer(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0, GridSlamProcessorThread *thread=0)
virtual void mousePressEvent(QMouseEvent *)
IntPoint world2map(const Point &p) const
virtual void mouseMoveEvent(QMouseEvent *)
std::vector< unsigned int > indexes
GridSlamProcessorThread * gfs_thread
std::vector< OrientedPoint > hypotheses
Point pic2map(const IntPoint &p)
GridSlamProcessorThread::EventDeque history
void setMotionModelParameters(double srr, double srt, double str, double stt)
virtual void timerEvent(QTimerEvent *te)
virtual void keyPressEvent(QKeyEvent *e)