rdk2carmen.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <fstream>
3 #include <iostream>
5 #include <log/sensorlog.h>
6 
7 
8 using namespace std;
9 using namespace GMapping;
10 
11 int main(int argc, char ** argv){
12  if (argc<2){
13  cerr << "usage "<<argv[0]<<" <filename> <outfilename>" << endl;
14  cerr << "or "<<argv[0]<<" <filename> for standard output" << endl;
15  exit (-1);
16  }
17  ifstream is(argv[1]);
18  if (! is){
19  cerr << "no file " << argv[1] << " found" << endl;
20  exit (-1);
21  }
22  ostream *os;
23  if (argc<3)
24  os=&cout;
25  else{
26  os=new ofstream(argv[2]);
27  if (! os){
28  cerr << "no file " << argv[1] << " found" << endl;
29  exit (-1);
30  }
31  }
33  conf.load(is);
34 
35  SensorMap m=conf.computeSensorMap();
36 
37  //for (SensorMap::const_iterator it=m.begin(); it!=m.end(); it++)
38  // cout << it->first << " " << it->second->getName() << endl;
39 
40  SensorLog log(m);
41  is.close();
42 
43  ifstream ls(argv[1]);
44  log.load(ls);
45  ls.close();
46  cerr << "log size" << log.size() << endl;
47  for (SensorLog::iterator it=log.begin(); it!=log.end(); it++){
48  RangeReading* rr=dynamic_cast<RangeReading*>(*it);
49  if (rr){
50  *os << rr->getSensor()->getName() << " ";
51  *os << rr->size()<< " ";
52  for (RangeReading::const_iterator it=rr->begin(); it!=rr->end(); it++){
53  *os << (*it)*0.001 << " ";
54  }
55  *os<< rr->getPose().x*0.001 << " " << rr->getPose().y*0.001 << " " << rr->getPose().theta << endl;
56  }
57  }
58 }
const Sensor * getSensor() const
Definition: sensorreading.h:13
int main(int argc, char **argv)
Definition: rdk2carmen.cpp:11
virtual SensorMap computeSensorMap() const
virtual std::istream & load(std::istream &is)
const OrientedPoint & getPose() const
Definition: rangereading.h:15
std::istream & load(std::istream &is)
Definition: sensorlog.cpp:23
std::map< std::string, Sensor * > SensorMap
Definition: sensor.h:19
std::string getName() const
Definition: sensor.h:13
ifstream is(argv[c])


openslam_gmapping
Author(s): Giorgio Grisetti, Cyrill Stachniss, Wolfram Burgard
autogenerated on Mon Jun 10 2019 14:04:22