8 #include <qapplication.h> 11 #define MAX_LASER_BEAMS 1024 12 #define MAX_FILENAME 1024 18 inline double min(
double a,
double b){
22 inline double max(
double a,
double b){
27 double theta=-M_PI/2+pose.
theta;
28 double theta_step=(laser.
readings.size()==180||laser.
readings.size()==181)?M_PI/180:M_PI/360;
29 for (std::vector<double>::const_iterator it=laser.
readings.begin(); it!=laser.
readings.end(); it++){
31 xmin=
min(xmin,pose.
x+*it*cos(theta));
32 ymin=
min(ymin,pose.
y+*it*sin(theta));
33 xmax=
max(xmax,pose.
x+*it*cos(theta));
34 ymax=
max(ymax,pose.
y+*it*sin(theta));
41 xmin = ymin = MAXDOUBLE;
42 xmax = ymax =-MAXDOUBLE;
44 for (RecordList::const_iterator it=rl.begin(); it!=rl.end(); it++){
51 if (smr && lastLaser){
52 for (std::vector<OrientedPoint>::const_iterator pit=smr->
poses.begin(); pit!=smr->
poses.end(); pit++){
58 int main(
int argc,
char** argv){
59 QApplication app(argc, argv);
63 const char* filename=0;
64 const char* format=
"PNG";
75 cout <<
" supply a gfs file, please" << endl;
76 cout <<
" usage gfs2img [options] -filename <gfs_file>" << endl;
77 cout <<
" [options]:" << endl;
78 cout <<
" -maxrange <range>" << endl;
79 cout <<
" -delta <map cell size>" << endl;
80 cout <<
" -skip <frames to skip among images>" << endl;
81 cout <<
" -format <image format in capital letters>" << endl;
84 ifstream
is(filename);
86 cout <<
" supply an EXISTING gfs file, please" << endl;
94 for (RecordList::const_iterator it=rl.begin(); it!=rl.end(); it++){
97 particles=odometry->
dim;
103 if (particles && beams)
106 cout <<
"Particles from gfs=" << particles << endl;
108 cout <<
"no particles found, terminating" << endl;
111 cout <<
"Laser beams from gfs=" << beams << endl;
113 cout <<
"0 beams found, terminating" << endl;
118 double laserBeamStep=0;
119 if (beams==180||beams==181){
120 laserBeamStep=M_PI/180;
121 }
else if (beams==360||beams==361){
122 laserBeamStep=M_PI/360;
124 cout <<
"Laser beam step" << laserBeamStep << endl;
125 if (laserBeamStep==0){
126 cout <<
"Invalid Beam Step, terminating" << endl;
130 double theta=-M_PI/2;
131 for (
int i=0; i<beams; i++){
132 laserAngles[i]=theta;
133 theta+=laserBeamStep;
138 matcher.setlaserMaxRange(maxrange);
139 matcher.setusableRange(maxUrange);
140 matcher.setgenerateMap(
true);
142 double xmin, ymin, xmax, ymax;
143 cout <<
"computing bounding box" << endl;
145 cout <<
"DONE" << endl <<
"BBOX= " << xmin <<
" " << ymin <<
" " << xmax <<
" " << ymax << endl;
148 center.
x=(xmin+xmax)/2.;
149 center.
y=(ymin+ymax)/2.;
151 cout <<
"computing paths" << endl;
152 unsigned int frame=0;
155 for (RecordList::const_iterator it=rl.begin(); it!=rl.end(); it++){
160 if (scanCount%scanSkip)
162 cout <<
"Frame " << frame <<
" ";
163 std::vector<RecordList> paths(particles);
165 double bestWeight=-MAXDOUBLE;
166 for (
int p=0; p<particles; p++){
174 cout <<
"bestIdx=" << bestIdx <<
" bestWeight=" << bestWeight << endl;
176 cout <<
"computing best map" << endl;
179 for (RecordList::const_iterator mt=paths[bestIdx].begin(); mt!=paths[bestIdx].end(); mt++){
183 for (uint i=0; i<s->
readings.size(); i++)
192 cout <<
"DONE " << count <<endl;
195 pixmap.fill(QColor(200, 200, 255));
196 QPainter painter(&pixmap);
199 double v=smap.
cell(x,y);
201 int grayValue=255-(int)(255.*v);
202 painter.setPen(QColor(grayValue, grayValue, grayValue));
246 cout <<
" DONE" << endl;
247 cout <<
"writing image" << endl;
248 QImage img=pixmap.convertToImage();
250 sprintf(ofilename,
"%s-%.4d.%s",filename, frame, format);
251 cout << ofilename << endl;
252 img.save(QString(ofilename), format,0);
256 cout <<
"For Cyrill: \"The Evil is Outside\"" << endl;
const char *const *argv double delta
double registerScan(ScanMatcherMap &map, const OrientedPoint &p, const double *readings)
Cell & cell(int x, int y)
vector< double > readings
istream & read(istream &is)
int main(int argc, char **argv)
#define parseDouble(name, value)
#define parseInt(name, value)
void setLaserParameters(unsigned int beams, double *angles, const OrientedPoint &lpose)
void computeBoundingBox(double &xmin, double &ymin, double &xmax, double &ymax, const LaserRecord &laser, const OrientedPoint &pose, double maxrange)
void invalidateActiveArea()
#define parseString(name, value)
vector< OrientedPoint > poses
double min(double a, double b)
double max(double a, double b)
void computeActiveArea(ScanMatcherMap &map, const OrientedPoint &p, const double *readings)
RecordList computePath(unsigned int i, RecordList::const_iterator frame) const
double getLogWeight(unsigned int i) const
orientedpoint< double, double > OrientedPoint
CMD_PARSE_BEGIN(1, argc-2)