9 #define MAX_LINE_LENGHT (1000000)    18         virtual void read(istream& 
is)=0;
    19         virtual void write(ostream& os){};
    30         virtual void write(ostream& os){
    31                 os << 
"#GFS_COMMENT: " << text << endl;
    42                 is >> pose.
x >> pose.
y >> pose.
theta;
    47         virtual void write(ostream& os){
    54                 os << pose.
x*100 << 
" " << pose.
y*100 << 
" " << 180/M_PI*pose.
theta <<  endl;
    63         virtual void write(ostream& os){
    64                 os << 
"NEFF " << neff << endl;
    73                 for (
unsigned int i=0; i< dim; i++){
    94                 for (
unsigned int i=0; i< dim; i++){
   102                         weights.push_back(w);
   112                 for (
unsigned int i=0; i< dim; i++){
   115                         readings.push_back(r);
   131                 os << pose.
x*100 << 
" " << pose.
y*100 << 
" " << 180/M_PI*pose.
theta <<  endl;
   133                 os << 
"LASER-RANGE ";
   135                 os << 
" 0 0 0 " << dim << 
" 180. : ";
   136                 for (
unsigned int i=0; i< dim; i++){
   137                         os <<
" "<< readings[i]*100 ;
   147                 for (
unsigned int i=0; i< dim; i++){
   150                         indexes.push_back(j);
   161                         is.getline(buf, 8192);
   162                         istringstream lineStream(buf);
   164                         lineStream >> recordType;
   166                         if (recordType==
"LASER_READING"){
   168                                 cout << 
"l" << flush;
   170                         if (recordType==
"ODO_UPDATE"){
   172                                 cout << 
"o" << flush;
   174                         if (recordType==
"SM_UPDATE"){
   176                                 cout << 
"m" << flush;
   178                         if (recordType==
"SIMULATOR_POS"){
   180                                 cout << 
"t" << flush;
   182                         if (recordType==
"RESAMPLE"){
   184                                 cout << 
"r" << flush;
   186                         if (recordType==
"NEFF"){
   188                                 cout << 
"n" << flush;
   190                         if (recordType==
"COMMENT"){
   192                                 cout << 
"c" << flush;
   195                                 rec->
read(lineStream);
   204                 unsigned int currentIndex=i;
   205                 for(RecordList::const_reverse_iterator it=rbegin(); it!=rend(); it++){
   208                                 weight+=scanmatch->
weights[currentIndex];
   212                                 currentIndex=resample->
indexes[currentIndex];
   221                 const_reverse_iterator it=rbegin();
   226                 unsigned int dim=scanmatch->
dim;
   229                 unsigned int best=scanmatch->
dim+1;
   230                 for (
unsigned i=0; i<dim; i++){
   231                         double w=getLogWeight(i);
   241                 unsigned int currentIndex=i;
   247                 for(RecordList::const_reverse_iterator it=rbegin(); it!=rend(); it++){
   257                                 p=pose->
pose=scanmatch->
poses[currentIndex];
   264                                 p=pose->
pose=odometry->
poses[currentIndex];
   277                                 rl.push_front(claser);
   282                                 rl.push_front(ccomment);
   286                                 currentIndex=resample->
indexes[currentIndex];
   292                 double ox=0, oy=0, rxx=0, rxy=0, ryx=0, ryy=0, rth=0;
   293                 bool computedTransformation=
false;
   294                 bool truePosFound=
false;
   299                 unsigned int count=0;
   300                 for(RecordList::iterator it=rl.begin(); it!=rl.end(); it++){
   303                                 neff=neffr->
neff/(double)sampleSize;
   304                         started=started || 
dynamic_cast<const LaserRecord*
>(*it)?
true:
false;
   305                         if (started && ! truePosFound){
   310                                         truePose=tpose->
pose;
   315                         if (started && truePosFound && ! computedTransformation){
   320                                         double s=sin(rth), 
c=cos(rth);
   323                                         ox=truePose.
x-(rxx*pose.
x+rxy*pose.
y);
   324                                         oy=truePose.
y-(ryx*pose.
x+ryy*pose.
y);
   325                                         computedTransformation=
true;
   333                                 os << 
"MARK-POS 0 0: " <<currPose.
x*100 << 
" " << currPose.
y*100 << 
" 0 " << count++ << endl;
   335                         if (computedTransformation){
   345                                                         double ex, ey, eth=truePose.
theta-pose.
theta-rth;
   346                                                         ex=truePose.
x-(ox+rxx*pose.
x+rxy*pose.
y);
   347                                                         ey=truePose.
y-(oy+ryx*pose.
x+ryy*pose.
y);
   348                                                         eth=atan2(sin(eth), cos(eth));
   352                                                            << ex << 
" " << ey << 
" " << eth 
   353                                                            << 
" " << sqrt(ex*ex+ey*ey) << 
" " << fabs(eth) << endl;
   372 int main (
int argc, 
const char * 
const * argv){
   374                 cout << 
"usage gfs2rec [-err] <infilename> <outfilename>" << endl;
   380         if (!strcmp(argv[c],
"-err")){
   384         if (!strcmp(argv[c],
"-neff")){
   388         ifstream 
is(argv[c]);
   390                 cout << 
"could read file "<< endl;
   397         cout << endl << 
"best index = " <<  bestidx<< endl;
   398         ofstream os(argv[c]);
   400                 cout << 
"could write file "<< endl;
 
virtual void read(istream &is)
virtual void write(ostream &os)
virtual void read(istream &is)
vector< OrientedPoint > poses
double getLogWeight(unsigned int i) const
void resample(std::vector< int > &indexes, const WeightVector &weights, unsigned int nparticles=0)
virtual void write(ostream &os)
vector< double > readings
virtual void write(ostream &os)
virtual void write(ostream &os)
virtual void read(istream &is)=0
virtual void read(istream &is)
istream & read(istream &is)
vector< OrientedPoint > poses
virtual void read(istream &is)
PoseRecord(bool ideal=false)
int main(int argc, conat char **argv)
vector< unsigned int > indexes
void printPath(ostream &os, unsigned int i, bool err=false) const
unsigned int getBestIdx() const