Revision: 7185 http://playerstage.svn.sourceforge.net/playerstage/?rev=7185&view=rev Author: rtv Date: 2008-12-02 02:30:04 +0000 (Tue, 02 Dec 2008)
Log Message: ----------- gui clean up Modified Paths: -------------- code/stage/trunk/examples/ctrl/fasr.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_position.cc code/stage/trunk/libstage/model_ranger.cc code/stage/trunk/libstage/stage.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc code/stage/trunk/worlds/fasr.world code/stage/trunk/worlds/simple.world Modified: code/stage/trunk/examples/ctrl/fasr.cc =================================================================== --- code/stage/trunk/examples/ctrl/fasr.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/examples/ctrl/fasr.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -77,19 +77,19 @@ assert(robot->sink); - const int waypoint_count = 100; - Waypoint* waypoints = new Waypoint[waypoint_count]; +// const int waypoint_count = 100; +// Waypoint* waypoints = new Waypoint[waypoint_count]; - for( int i=0; i<waypoint_count; i++ ) - { - waypoints[i].pose.x = i* 0.1; - waypoints[i].pose.y = drand48() * 4.0; - waypoints[i].pose.z = 0; - waypoints[i].pose.a = normalize( i/10.0 ); - waypoints[i].color = stg_color_pack( 0,0,1,0 ); - } +// for( int i=0; i<waypoint_count; i++ ) +// { +// waypoints[i].pose.x = i* 0.1; +// waypoints[i].pose.y = drand48() * 4.0; +// waypoints[i].pose.z = 0; +// waypoints[i].pose.a = normalize( i/10.0 ); +// waypoints[i].color = stg_color_pack( 0,0,1,0 ); +// } - robot->pos->SetWaypoints( waypoints, waypoint_count ); +// robot->pos->SetWaypoints( waypoints, waypoint_count ); return 0; //ok } Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/model_laser.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -28,8 +28,8 @@ static const unsigned int DEFAULT_RESOLUTION = 1; static const char* DEFAULT_COLOR = "blue"; -Option StgModelLaser::showLaserData( "Show Laser Data", "show_laser", "", true ); -Option StgModelLaser::showLaserStrikes( "Show Laser Data", "show_laser_strikes", "", false ); +Option StgModelLaser::showLaserData( "Laser scans", "show_laser", "", true ); +Option StgModelLaser::showLaserStrikes( "Laser strikes", "show_laser_strikes", "", false ); /** @ingroup model @@ -334,32 +334,35 @@ pts[0] = 0.0; pts[1] = 0.0; - - PushColor( 0, 0, 1, 0.5 ); - for( unsigned int s=0; s<sample_count; s++ ) - { - double ray_angle = (s * (fov / (sample_count-1))) - fov/2.0; - pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) ); - pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) ); + if( showLaserData ) + { + PushColor( 0, 0, 1, 0.5 ); - // if the sample is unusually bright, draw a little blob - if( samples[s].reflectance > 0 ) + for( unsigned int s=0; s<sample_count; s++ ) { - glBegin( GL_POINTS ); - glVertex2f( pts[2*s+2], pts[2*s+3] ); - glEnd(); - } + double ray_angle = (s * (fov / (sample_count-1))) - fov/2.0; + pts[2*s+2] = (float)(samples[s].range * cos(ray_angle) ); + pts[2*s+3] = (float)(samples[s].range * sin(ray_angle) ); + + // if the sample is unusually bright, draw a little blob + if( samples[s].reflectance > 0 ) + { + glBegin( GL_POINTS ); + glVertex2f( pts[2*s+2], pts[2*s+3] ); + glEnd(); + } + } + PopColor(); + + glDepthMask( GL_FALSE ); + + // draw the filled polygon in transparent blue + PushColor( 0, 0, 1, 0.1 ); + glVertexPointer( 2, GL_FLOAT, 0, pts ); + glDrawArrays( GL_POLYGON, 0, sample_count+1 ); + PopColor(); } - PopColor(); - - glDepthMask( GL_FALSE ); - - // draw the filled polygon in transparent blue - PushColor( 0, 0, 1, 0.1 ); - glVertexPointer( 2, GL_FLOAT, 0, pts ); - glDrawArrays( GL_POLYGON, 0, sample_count+1 ); - PopColor(); if( showLaserStrikes ) { Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/model_position.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -82,6 +82,10 @@ const stg_position_localization_mode_t POSITION_LOCALIZATION_DEFAULT = STG_POSITION_LOCALIZATION_GPS; const stg_position_drive_mode_t POSITION_DRIVE_DEFAULT = STG_POSITION_DRIVE_DIFFERENTIAL; +Option StgModelPosition::showCoords( "Position Coordinates", "show_coords", "", false ); +Option StgModelPosition::showWaypoints( "Position Waypoints", "show_waypoints", "", false ); + + StgModelPosition::StgModelPosition( StgWorld* world, StgModel* parent ) : StgModel( world, parent, MODEL_TYPE_POSITION ), @@ -126,6 +130,8 @@ drand48() * STG_POSITION_INTEGRATION_ERROR_MAX_A - STG_POSITION_INTEGRATION_ERROR_MAX_A/2.0; + registerOption( &showCoords ); + registerOption( &showWaypoints ); } @@ -556,60 +562,63 @@ void StgModelPosition::DataVisualize( Camera* cam ) { - if( waypoints && waypoint_count ) + if( showWaypoints && waypoints && waypoint_count ) DrawWaypoints(); - - // vizualize my estimated pose - glPushMatrix(); - // back into global coords - gl_pose_inverse_shift( GetGlobalPose() ); + if( showCoords ) + { + // vizualize my estimated pose + glPushMatrix(); + + // back into global coords + gl_pose_inverse_shift( GetGlobalPose() ); - gl_pose_shift( est_origin ); - PushColor( 1,0,0,1 ); // origin in red - gl_draw_origin( 0.5 ); + gl_pose_shift( est_origin ); + PushColor( 1,0,0,1 ); // origin in red + gl_draw_origin( 0.5 ); - glEnable (GL_LINE_STIPPLE); - glLineStipple (3, 0xAAAA); + glEnable (GL_LINE_STIPPLE); + glLineStipple (3, 0xAAAA); - PushColor( 1,0,0,0.5 ); - glBegin( GL_LINE_STRIP ); - glVertex2f( 0,0 ); - glVertex2f( est_pose.x, 0 ); - glVertex2f( est_pose.x, est_pose.y ); - glEnd(); + PushColor( 1,0,0,0.5 ); + glBegin( GL_LINE_STRIP ); + glVertex2f( 0,0 ); + glVertex2f( est_pose.x, 0 ); + glVertex2f( est_pose.x, est_pose.y ); + glEnd(); - glDisable(GL_LINE_STIPPLE); + glDisable(GL_LINE_STIPPLE); - char label[64]; - snprintf( label, 64, "x:%.3f", est_pose.x ); - gl_draw_string( est_pose.x / 2.0, -0.5, 0, label ); + char label[64]; + snprintf( label, 64, "x:%.3f", est_pose.x ); + gl_draw_string( est_pose.x / 2.0, -0.5, 0, label ); - snprintf( label, 64, "y:%.3f", est_pose.y ); - gl_draw_string( est_pose.x + 0.5 , est_pose.y / 2.0, 0, (const char*)label ); + snprintf( label, 64, "y:%.3f", est_pose.y ); + gl_draw_string( est_pose.x + 0.5 , est_pose.y / 2.0, 0, (const char*)label ); - PopColor(); + PopColor(); - gl_pose_shift( est_pose ); - PushColor( 0,1,0,1 ); // pose in green - gl_draw_origin( 0.5 ); - PopColor(); + gl_pose_shift( est_pose ); + PushColor( 0,1,0,1 ); // pose in green + gl_draw_origin( 0.5 ); + PopColor(); - gl_pose_shift( geom.pose ); - PushColor( 0,0,1,1 ); // offset in blue - gl_draw_origin( 0.5 ); - PopColor(); + gl_pose_shift( geom.pose ); + PushColor( 0,0,1,1 ); // offset in blue + gl_draw_origin( 0.5 ); + PopColor(); - double r,g,b,a; - stg_color_unpack( color, &r, &g, &b, &a ); - PushColor( r, g, b, 0.5 ); + double r,g,b,a; + stg_color_unpack( color, &r, &g, &b, &a ); + PushColor( r, g, b, 0.5 ); - glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); - blockgroup.DrawFootPrint( geom ); - PopColor(); + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + blockgroup.DrawFootPrint( geom ); + PopColor(); - glPopMatrix(); + glPopMatrix(); + } } void StgModelPosition::DrawWaypoints() Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/model_ranger.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -95,8 +95,8 @@ static const char RANGER_CONFIG_COLOR[] = "gray90"; static const char RANGER_GEOM_COLOR[] = "orange"; -Option StgModelRanger::showRangerData( "Show Ranger Data", "show_ranger", "", true ); -Option StgModelRanger::showRangerTransducers( "Show Ranger transducer locations", "show_ranger_transducers", "", false ); +Option StgModelRanger::showRangerData( "Ranger ranges", "show_ranger", "", true ); +Option StgModelRanger::showRangerTransducers( "Ranger transducers", "show_ranger_transducers", "", false ); StgModelRanger::StgModelRanger( StgWorld* world, Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/stage.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -236,14 +236,14 @@ static void pb_set_pixel( Fl_Shared_Image* pb, int x, int y, uint8_t val ) { // bounds checking - int width = pb->w();//gdk_pixbuf_get_width(pb); - int height = pb->h();//gdk_pixbuf_get_height(pb); + int width = pb->w(); + int height = pb->h(); if( x >=0 && x < width && y >= 0 && y < height ) { // zeroing guchar* pix = pb_get_pixel( pb, x, y ); - unsigned int bytes_per_sample = 1;//gdk_pixbuf_get_bits_per_sample (pb) / 8; - unsigned int num_samples = pb->d();//gdk_pixbuf_get_n_channels(pb); + unsigned int bytes_per_sample = 1; + unsigned int num_samples = pb->d(); memset( pix, val, num_samples * bytes_per_sample ); } else @@ -253,8 +253,8 @@ // set all the pixels in a rectangle static void pb_set_rect( Fl_Shared_Image* pb, int x, int y, int width, int height, uint8_t val ) { - int bytes_per_sample = 1;//gdk_pixbuf_get_bits_per_sample (pb) / 8; - int num_samples = pb->d();//gdk_pixbuf_get_n_channels(pb); + int bytes_per_sample = 1; + int num_samples = pb->d(); int a, b; for( a = y; a < y+height; a++ ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/stage.hh 2008-12-02 02:30:04 UTC (rev 7185) @@ -2477,6 +2477,10 @@ uint32_t waypoint_count; void DrawWaypoints(); + private: + static Option showCoords; + static Option showWaypoints; + public: static const char* typestr; // constructor Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/libstage/worldgui.cc 2008-12-02 02:30:04 UTC (rev 7185) @@ -497,22 +497,25 @@ } -void StgWorldGui::viewOptionsCb( Fl_Widget* w, void* p ) { +void StgWorldGui::viewOptionsCb( Fl_Widget* w, void* p ) +{ StgWorldGui* worldGui = static_cast<StgWorldGui*>( p ); - - if ( !worldGui->oDlg ) { - int x = worldGui->w()+worldGui->x() + 10; - int y = worldGui->y(); - OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 ); - oDlg->callback( optionsDlgCb, worldGui ); - oDlg->setOptions( worldGui->drawOptions ); - oDlg->showAllOpt( &worldGui->canvas->visualizeAll ); - worldGui->oDlg = oDlg; - oDlg->show(); - } - else { - worldGui->oDlg->show(); // bring it to front - } + + if ( !worldGui->oDlg ) + { + int x = worldGui->w()+worldGui->x() + 10; + int y = worldGui->y(); + OptionsDlg* oDlg = new OptionsDlg( x,y, 180,250 ); + oDlg->callback( optionsDlgCb, worldGui ); + oDlg->setOptions( worldGui->drawOptions ); + oDlg->showAllOpt( &worldGui->canvas->visualizeAll ); + worldGui->oDlg = oDlg; + oDlg->show(); + } + else + { + worldGui->oDlg->show(); // bring it to front + } } void StgWorldGui::optionsDlgCb( Fl_Widget* w, void* p ) { @@ -592,7 +595,6 @@ Fl_Box* box = new Fl_Box( Spc, Spc, Width-2*Spc, pngH ); // widget that will contain image - std::string fullpath; fullpath = FileManager::findFile( "assets/stagelogo.png" ); Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/worlds/fasr.world 2008-12-02 02:30:04 UTC (rev 7185) @@ -65,8 +65,6 @@ ( sicklaser( samples 32 range_max 5 laser_return 2 ) ctrl "fasr" - - localization "odom" ) autorob( pose [5.099 4.804 0 -73.937] ) @@ -80,16 +78,16 @@ autorob( pose [6.898 4.775 0 -117.576] ) autorob( pose [7.012 5.706 0 129.497] ) -#autorob( pose [6.616 6.893 0 170.743] ) -#autorob( pose [6.451 4.189 0 -61.453] ) -#autorob( pose [5.098 6.788 0 -61.295] ) -#autorob( pose [4.374 5.163 0 -90.417] ) -#autorob( pose [4.999 4.230 0 -42.157] ) -#autorob( pose [4.331 4.217 0 -95.000] ) -#autorob( pose [5.440 5.317 0 -26.545] ) -#autorob( pose [7.518 6.973 0 163.239] ) -#autorob( pose [7.559 4.764 0 -139.066] ) -#autorob( pose [4.839 3.595 0 -179.567] ) +autorob( pose [6.616 6.893 0 170.743] ) +autorob( pose [6.451 4.189 0 -61.453] ) +autorob( pose [5.098 6.788 0 -61.295] ) +autorob( pose [4.374 5.163 0 -90.417] ) +autorob( pose [4.999 4.230 0 -42.157] ) +autorob( pose [4.331 4.217 0 -95.000] ) +autorob( pose [5.440 5.317 0 -26.545] ) +autorob( pose [7.518 6.973 0 163.239] ) +autorob( pose [7.559 4.764 0 -139.066] ) +autorob( pose [4.839 3.595 0 -179.567] ) #autorob( pose [7.122 4.175 0 -31.440] ) #autorob( pose [6.203 6.963 0 2.937] ) Modified: code/stage/trunk/worlds/simple.world =================================================================== --- code/stage/trunk/worlds/simple.world 2008-12-02 01:45:44 UTC (rev 7184) +++ code/stage/trunk/worlds/simple.world 2008-12-02 02:30:04 UTC (rev 7185) @@ -10,7 +10,7 @@ interval_sim 100 # simulation timestep in milliseconds interval_real 10 # real-time interval between simulation updates in milliseconds -paused 0 +paused 1 resolution 0.02 @@ -48,4 +48,3 @@ ctrl "wander" ) -walle( pose [ 3 3 0 ] ctrl "wander" ) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit