Revision: 8196
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8196&view=rev
Author:   rtv
Date:     2009-08-13 01:06:05 +0000 (Thu, 13 Aug 2009)

Log Message:
-----------
tweaked fiducial vis. working on lights

Modified Paths:
--------------
    code/stage/trunk/libstage/block.cc
    code/stage/trunk/libstage/model_fiducial.cc
    code/stage/trunk/libstage/model_laser.cc
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/worlds/chatterbox.inc

Modified: code/stage/trunk/libstage/block.cc
===================================================================
--- code/stage/trunk/libstage/block.cc  2009-08-11 21:04:09 UTC (rev 8195)
+++ code/stage/trunk/libstage/block.cc  2009-08-13 01:06:05 UTC (rev 8196)
@@ -13,7 +13,7 @@
                                  stg_meters_t zmin,
                                  stg_meters_t zmax,
                                  Color color,
-                                 bool inherit_color
+                                 bool inherit_color                            
  
                                  ) :
   mod( mod ),
   mpts(),
@@ -22,6 +22,7 @@
   local_z( zmin, zmax ),
   color( color ),
   inherit_color( inherit_color ),
+  glow( 0.0 ),
   rendered_cells( new CellPtrVec ), 
   candidate_cells( new CellPtrVec ),
   gpts()
@@ -32,21 +33,21 @@
   // copy the argument point data into the member vector
   this->pts.reserve( pt_count );
   for( size_t p=0; p<pt_count; p++ )
-       this->pts.push_back( pts[p] );  
+        this->pts.push_back( pts[p] ); 
 }
 
 /** A from-file  constructor */
 Block::Block(  Model* mod,
-                          Worldfile* wf,
-                          int entity)
+                                       Worldfile* wf,
+                                       int entity)
   : mod( mod ),
-       mpts(),
+        mpts(),
     pt_count(0),
     pts(),
     color(0),
     inherit_color(true),
-       rendered_cells( new CellPtrVec ), 
-       candidate_cells( new CellPtrVec ) 
+        rendered_cells( new CellPtrVec ), 
+        candidate_cells( new CellPtrVec ) 
 {
   assert(mod);
   assert(wf);
@@ -405,10 +406,7 @@
   DrawTop();
   glDisable(GL_POLYGON_OFFSET_FILL);
   
-  //   // draw the block outline in a darker version of the same color
-  //double r,g,b,a;
-  //stg_color_unpack( col, &r, &g, &b, &a );
-  //mod->PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a ));
+  // draw the block outline in a darker version of the same color
   mod->PushColor( Color( col.r/2.0, col.g/2.0, col.b/2.0, col.a ));
   
   glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
@@ -417,7 +415,12 @@
   DrawSides();
   glDepthMask(GL_TRUE);
   glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-  
+ 
+  if( glow > 0.0 )
+        {
+               
+        }
+ 
   mod->PopColor();
   mod->PopColor();
 }
@@ -457,4 +460,6 @@
     }
   else
     inherit_color = true;
+
+  glow = wf->ReadFloat( entity, "glow", glow );
 }

Modified: code/stage/trunk/libstage/model_fiducial.cc
===================================================================
--- code/stage/trunk/libstage/model_fiducial.cc 2009-08-11 21:04:09 UTC (rev 
8195)
+++ code/stage/trunk/libstage/model_fiducial.cc 2009-08-13 01:06:05 UTC (rev 
8196)
@@ -25,7 +25,8 @@
 static const stg_watts_t DEFAULT_WATTS = 10.0;
 
 //TODO make instance attempt to register an option (as customvisualizations do)
-Option ModelFiducial::showFiducialData( "Fiducials", "show_fiducial", "", 
true, NULL );
+Option ModelFiducial::showData( "Fiducials", "show_fiducial", "", true, NULL );
+Option ModelFiducial::showFov( "Fiducial FOV", "show_fiducial_fov", "", false, 
NULL );
 
 /** 
   @ingroup model
@@ -65,34 +66,35 @@
   the angular field of view of the scanner, in radians.
 
  */
-
-ModelFiducial::ModelFiducial( World* world, 
-                                                                               
                Model* parent )
-  : Model( world, parent, MODEL_TYPE_FIDUCIAL ),
-       fiducials(),
-       max_range_anon( DEFAULT_RANGEMAXANON ),
-       max_range_id( DEFAULT_RANGEMAXID ),
-       min_range( DEFAULT_RANGEMIN ),
-       fov( DEFAULT_FOV ),
-       heading( 0 ),
-       key( 0 )
+  
+  ModelFiducial::ModelFiducial( World* world, 
+                                                                               
  Model* parent ) : 
+  Model( world, parent, MODEL_TYPE_FIDUCIAL ),
+  fiducials(),
+  max_range_anon( DEFAULT_RANGEMAXANON ),
+  max_range_id( DEFAULT_RANGEMAXID ),
+  min_range( DEFAULT_RANGEMIN ),
+  fov( DEFAULT_FOV ),
+  heading( 0 ),
+  key( 0 )
 {
-       //PRINT_DEBUG2( "Constructing ModelFiducial %d (%s)\n", 
-       //              id, typestr );
-
-       // assert that Update() is reentrant for this derived model
-       thread_safe = true;
-       
-       // sensible fiducial defaults 
-       //  interval = 200; // common for a SICK LMS200
-
-       this->ClearBlocks();
-
-       Geom geom;
-       memset( &geom, 0, sizeof(geom));
-       SetGeom( geom );
-
-       RegisterOption( &showFiducialData );
+  //PRINT_DEBUG2( "Constructing ModelFiducial %d (%s)\n", 
+  //           id, typestr );
+  
+  // assert that Update() is reentrant for this derived model
+  thread_safe = true;
+  
+  // sensible fiducial defaults 
+  //  interval = 200; // common for a SICK LMS200
+  
+  this->ClearBlocks();
+  
+  Geom geom;
+  geom.Zero();
+  SetGeom( geom );
+  
+  RegisterOption( &showData );
+  RegisterOption( &showFov );
 }
 
 ModelFiducial::~ModelFiducial( void )
@@ -239,67 +241,69 @@
 
 void ModelFiducial::DataVisualize( Camera* cam )
 {
-       if ( !showFiducialData )
-               return;
+       if( showFov )
+         {
+                PushColor( 1,0,1,0.2  ); // magenta, with a bit of alpha
 
-       PushColor( 1,0,1,0.7  ); // magenta, with a bit of alpha
+                GLUquadric* quadric = gluNewQuadric();
+                
+                gluQuadricDrawStyle( quadric, GLU_SILHOUETTE );
+                
+                gluPartialDisk( quadric,
+                                                         0, 
+                                                         max_range_anon,
+                                                         20, // slices 
+                                                         1, // loops
+                                                         rtod( M_PI/2.0 + 
fov/2.0), // start angle
+                                                         rtod(-fov) ); // 
sweep angle
+                
+                gluDeleteQuadric( quadric );
+
+                PopColor();
+         }
        
-       // draw the FOV
-//     GLUquadric* quadric = gluNewQuadric();
-//     gluQuadricDrawStyle( quadric, GLU_SILHOUETTE );
-       
-//     gluPartialDisk( quadric,
-//                                                                     0, 
-//                                                                     
max_range_anon,
-//                                                                     20, // 
slices   
-//                                                                     1, // 
loops
-//                                                                     rtod( 
M_PI/2.0 + fov/2.0), // start angle
-//                                                                     
rtod(-fov) ); // sweep angle
-       
-//     gluDeleteQuadric( quadric );
-
-       // draw fuzzy dotted lines      
-       glLineWidth( 2.0 );
-       glLineStipple( 1, 0x00FF );
-
-       // draw lines to the fiducials
-       for( unsigned int f=0; f<fiducials.size(); f++ )
-               {
-                       Fiducial& fid = fiducials[f];
-                                               
-                       double dx = fid.range * cos( fid.bearing);
-                       double dy = fid.range * sin( fid.bearing);
-                       
-                       
-                       glEnable(GL_LINE_STIPPLE);
-                       glBegin( GL_LINES );
-                       glVertex2f( 0,0 );
-                       glVertex2f( dx, dy );
-                       glEnd();
-                       glDisable(GL_LINE_STIPPLE);
-        
-                       PushColor( 1,0,1,1  ); // magenta, no alpha
-
-                       glPushMatrix();
-                       Gl::coord_shift( dx,dy,0,fid.geom.a );
-                       
-                       glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
-                       glRectf( -fid.geom.x/2.0, -fid.geom.y/2.0,
-                                                        fid.geom.x/2.0, 
fid.geom.y/2.0 );
-                       
-                       // show the fiducial ID
-                       char idstr[32];
-                       snprintf(idstr, 31, "%d", fid.id );
-                       Gl::draw_string( 0,0,0, idstr );
-
-                       PopColor();
-                       
-                       glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-                       glPopMatrix();                  
-               }
-                                
-        PopColor();                     
-   glLineWidth( 1.0 );                  
+       if( showData )
+         {
+                PushColor( 1,0,1,0.4  ); // magenta, with a bit of alpha
+                
+                // draw fuzzy dotted lines     
+                glLineWidth( 2.0 );
+                glLineStipple( 1, 0x00FF );
+                
+                // draw lines to the fiducials
+                for( unsigned int f=0; f<fiducials.size(); f++ )
+                       {
+                         Fiducial& fid = fiducials[f];
+                         
+                         double dx = fid.range * cos( fid.bearing);
+                         double dy = fid.range * sin( fid.bearing);
+                         
+                         glEnable(GL_LINE_STIPPLE);
+                         glBegin( GL_LINES );
+                         glVertex2f( 0,0 );
+                         glVertex2f( dx, dy );
+                         glEnd();
+                         glDisable(GL_LINE_STIPPLE);
+                                                 
+                         glPushMatrix();
+                         Gl::coord_shift( dx,dy,0,fid.geom.a );
+                         
+                         glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
+                         glRectf( -fid.geom.x/2.0, -fid.geom.y/2.0,
+                                                 fid.geom.x/2.0, 
fid.geom.y/2.0 );
+                         
+                         // show the fiducial ID
+                         char idstr[32];
+                         snprintf(idstr, 31, "%d", fid.id );
+                         Gl::draw_string( 0,0,0, idstr );
+                         
+                         glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+                         glPopMatrix();                        
+                       }
+                
+                PopColor();                     
+                glLineWidth( 1.0 );            
+         }      
 }
        
 void ModelFiducial::Shutdown( void )

Modified: code/stage/trunk/libstage/model_laser.cc
===================================================================
--- code/stage/trunk/libstage/model_laser.cc    2009-08-11 21:04:09 UTC (rev 
8195)
+++ code/stage/trunk/libstage/model_laser.cc    2009-08-13 01:06:05 UTC (rev 
8196)
@@ -330,7 +330,6 @@
          laser->PushColor( 0, 0, 1, 0.1 );             
          glDrawArrays( GL_POLYGON, 0, sample_count+1 );
          laser->PopColor();  
-         //glDepthMask( GL_TRUE );
        }
   
   glDepthMask( GL_TRUE );
@@ -356,7 +355,6 @@
          laser->PushColor( 0, 0, 1, 0.5 );             
          glDrawArrays( GL_POLYGON, 0, sample_count+1 );
          laser->PopColor();
-         //                     glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
        }                        
   
   if( showBeams )

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-08-11 21:04:09 UTC (rev 8195)
+++ code/stage/trunk/libstage/stage.hh  2009-08-13 01:06:05 UTC (rev 8196)
@@ -114,10 +114,10 @@
     MODEL_TYPE_BLOBFINDER,
     MODEL_TYPE_BLINKENLIGHT,
     MODEL_TYPE_CAMERA,
-               MODEL_TYPE_GRIPPER,
-               MODEL_TYPE_ACTUATOR,
-               MODEL_TYPE_LOADCELL,
-               MODEL_TYPE_LIGHTINDICATOR,
+        MODEL_TYPE_GRIPPER,
+        MODEL_TYPE_ACTUATOR,
+        MODEL_TYPE_LOADCELL,
+        MODEL_TYPE_LIGHTINDICATOR,
     MODEL_TYPE_COUNT // must be the last entry, to count the number of types
   } stg_model_type_t;
        
@@ -262,6 +262,9 @@
        
        void Load( Worldfile* wf, int section, const char* keyword );
        void Save( Worldfile* wf, int section, const char* keyword );
+        
+        void Zero()
+        { x=y=z=0.0; }
   };
   
   /** Specify a 3 axis position, in x, y and heading. */
@@ -385,6 +388,12 @@
 
         /** construct from a prior pose and size */
         Geom( const Pose& p, const Size& s ) : pose(p), size(s) {}
+        
+        void Zero()
+        {
+               pose.Zero();
+               size.Zero();
+        }
   };
   
   /** Specify a point in space. Arrays of Waypoints can be attached to
@@ -1159,26 +1168,22 @@
                
   private:
     Model* mod; ///< model to which this block belongs
-
-               std::vector<stg_point_t> mpts; ///< cache of this->pts in model 
coordindates
-    size_t pt_count; ///< the number of points
-
-               std::vector<stg_point_t> pts; ///< points defining a polygonx
-    //stg_point_t* pts; ///< points defining a polygon
-        
-    Size size;
-        
+        std::vector<stg_point_t> mpts; ///< cache of this->pts in model 
coordindates
+    size_t pt_count; ///< the number of points  
+        std::vector<stg_point_t> pts; ///< points defining a polygonx   
+    Size size;  
     Bounds local_z; ///<  z extent in local coords
-
     Color color;
     bool inherit_color;
         
+        /** experimental - range 0 - 1, render glowing */
+        double glow;
+        
     void DrawTop();
     void DrawSides();
         
     /** z extent in global coordinates */
-    Bounds global_z;
-        
+    Bounds global_z;    
     bool mapped;
         
     /** record the cells into which this block has been rendered to
@@ -2684,10 +2689,11 @@
         virtual void Update();
         virtual void DataVisualize( Camera* cam );
 
-        static Option showFiducialData;
+        static Option showData;
+        static Option showFov;
+        
+        std::vector<Fiducial> fiducials;
                
-               std::vector<Fiducial> fiducials;
-               
   public:              
                ModelFiducial( World* world, Model* parent );
                virtual ~ModelFiducial();

Modified: code/stage/trunk/worlds/chatterbox.inc
===================================================================
--- code/stage/trunk/worlds/chatterbox.inc      2009-08-11 21:04:09 UTC (rev 
8195)
+++ code/stage/trunk/worlds/chatterbox.inc      2009-08-13 01:06:05 UTC (rev 
8196)
@@ -11,7 +11,6 @@
  joules 100000 # todo
  joules_capacity 400000 # todo
  watts 100 # todo
- obstacle_return 0
  
 # charging connection
  model


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to