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

Modified Files:
        playerv.h pv_dev_bumper.c pv_dev_ir.c pv_dev_laser.c 
        pv_dev_map.c pv_dev_ranger.c pv_dev_sonar.c 
Log Message:
applied Toby's patch to replace fixed-size arrays

Index: pv_dev_map.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_map.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pv_dev_map.c        17 Oct 2007 20:28:36 -0000      1.2
--- pv_dev_map.c        1 Nov 2007 22:16:23 -0000       1.3
***************
*** 93,100 ****
        if (playerc_map_subscribe(map->proxy, PLAYER_OPEN_MODE) != 0)
          PRINT_ERR1("libplayerc error: %s", playerc_error_str());
-       
        // download a map
!       playerc_map_get_map( map->proxy );
!       map_draw( map );
      }
    }
--- 93,99 ----
        if (playerc_map_subscribe(map->proxy, PLAYER_OPEN_MODE) != 0)
          PRINT_ERR1("libplayerc error: %s", playerc_error_str());
        // download a map
!       if (playerc_map_get_map( map->proxy ) >= 0)     
!         map_draw( map );
      }
    }

Index: pv_dev_bumper.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_bumper.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pv_dev_bumper.c     17 Sep 2007 02:18:50 -0000      1.1
--- pv_dev_bumper.c     1 Nov 2007 22:16:23 -0000       1.2
***************
*** 55,58 ****
--- 55,59 ----
    bumper->drivername = strdup(drivername);
    bumper->datatime = 0;
+   bumper->mainwnd = mainwnd;
  
    snprintf(section, sizeof(section), "bumper:%d", index);
***************
*** 67,77 ****
    rtk_menuitem_check(bumper->subscribe_item, subscribe);
  
!   // Construct figures
!   for (i = 0; i < PLAYERC_BUMPER_MAX_SAMPLES; i++)
!     bumper->scan_fig[i] = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 
1);
! 
    return bumper;
  }
  
  
  // Destroy a bumper device
--- 68,88 ----
    rtk_menuitem_check(bumper->subscribe_item, subscribe);
  
!   bumper->fig_count = 0;
    return bumper;
  }
  
+ void bumper_allocate_figures(bumper_t * bumper, int fig_count)
+ {
+   int i;
+   if (bumper->fig_count <= fig_count)
+     return;
+   bumper->scan_fig = 
realloc(bumper->scan_fig,fig_count*sizeof(bumper->scan_fig[0]));
+   
+   // Construct figures
+   for (i = bumper->fig_count; i < fig_count; i++)
+     bumper->scan_fig[i] = rtk_fig_create(bumper->mainwnd->canvas, 
bumper->mainwnd->robot_fig, 1);
+   bumper->fig_count = fig_count;
+ }
+ 
  
  // Destroy a bumper device
***************
*** 84,89 ****
    playerc_bumper_destroy(bumper->proxy);
  
!   for (i = 0; i < PLAYERC_BUMPER_MAX_SAMPLES; i++)
      rtk_fig_destroy(bumper->scan_fig[i]);
  
    rtk_menuitem_destroy(bumper->subscribe_item);
--- 95,101 ----
    playerc_bumper_destroy(bumper->proxy);
  
!   for (i = 0; i < bumper->fig_count; i++)
      rtk_fig_destroy(bumper->scan_fig[i]);
+   free(bumper->scan_fig);
  
    rtk_menuitem_destroy(bumper->subscribe_item);
***************
*** 112,115 ****
--- 124,128 ----
          PRINT_ERR1("get_geom failed : %s", playerc_error_str());    
  
+       bumper_allocate_figures(bumper, bumper->proxy->pose_count);
        for (i = 0; i < bumper->proxy->pose_count; i++){
          //fprintf(stderr, "bumper poses %02d: %f %f %f %f 
%f\n",i,bumper->proxy->poses[i][0],bumper->proxy->poses[i][1],bumper->proxy->poses[i][2],bumper->proxy->poses[i][3],bumper->proxy->poses[i][4]);

Index: playerv.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/playerv.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** playerv.h   20 Aug 2007 19:42:49 -0000      1.50
--- playerv.h   1 Nov 2007 22:16:23 -0000       1.51
***************
*** 186,190 ****
  
     // Figures for drawing the bumper
!    rtk_fig_t *scan_fig[PLAYERC_BUMPER_MAX_SAMPLES];
  
     // Bumper device proxy
--- 186,192 ----
  
     // Figures for drawing the bumper
!    rtk_fig_t **scan_fig;
!    int fig_count;
!    mainwnd_t *mainwnd;
  
     // Bumper device proxy
***************
*** 473,477 ****
  
    // Figures for drawing the sonar scan
!   rtk_fig_t *scan_fig[PLAYERC_SONAR_MAX_SAMPLES];
  
    // Sonar device proxy
--- 475,481 ----
  
    // Figures for drawing the sonar scan
!   rtk_fig_t **scan_fig;
!   int fig_count;
!   mainwnd_t *mainwnd;
  
    // Sonar device proxy
***************
*** 512,516 ****
  
    // Figures for drawing the sonar scan
!   rtk_fig_t *scan_fig[PLAYERC_IR_MAX_SAMPLES];
  
    // Sonar device proxy
--- 516,522 ----
  
    // Figures for drawing the sonar scan
!   rtk_fig_t **scan_fig;
!   int fig_count;
!   mainwnd_t *mainwnd;
  
    // Sonar device proxy

Index: pv_dev_sonar.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_sonar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pv_dev_sonar.c      17 Sep 2007 02:18:50 -0000      1.1
--- pv_dev_sonar.c      1 Nov 2007 22:16:23 -0000       1.2
***************
*** 57,60 ****
--- 57,61 ----
    sonar->drivername = strdup(drivername);
    sonar->datatime = 0;
+   sonar->mainwnd = mainwnd;
  
    snprintf(section, sizeof(section), "sonar:%d", index);
***************
*** 69,79 ****
    rtk_menuitem_check(sonar->subscribe_item, subscribe);
  
!   // Construct figures
!   for (i = 0; i < PLAYERC_SONAR_MAX_SAMPLES; i++)
!     sonar->scan_fig[i] = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 
1);
  
    return sonar;
  }
  
  
  // Destroy a sonar device
--- 70,91 ----
    rtk_menuitem_check(sonar->subscribe_item, subscribe);
  
!   sonar->fig_count = 0;
  
    return sonar;
  }
  
+ void sonar_allocate_figures(sonar_t * sonar, int fig_count)
+ {
+   int i;
+   if (fig_count <= sonar->fig_count)
+     return;
+   sonar->scan_fig = 
realloc(sonar->scan_fig,fig_count*sizeof(sonar->scan_fig[0]));
+   
+   // Construct figures
+   for (i = sonar->fig_count; i < fig_count; i++)
+         sonar->scan_fig[i] = rtk_fig_create(sonar->mainwnd->canvas, 
sonar->mainwnd->robot_fig, 1);
+   sonar->fig_count = fig_count;
+ }
+ 
  
  // Destroy a sonar device
***************
*** 86,90 ****
    playerc_sonar_destroy(sonar->proxy);
  
!   for (i = 0; i < PLAYERC_SONAR_MAX_SAMPLES; i++)
      rtk_fig_destroy(sonar->scan_fig[i]);
  
--- 98,102 ----
    playerc_sonar_destroy(sonar->proxy);
  
!   for (i = 0; i < sonar->fig_count; i++)
      rtk_fig_destroy(sonar->scan_fig[i]);
  
***************
*** 149,157 ****
  {
    int i;
!       for (i = 0; i < sonar->proxy->pose_count; i++)
!         rtk_fig_origin(sonar->scan_fig[i],
!                        sonar->proxy->poses[i].px,
!                        sonar->proxy->poses[i].py,
!                        sonar->proxy->poses[i].pyaw);
  }
  
--- 161,171 ----
  {
    int i;
!   sonar_allocate_figures(sonar, sonar->proxy->pose_count);
!   for (i = 0; i < sonar->proxy->pose_count; i++)
!     rtk_fig_origin(sonar->scan_fig[i],
!       sonar->proxy->poses[i].px,
!       sonar->proxy->poses[i].py,
!       sonar->proxy->poses[i].pyaw
!     );
  }
  

Index: pv_dev_laser.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_laser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pv_dev_laser.c      17 Sep 2007 02:18:50 -0000      1.1
--- pv_dev_laser.c      1 Nov 2007 22:16:23 -0000       1.2
***************
*** 225,229 ****
    double r, b, res;
    int point_count;
!   double points[PLAYERC_LASER_MAX_SAMPLES + 1][2];
    rtk_fig_show(laser->scan_fig, 1);      
    rtk_fig_clear(laser->scan_fig);
--- 225,229 ----
    double r, b, res;
    int point_count;
!   double (*points)[2];
    rtk_fig_show(laser->scan_fig, 1);      
    rtk_fig_clear(laser->scan_fig);
***************
*** 253,270 ****
            
      // Draw in the range scan (empty space)
!     point_count = 0;
!     points[point_count][0] = 0;
!     points[point_count][1] = 0;    
!     point_count++;
      for (i = 0; i < laser->proxy->scan_count; i++)
      {      
        r = laser->proxy->scan[i][0];
        b = laser->proxy->scan[i][1];
!       points[point_count][0] = r * cos(b - res);
!       points[point_count][1] = r * sin(b - res);
!       point_count++;
      }
      rtk_fig_color_rgb32(laser->scan_fig, COLOR_LASER_EMP);
!     rtk_fig_polygon(laser->scan_fig, 0, 0, 0, point_count, points, 1);
                
      // Draw in the range scan (occupied space)
--- 253,268 ----
            
      // Draw in the range scan (empty space)
!     points = calloc(laser->proxy->scan_count,sizeof(double)*2);
      for (i = 0; i < laser->proxy->scan_count; i++)
      {      
        r = laser->proxy->scan[i][0];
        b = laser->proxy->scan[i][1];
!       points[i][0] = r * cos(b - res);
!       points[i][1] = r * sin(b - res);
      }
      rtk_fig_color_rgb32(laser->scan_fig, COLOR_LASER_EMP);
!     rtk_fig_polygon(laser->scan_fig, 0, 0, 0, laser->proxy->scan_count, 
points, 1);
!     free(points);
!     points = NULL;
                
      // Draw in the range scan (occupied space)

Index: pv_dev_ir.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_ir.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pv_dev_ir.c 17 Sep 2007 02:18:50 -0000      1.1
--- pv_dev_ir.c 1 Nov 2007 22:16:23 -0000       1.2
***************
*** 55,58 ****
--- 55,59 ----
    ir->drivername = strdup(drivername);
    ir->datatime = 0;
+   ir->mainwnd = mainwnd;
  
    snprintf(section, sizeof(section), "ir:%d", index);
***************
*** 67,73 ****
    rtk_menuitem_check(ir->subscribe_item, subscribe);
  
!   // Construct figures
!   for (i = 0; i < PLAYERC_IR_MAX_SAMPLES; i++)
!     ir->scan_fig[i] = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 1);
  
    return ir;
--- 68,72 ----
    rtk_menuitem_check(ir->subscribe_item, subscribe);
  
!   ir->fig_count = 0;
  
    return ir;
***************
*** 75,78 ****
--- 74,91 ----
  
  
+ void ir_allocate_figures(ir_t * ir, int fig_count)
+ {
+   int i;
+   if (ir->fig_count <= fig_count)
+     return;
+   ir->scan_fig = realloc(ir->scan_fig,fig_count*sizeof(ir->scan_fig[0]));
+   
+   // Construct figures
+   for (i = ir->fig_count; i < fig_count; i++)
+         ir->scan_fig[i] = rtk_fig_create(ir->mainwnd->canvas, 
ir->mainwnd->robot_fig, 1);
+   ir->fig_count = fig_count;
+ }
+ 
+ 
  // Destroy an ir device
  void ir_destroy(ir_t *ir)
***************
*** 84,89 ****
    playerc_ir_destroy(ir->proxy);
  
!   for (i = 0; i < PLAYERC_IR_MAX_SAMPLES; i++)
      rtk_fig_destroy(ir->scan_fig[i]);
  
    rtk_menuitem_destroy(ir->subscribe_item);
--- 97,103 ----
    playerc_ir_destroy(ir->proxy);
  
!   for (i = 0; i < ir->fig_count; i++)
      rtk_fig_destroy(ir->scan_fig[i]);
+   free(ir->scan_fig);
  
    rtk_menuitem_destroy(ir->subscribe_item);
***************
*** 112,115 ****
--- 126,130 ----
          PRINT_ERR1("get_geom failed : %s", playerc_error_str());    
  
+       ir_allocate_figures(ir, ir->proxy->poses.poses_count);
        for (i = 0; i < ir->proxy->poses.poses_count; i++)
          {

Index: pv_dev_ranger.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/playerv/pv_dev_ranger.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pv_dev_ranger.c     18 Oct 2007 22:52:53 -0000      1.2
--- pv_dev_ranger.c     1 Nov 2007 22:16:23 -0000       1.3
***************
*** 193,197 ****
    int ii = 0, jj = 0;
    int point_count;
!   double point1[2], point2[2], points[PLAYER_LASER_MAX_SAMPLES + 1][2];
    double current_angle = 0.0f, temp = 0.0f;
    unsigned int ranges_per_sensor = 0;
--- 193,198 ----
    int ii = 0, jj = 0;
    int point_count;
!   double point1[2], point2[2]; 
!   double (*points)[2];
    double current_angle = 0.0f, temp = 0.0f;
    unsigned int ranges_per_sensor = 0;
***************
*** 212,215 ****
--- 213,217 ----
    {
      // Draw sonar-like
+     points = calloc(3, sizeof(double)*2);
      temp = 20.0f * M_PI / 180.0f / 2.0f;
      for (ii = 0; ii < ranger->proxy->sensor_count; ii++)
***************
*** 233,236 ****
--- 235,240 ----
        rtk_fig_rectangle(ranger->scan_fig[ii], 0, 0, 0, 
ranger->proxy->sensor_sizes[ii].sw, ranger->proxy->sensor_sizes[ii].sl, 0);
      }
+     free(points);
+     points=NULL;
    }
    else
***************
*** 240,243 ****
--- 244,248 ----
      {
        // Draw each sensor in turn
+       points = calloc(ranger->proxy->sensor_count, sizeof(double)*2);
        for (ii = 0; ii < ranger->proxy->sensor_count; ii++)
        {
***************
*** 272,275 ****
--- 277,282 ----
          }
        }
+       free(points);
+       points = NULL;
      }
      else


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to