24 #include "moc_qparticleviewer.cpp" 32 setMinimumSize(500,500);
60 if (event->button()==LeftButton){
76 if (event->button()==LeftButton){
85 case Qt::Key_Plus:
mapscale *=1.25;
break;
86 case Qt::Key_Minus:
mapscale/=1.25;
break;
96 cerr <<
"QParticleViewer::resizeEvent" << sizeev->size().width()<<
" " << sizeev->size().height() << endl;
101 assert(oldPose.size()==newPose.size());
103 painter.setPen(Qt::red);
104 OrientedPointVector::const_iterator nit=newPose.begin();
105 for(OrientedPointVector::const_iterator it=oldPose.begin(); it!=oldPose.end(); it++, nit++){
109 (
int)(p0.
x), (
int)(p0.
y), (
int)(p1.
x), (
int)(p1.
y)
119 QTextIStream&
is=*
tis;
121 string line=is.readLine();
122 istringstream lineStream(line);
124 lineStream >> recordType;
125 if (recordType==
"LASER_READING"){
127 cout <<
"l" << flush;
129 if (recordType==
"ODO_UPDATE"){
140 for (
unsigned int i=0; i< size; i++){
145 lineStream >> p.
theta;
149 cout <<
"o" << flush;
151 if (recordType==
"SM_UPDATE"){
161 for (
unsigned int i=0; i< size; i++){
166 lineStream >> p.
theta;
170 cout <<
"u" << flush;
172 if (recordType==
"RESAMPLE"){
179 for (
unsigned int i=0; i< size; i++){
185 cout <<
"r" << flush;
196 painter.setPen(Qt::black);
197 m_pixmap->fill(QColor(200,200,255));
198 unsigned int count=0;
209 for(
int x=0; x<
m_pixmap->width(); x++)
210 for(
int y=0; y<
m_pixmap->height(); y++){
217 double v=map.
cell(p);
219 int grayValue=255-(int)(255.*v);
220 painter.setPen(QColor(grayValue, grayValue, grayValue));
221 painter.drawPoint(x,y);
233 for (GridSlamProcessorThread::EventDeque::const_iterator it=events.begin(); it!=events.end();it++){
259 unsigned int particleSize=0;
260 std::vector<OrientedPoint> oldPose, newPose;
261 vector<unsigned int> indexes;
263 GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin();
264 while (!particleSize && it!=
history.rend()){
270 particleSize=resample->
indexes.size();
276 unsigned int bestIdx=0;
278 for (
unsigned int i=0; i<particleSize; i++){
279 unsigned int currentIndex=i;
281 for(GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin(); it!=
history.rend()&& !done; it++){
287 bestIdx=currentIndex;
297 currentIndex=resample->
indexes[currentIndex];
304 for (
unsigned int i=0; i<particleSize+1; i++){
305 painter.setPen(Qt::yellow);
306 unsigned int currentIndex=i;
308 currentIndex=bestIdx;
309 painter.setPen(Qt::red);
313 for(GridSlamProcessorThread::EventDeque::reverse_iterator it=
history.rbegin(); it!=
history.rend(); it++){
320 painter.drawPoint(p0.
x, p0.
y);
322 painter.drawLine(p0.
x, p0.
y, p1.x, p1.y);
330 if (resample && ! first){
331 currentIndex=resample->
indexes[currentIndex];
338 sprintf(name,
"dump-%05d.png",
count/writeToFile);
339 cout <<
" Writing " << name <<
" ..." << flush;
340 QImage image=
m_pixmap->convertToImage();
341 bool rv=image.save(name,
"PNG");
353 if (te->timerId()==
timer) {
365 timer=startTimer(period);
const char *const *argv double delta
virtual ~QParticleViewer()
Cell & cell(int x, int y)
void setMatchingParameters(const MatchingParameters &mp)
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 *)
const ParticleVector & getParticles() const
void resample(std::vector< int > &indexes, const WeightVector &weights, unsigned int nparticles=0)
QParticleViewer(QWidget *parent=0, const char *name=0, WFlags f=0, GridSlamProcessorThread *thread=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)
virtual void mousePressEvent(QMouseEvent *)
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)
IntPoint world2map(const Point &p) const
virtual void timerEvent(QTimerEvent *te)
virtual void keyPressEvent(QKeyEvent *e)