Update of /cvsroot/playerstage/code/player/utils/pmap
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3452

Modified Files:
      Tag: release-2-0-patches
        logfile.cpp pmap_test.cpp 
Log Message:
fixed logfile parser to really skip irrelevant lines

Index: pmap_test.cpp
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/pmap/pmap_test.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** pmap_test.cpp       7 Jun 2006 16:12:59 -0000       1.1.2.2
--- pmap_test.cpp       24 Jan 2007 18:25:11 -0000      1.1.2.3
***************
*** 427,435 ****
    while (1)
    {
!     if (logfile_read(logfile) != 0)
      {
        fprintf(stderr, "\n");
        return -1;
      }
      
      if (start_time == 0.0 && logfile->dtime > 0.0)
--- 427,438 ----
    while (1)
    {
!     int logresult = logfile_read(logfile); 
!     if (logresult < 0)
      {
        fprintf(stderr, "\n");
        return -1;
      }
+     else if(logresult > 0)
+       continue;
      
      if (start_time == 0.0 && logfile->dtime > 0.0)

Index: logfile.cpp
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/pmap/logfile.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** logfile.cpp 7 Jun 2006 16:12:58 -0000       1.1.2.2
--- logfile.cpp 24 Jan 2007 18:25:11 -0000      1.1.2.3
***************
*** 21,25 ****
  
    self = new logfile_t;
!   
    // Open logfile
    self->file = fopen(filename, "r");
--- 21,25 ----
  
    self = new logfile_t;
! 
    // Open logfile
    self->file = fopen(filename, "r");
***************
*** 31,39 ****
  
    self->eof = 0;
!   
    // Allocate space for lines
    self->line_size = 2 * 1024 * 1024;
    self->line = new char[self->line_size];
!   
    return self;
  }
--- 31,39 ----
  
    self->eof = 0;
! 
    // Allocate space for lines
    self->line_size = 2 * 1024 * 1024;
    self->line = new char[self->line_size];
! 
    return self;
  }
***************
*** 44,48 ****
  {
    int i, len;
!   
    // Read in a line
    self->line = fgets(self->line, self->line_size, self->file);
--- 44,48 ----
  {
    int i, len;
! 
    // Read in a line
    self->line = fgets(self->line, self->line_size, self->file);
***************
*** 52,58 ****
      return -1;
    }
!   
    self->linenum++;
!   
    // Tokenize the line using whitespace separators
    self->token_count = 0;
--- 52,58 ----
      return -1;
    }
! 
    self->linenum++;
! 
    // Tokenize the line using whitespace separators
    self->token_count = 0;
***************
*** 75,99 ****
  
    self->interface = "";
!   
    // Skip blank lines
    if (self->token_count == 0)
!     return 0;
!     
    // Discard comments
    if (strcmp(self->tokens[0], "#") == 0 || strcmp(self->tokens[0], "##") == 0)
!     return 0;
  
    assert(self->token_count >= 3);
    self->interface = self->tokens[3];
!   
    // Skip sync packets
    if (strcmp(self->interface, "sync") == 0)
!     return 0;
!   
    assert(self->token_count >= 5);
    self->index = atoi(self->tokens[4]);
    self->dtime = atof(self->tokens[0]);
  
!   if (strcmp(self->interface, "position3d") == 0)
    {
      // HACK
--- 75,99 ----
  
    self->interface = "";
! 
    // Skip blank lines
    if (self->token_count == 0)
!     return 1;
! 
    // Discard comments
    if (strcmp(self->tokens[0], "#") == 0 || strcmp(self->tokens[0], "##") == 0)
!     return 1;
  
    assert(self->token_count >= 3);
    self->interface = self->tokens[3];
! 
    // Skip sync packets
    if (strcmp(self->interface, "sync") == 0)
!     return 1;
! 
    assert(self->token_count >= 5);
    self->index = atoi(self->tokens[4]);
    self->dtime = atof(self->tokens[0]);
  
!   /*if (strcmp(self->interface, "position3d") == 0)
    {
      // HACK
***************
*** 103,129 ****
      self->position_pose[2] = atof(self->tokens[11]);
    }
!   else if (strcmp(self->interface, "position2d") == 0)
    {
!     assert(self->token_count >= 9);
      self->position_pose[0] = atof(self->tokens[7]);
      self->position_pose[1] = atof(self->tokens[8]);
      self->position_pose[2] = atof(self->tokens[9]);
    }
!   else if (strcmp(self->interface, "gps") == 0)
    {
      assert(self->token_count >= 12);
      self->gps_pos[0] = atof(self->tokens[10]);
      self->gps_pos[1] = atof(self->tokens[11]);
!   }
    else if (strcmp(self->interface, "laser") == 0)
    {
!     assert(self->token_count >= 13);    
      self->laser_range_count = atoi(self->tokens[12]);
!     assert(self->token_count >= 13 + self->laser_range_count * 2);    
  
      for (i = 0; i < self->laser_range_count; i++)
        self->laser_ranges[i] = atof(self->tokens[13 + i * 2]);
    }
!   
    return 0;
  }
--- 103,135 ----
      self->position_pose[2] = atof(self->tokens[11]);
    }
!   else */if (strcmp(self->interface, "position2d") == 0)
    {
!     // Ignore anything but PLAYER_POSITION2D_DATA_STATE messages
!     if (atoi(self->tokens[5]) != 1 || atoi(self->tokens[6]) != 1)
!       return 1;
!     assert(self->token_count >= 14);
      self->position_pose[0] = atof(self->tokens[7]);
      self->position_pose[1] = atof(self->tokens[8]);
      self->position_pose[2] = atof(self->tokens[9]);
    }
!   /*else if (strcmp(self->interface, "gps") == 0)
    {
      assert(self->token_count >= 12);
      self->gps_pos[0] = atof(self->tokens[10]);
      self->gps_pos[1] = atof(self->tokens[11]);
!   }*/
    else if (strcmp(self->interface, "laser") == 0)
    {
!     // Ignore anything but PLAYER_LASER_DATA_SCAN messages
!     if (atoi(self->tokens[5]) != 1 || atoi(self->tokens[6]) != 1)
!       return 1;
!     assert(self->token_count >= 13);
      self->laser_range_count = atoi(self->tokens[12]);
!     assert(self->token_count >= 13 + self->laser_range_count * 2);
  
      for (i = 0; i < self->laser_range_count; i++)
        self->laser_ranges[i] = atof(self->tokens[13 + i * 2]);
    }
! 
    return 0;
  }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to