log_plot.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <fstream>
3 #include <iostream>
4 #include <sys/types.h>
7 
8 
9 using namespace std;
10 using namespace GMapping;
11 
12 int main(int argc, char ** argv){
13  double maxrange=2.;
14  if (argc<2){
15  cout << "usage log_plot <filename> | gnuplot" << endl;
16  exit (-1);
17  }
18  ifstream is(argv[1]);
19  if (! is){
20  cout << "no file " << argv[1] << " found" << endl;
21  exit (-1);
22  }
24  conf.load(is);
25 
26  SensorMap m=conf.computeSensorMap();
27 
28  //for (SensorMap::const_iterator it=m.begin(); it!=m.end(); it++)
29  // cout << it->first << " " << it->second->getName() << endl;
30 
31  SensorLog log(m);
32  is.close();
33 
34  ifstream ls(argv[1]);
35  log.load(ls);
36  ls.close();
37  int count=0;
38  int frame=0;
39  cerr << "log size" << log.size() << endl;
40  for (SensorLog::iterator it=log.begin(); it!=log.end(); it++){
41  RangeReading* rr=dynamic_cast<RangeReading*>(*it);
42  if (rr){
43  count++;
44  if (count%3)
45  continue;
46  std::vector<Point> points(rr->size());
47  uint j=0;
48  for (uint i=0; i<rr->size(); i++){
49  const RangeSensor * rs=dynamic_cast<const RangeSensor*>(rr->getSensor());
50  double c=rs->beams()[i].c, s=rs->beams()[i].s;
51  double r=(*rr)[i];
52  if (r>maxrange)
53  continue;
54  points[j++]=Point(r*c,r*s);
55  }
56  if (j){
57  char buf[1024];
58  sprintf(buf,"frame-%05d.gif",frame);
59  frame++;
60  cout << "set terminal gif" << endl;
61  cout << "set output \"" << buf << "\"" << endl;
62  cout << "set size ratio -1" << endl;
63  cout << "plot [-3:3][0:3] '-' w p ps 1" << endl;
64  for (uint i=0; i<j; i++){
65  cout << points[i].y << " " << points[i].x << endl;
66  }
67  cout << "e" << endl;
68  }
69  }
70  }
71 }
GMapping::SensorMap
std::map< std::string, Sensor * > SensorMap
Definition: sensor.h:20
c
unsigned int c
Definition: gfs2stream.cpp:41
is
ifstream is(argv[c])
carmenconfiguration.h
GMapping::CarmenConfiguration::computeSensorMap
virtual SensorMap computeSensorMap() const
Definition: carmenconfiguration.cpp:97
GMapping
Definition: configfile.cpp:34
GMapping::RangeSensor::beams
const std::vector< Beam > & beams() const
Definition: rangesensor.h:24
sensorlog.h
main
int main(int argc, char **argv)
Definition: log_plot.cpp:12
GMapping::CarmenConfiguration
Definition: carmenconfiguration.h:14
GMapping::RangeSensor
Definition: rangesensor.h:11
GMapping::Point
point< double > Point
Definition: point.h:202
GMapping::SensorLog::load
std::istream & load(std::istream &is)
Definition: sensorlog.cpp:23
GMapping::SensorReading::getSensor
const Sensor * getSensor() const
Definition: sensoreading.h:13
GMapping::RangeReading
Definition: rangereading.h:17
GMapping::CarmenConfiguration::load
virtual std::istream & load(std::istream &is)
Definition: carmenconfiguration.cpp:17
maxrange
double maxrange
Definition: gfs2stream.cpp:22
GMapping::SensorLog
Definition: sensorlog.h:16


openslam_gmapping
Author(s): Cyrill Stachniss, Udo Frese, Giorgio Grisetti, Wolfram Burgard
autogenerated on Thu Oct 19 2023 02:25:51