Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <rtv@us...> - 2008-04-10 17:54:26
|
Revision: 6297 http://playerstage.svn.sourceforge.net/playerstage/?rev=6297&view=rev Author: rtv Date: 2008-04-10 17:54:28 -0700 (Thu, 10 Apr 2008) Log Message: ----------- cmake build works with modules & partially installs Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/examples/ctrl/fasr.cc code/stage/trunk/examples/ctrl/lasernoise.cc code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_blinkenlight.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/stage.cc code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/CMakeLists.txt 2008-04-11 00:54:28 UTC (rev 6297) @@ -1,5 +1,9 @@ PROJECT(Stage) +SET (STAGE_VERSION 3.0.0 CACHE STRING "Stage distribution version") +SET (STAGE_API_VERSION 3.0.0 CACHE STRING "Stage API version") +MESSAGE (STATUS "${PROJECT_NAME} version ${STAGE_VERSION}") + include(FindPkgConfig) pkg_check_modules( GLIB gdk-pixbuf-2.0 ) Modified: code/stage/trunk/examples/ctrl/fasr.cc =================================================================== --- code/stage/trunk/examples/ctrl/fasr.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/examples/ctrl/fasr.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -82,7 +82,6 @@ stg_laser_sample_t* scan = robot->laser->GetSamples( &sample_count ); assert(scan); - double newturnrate=0.0, newspeed=0.0; bool obstruction = false; bool stop = false; Modified: code/stage/trunk/examples/ctrl/lasernoise.cc =================================================================== --- code/stage/trunk/examples/ctrl/lasernoise.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/examples/ctrl/lasernoise.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -28,7 +28,7 @@ stg_laser_sample_t* scan = mod->GetSamples( &sample_count ); if( scan ) - for( int i=0; i<sample_count; i++ ) + for( unsigned int i=0; i<sample_count; i++ ) scan[i].range *= SimpleNormalDeviate( 1.0, DEVIATION ); return 0; // run again Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-04-11 00:54:28 UTC (rev 6297) @@ -12,6 +12,7 @@ gl.cc glcolorstack.cc model.cc + model_blinkenlight.cc model_callbacks.cc model_fiducial.cc model_laser.cc @@ -20,6 +21,7 @@ model_ranger.cc model_blobfinder.cc model_props.cc + resource.cc stage.cc typetable.cc world.cc @@ -27,10 +29,7 @@ worldgui.cc ) -add_executable( stage main.cc ) - - target_link_libraries( stage ${GLIB_LIBRARIES} ${FLTK_LIBRARIES} @@ -38,3 +37,17 @@ ltdl ) +add_executable( stagebinary main.cc +) + +set_target_properties( stagebinary PROPERTIES + OUTPUT_NAME stage ) + +target_link_libraries( stagebinary + stage +) + +INSTALL(TARGETS stagebinary stage + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib +) Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/canvas.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -533,7 +533,7 @@ // find all the flags - GList* flags = NULL; + //GList* flags = NULL; } void StgCanvas::resize(int X,int Y,int W,int H) Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/main.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -5,9 +5,12 @@ */ -#include "config.h" +//#include "config.h" #include "stage_internal.hh" +const char* PACKAGE = "Stage"; +const char* VERSION = "3.dev"; + int main( int argc, char* argv[] ) { printf( "%s %s\n", PACKAGE, VERSION ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/model.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -985,7 +985,7 @@ glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - for( int i=0; i<blinkenlights->len; i++ ) + for( unsigned int i=0; i<blinkenlights->len; i++ ) { stg_blinkenlight_t* b = (stg_blinkenlight_t*)g_ptr_array_index( blinkenlights, i ); Modified: code/stage/trunk/libstage/model_blinkenlight.cc =================================================================== --- code/stage/trunk/libstage/model_blinkenlight.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/model_blinkenlight.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -49,12 +49,12 @@ //#define DEBUG 1 #include "stage_internal.hh" -static gboolean blink( bool* enabled ) -{ - *enabled = ! *enabled; - puts( "blink" ); - return true; -} +//static gboolean blink( bool* enabled ) +//{ +// *enabled = ! *enabled; +// puts( "blink" ); +// return true; +//} StgModelBlinkenlight::StgModelBlinkenlight( StgWorld* world, StgModel* parent, Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/model_load.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -415,10 +415,13 @@ } else { + printf( "Libtool error: %s. Can't open your plugin controller. Quitting\n", + lt_dlerror() ); // report the error from libtool + PRINT_ERR1( "Failed to open \"%s\". Check that it can be found by searching the directories in your STAGEPATH environment variable, or the current directory if STAGEPATH is not set.]\n", lib ); exit(-1); } - + fflush(stdout); } Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/stage.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -17,7 +17,7 @@ //#define DEBUG #include "stage_internal.hh" -#include "config.h" // results of autoconf's system configuration tests +//#include "config.h" // results of autoconf's system configuration tests static bool init_called = false; static GHashTable* typetable = NULL; Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-04-10 21:24:57 UTC (rev 6296) +++ code/stage/trunk/libstage/worldgui.cc 2008-04-11 00:54:28 UTC (rev 6297) @@ -95,7 +95,7 @@ */ -#include "config.h" // for PACKAGE strings etc +//#include "config.h" // for PACKAGE strings etc #include "stage_internal.hh" #include "region.hh" @@ -116,6 +116,8 @@ static const char* MITEM_VIEW_TRAILS = "View/Trails/Blocks"; static const char* MITEM_VIEW_ARROWS = "View/Trails/Arrows"; +// hack - get this from somewhere sensible +const char* PACKAGE_STRING = "Stage-3.dev"; void dummy_cb(Fl_Widget*, void* v) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-04-11 16:48:08
|
Revision: 6303 http://playerstage.svn.sourceforge.net/playerstage/?rev=6303&view=rev Author: rtv Date: 2008-04-11 16:48:14 -0700 (Fri, 11 Apr 2008) Log Message: ----------- fixed a graphics bug Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-04-11 21:34:50 UTC (rev 6302) +++ code/stage/trunk/libstage/canvas.cc 2008-04-11 23:48:14 UTC (rev 6303) @@ -394,22 +394,7 @@ // Clear screen to bg color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - if( showflags & STG_SHOW_CLOCK ) - { - glPushMatrix(); - glLoadIdentity(); - char clockstr[50]; - world->ClockString( clockstr, 50 ); - - colorstack.Push( 0,0,0 ); // black - gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr ); - colorstack.Pop(); - - glPopMatrix(); - } - - // if following selected, shift the view to above the selected robot if( (showflags & STG_SHOW_FOLLOW) && last_selection ) { @@ -531,7 +516,23 @@ world->ClearRays(); } + if( showflags & STG_SHOW_CLOCK ) + { + glPushMatrix(); + glLoadIdentity(); + glDisable( GL_DEPTH_TEST ); + char clockstr[50]; + world->ClockString( clockstr, 50 ); + + colorstack.Push( 0,0,0 ); // black + gl_draw_string( -w()/2+4, -h()/2+4, 5, clockstr ); + colorstack.Pop(); + + glEnable( GL_DEPTH_TEST ); + glPopMatrix(); + } + // find all the flags //GList* flags = NULL; } Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-04-11 21:34:50 UTC (rev 6302) +++ code/stage/trunk/libstage/model.cc 2008-04-11 23:48:14 UTC (rev 6303) @@ -250,26 +250,26 @@ // anything else to do here? - // try some things out; - stg_blinkenlight_t* b = new stg_blinkenlight_t; - b->pose.x = 0; - b->pose.y = 0; - b->pose.z = 0.4; - b->pose.a = 0; - b->enabled = true; - b->color = stg_color_pack( 1,1,0,0 ); - b->size = 0.1; +// // try some things out; +// stg_blinkenlight_t* b = new stg_blinkenlight_t; +// b->pose.x = 0; +// b->pose.y = 0; +// b->pose.z = 0.4; +// b->pose.a = 0; +// b->enabled = true; +// b->color = stg_color_pack( 1,1,0,0 ); +// b->size = 0.1; - //AddBlinkenlight( b ); +// //AddBlinkenlight( b ); - stg_blinkenlight_t* c = new stg_blinkenlight_t; - c->pose.x = 0.1; - c->pose.y = 0; - c->pose.z = 0.4; - c->pose.a = 0; - c->enabled = false; - c->color = stg_color_pack( 1,1,0,0 ); - c->size = 0.1; +// stg_blinkenlight_t* c = new stg_blinkenlight_t; +// c->pose.x = 0.1; +// c->pose.y = 0; +// c->pose.z = 0.4; +// c->pose.a = 0; +// c->enabled = false; +// c->color = stg_color_pack( 1,1,0,0 ); +// c->size = 0.1; } void StgModel::AddFlag( StgFlag* flag ) @@ -920,7 +920,6 @@ // shift up the CS to the top of this model gl_coord_shift( 0,0, this->geom.size.z, 0 ); - // recursively draw the tree below this model for( GList* it=children; it; it=it->next ) @@ -970,6 +969,8 @@ glTranslatef( 0, 0, flag->size/2.0 ); } + g_list_free( list ); + gluDeleteQuadric( quadric ); glPopMatrix(); } Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-04-11 21:34:50 UTC (rev 6302) +++ code/stage/trunk/worlds/fasr.world 2008-04-11 23:48:14 UTC (rev 6303) @@ -24,10 +24,10 @@ # configure the GUI window window ( - size [ 1200 1000 ] - center [9.990 -19.040] + size [ 698.000 628.000 ] + center [6.990 -4.040] rotate [ 0.000 0.000 ] - scale 28.806 + scale 33.306 show_data 0 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-04-13 22:37:20
|
Revision: 6314 http://playerstage.svn.sourceforge.net/playerstage/?rev=6314&view=rev Author: rtv Date: 2008-04-13 22:37:26 -0700 (Sun, 13 Apr 2008) Log Message: ----------- removed gdk-pixbuf dependency (and thus GTK is gone) Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/stage.cc Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-04-13 08:29:35 UTC (rev 6313) +++ code/stage/trunk/CMakeLists.txt 2008-04-14 05:37:26 UTC (rev 6314) @@ -5,7 +5,7 @@ MESSAGE (STATUS "${PROJECT_NAME} version ${STAGE_VERSION}") include(FindPkgConfig) -pkg_check_modules( GLIB gdk-pixbuf-2.0 ) +pkg_check_modules( GLIB glib-2.0 ) find_package(OPENGL REQUIRED) Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-04-13 08:29:35 UTC (rev 6313) +++ code/stage/trunk/libstage/stage.cc 2008-04-14 05:37:26 UTC (rev 6314) @@ -12,7 +12,7 @@ #include <glib.h> #include <locale.h> -#include <gdk-pixbuf/gdk-pixbuf.h> +#include <FL/Fl_Shared_Image.H> //#define DEBUG @@ -30,13 +30,14 @@ // seed the RNG srand48( time(NULL) ); - g_type_init(); - if(!setlocale(LC_ALL,"POSIX")) PRINT_WARN("Failed to setlocale(); config file may not be parse correctly\n" ); typetable = stg_create_typetable(); init_called = true; + + // ask FLTK to load support for various image formats + fl_register_images(); } bool Stg::InitDone() @@ -335,62 +336,65 @@ // pb_* functions are only used inside this file -static guchar* pb_get_pixel( GdkPixbuf* pb, int x, int y ) -{ - guchar* pixels = gdk_pixbuf_get_pixels(pb); - int rs = gdk_pixbuf_get_rowstride(pb); - int ch = gdk_pixbuf_get_n_channels(pb); - return( pixels + y * rs + x * ch ); -} - -// static void pb_set_pixel( GdkPixbuf* pb, int x, int y, uint8_t val ) +// static guchar* pb_get_pixel( GdkPixbuf* pb, int x, int y ) // { -// // bounds checking -// int width = gdk_pixbuf_get_width(pb); -// int height = gdk_pixbuf_get_height(pb); -// if( x >=0 && x < width && y >= 0 && y < height ) -// { -// // zeroing -// guchar* pix = pb_get_pixel( pb, x, y ); -// int bytes_per_sample = gdk_pixbuf_get_bits_per_sample (pb) / 8; -// int num_samples = gdk_pixbuf_get_n_channels(pb); -// memset( pix, val, num_samples * bytes_per_sample ); -// } -// else -// PRINT_WARN4( "pb_set_pixel coordinate %d,%d out of range (image dimensions %d by %d)", x, y, width, height ); +// guchar* pixels = gdk_pixbuf_get_pixels(pb); +// int rs = gdk_pixbuf_get_rowstride(pb); +// int ch = gdk_pixbuf_get_n_channels(pb); +// return( pixels + y * rs + x * ch ); // } -// set all the pixels in a rectangle -static void pb_set_rect( GdkPixbuf* pb, int x, int y, int width, int height, uint8_t val ) +static guchar* pb_get_pixel( Fl_Shared_Image* img, int x, int y ) { - int bytes_per_sample = gdk_pixbuf_get_bits_per_sample (pb) / 8; - int num_samples = gdk_pixbuf_get_n_channels(pb); + guchar* pixels = (guchar*)(img->data()[0]); + //int rs = gdk_pixbuf_get_rowstride(pb); + //int ch = gdk_pixbuf_get_n_channels(pb); - int a, b; - for( a = y; a < y+height; a++ ) - for( b = x; b < x+width; b++ ) - { - // zeroing - guchar* pix = pb_get_pixel( pb, b, a ); - memset( pix, val, num_samples * bytes_per_sample ); - } -} + //unsigned int depth = img->d(); + //unsigned int width = img->w(); + unsigned int index = (y * img->w() * img->d()) + (x * img->d()); + return( pixels + index ); +} -// returns TRUE if any channel in the pixel is non-zero -static gboolean pb_pixel_is_set( GdkPixbuf* pb, int x, int y, int threshold ) +static void pb_set_pixel( Fl_Shared_Image* pb, int x, int y, uint8_t val ) { - guchar* pixel = pb_get_pixel( pb,x,y ); - //int channels = gdk_pixbuf_get_n_channels(pb); - //int i; - //for( i=0; i<channels; i++ ) - //if( pixel[i] ) return TRUE; - if( pixel[0] > threshold ) return TRUE; // just use the red channel for now - - return FALSE; + // bounds checking + int width = pb->w();//gdk_pixbuf_get_width(pb); + int height = pb->h();//gdk_pixbuf_get_height(pb); + 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); + memset( pix, val, num_samples * bytes_per_sample ); + } + else + PRINT_WARN4( "pb_set_pixel coordinate %d,%d out of range (image dimensions %d by %d)", x, y, width, height ); } +// 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 a, b; + for( a = y; a < y+height; a++ ) + for( b = x; b < x+width; b++ ) + { + // zeroing + guchar* pix = pb_get_pixel( pb, b, a ); + memset( pix, val, num_samples * bytes_per_sample ); + } + } +// // returns TRUE if any channel in the pixel is non-zero +static gboolean pb_pixel_is_set( Fl_Shared_Image* img, int x, int y, int threshold ) +{ + guchar* pixel = pb_get_pixel( img,x,y ); + return( pixel[0] > threshold ); +} int Stg::stg_rotrects_from_image_file( const char* filename, stg_rotrect_t** rects, @@ -400,63 +404,43 @@ { // TODO: make this a parameter const int threshold = 127; - - GError* err = NULL; - GdkPixbuf* pb = gdk_pixbuf_new_from_file( filename, &err ); - - if( err ) - { - fprintf( stderr, "\nError loading bitmap: %s\n", err->message ); - return 1; // error - } - // this should be ok as no error was reported - assert( pb ); - - -#ifdef DEBUG - printf( "debug: Loaded image \"%s\" \n\tchannels:%d bits:%d alpha:%d " - "width:%d height:%d rowstride:%d pixels:%p (%s %s)\n", - filename, - gdk_pixbuf_get_n_channels(pb), - gdk_pixbuf_get_bits_per_sample(pb), - gdk_pixbuf_get_has_alpha(pb), - gdk_pixbuf_get_width(pb), - gdk_pixbuf_get_height(pb), - gdk_pixbuf_get_rowstride(pb), - gdk_pixbuf_get_pixels(pb), - __FILE__, __FUNCTION__ ); -#endif + Fl_Shared_Image *img = Fl_Shared_Image::get(filename); + assert( img ); - + //printf( "loaded image %s w %d h %d d %d count %d ld %d\n", + // filename, img->w(), img->h(), img->d(), img->count(), img->ld() ); + *rect_count = 0; size_t allocation_unit = 1000; size_t rects_allocated = allocation_unit; *rects = (stg_rotrect_t*)g_new( stg_rotrect_t, rects_allocated ); - int img_width = gdk_pixbuf_get_width(pb); - int img_height = gdk_pixbuf_get_height(pb); + int img_width = img->w();//gdk_pixbuf_get_width(pb); + int img_height = img->h();//gdk_pixbuf_get_height(pb); // if the caller wanted to know the dimensions if( widthp ) *widthp = img_width; if( heightp ) *heightp = img_height; + int y, x; for(y = 0; y < img_height; y++) { + puts(""); for(x = 0; x < img_width; x++) { // skip blank (white) pixels - if( pb_pixel_is_set( pb,x,y, threshold) ) + if( pb_pixel_is_set( img,x,y, threshold) ) continue; - + // a rectangle starts from this point int startx = x; int starty = y; int height = img_height; // assume full height for starters // grow the width - scan along the line until we hit an empty (white) pixel - for( ; x < img_width && ! pb_pixel_is_set(pb,x,y,threshold); x++ ) + for( ; x < img_width && ! pb_pixel_is_set(img,x,y,threshold); x++ ) { // handle horizontal cropping //double ppx = x * sx; @@ -465,7 +449,7 @@ // look down to see how large a rectangle below we can make int yy = y; - while( ! pb_pixel_is_set(pb,x,yy,threshold) && (yy < img_height-1) ) + while( ! pb_pixel_is_set(img,x,yy,threshold) && (yy < img_height-1) ) { // handle vertical cropping //double ppy = (this->image->height - yy) * sy; @@ -482,7 +466,7 @@ } // whiten the pixels we have used in this rect - pb_set_rect( pb, startx, starty, x-startx, height, 0xFF ); + pb_set_rect( img, startx, starty, x-startx, height, 0xFF ); // add this rectangle to the array (*rect_count)++; @@ -512,8 +496,10 @@ } } + printf( "rects found %d\n", *rect_count ); + // free the image data - gdk_pixbuf_unref( pb ); + //gdk_pixbuf_unref( pb ); return 0; // ok } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gerkey@us...> - 2008-05-11 17:09:52
|
Revision: 6425 http://playerstage.svn.sourceforge.net/playerstage/?rev=6425&view=rev Author: gerkey Date: 2008-05-11 17:09:57 -0700 (Sun, 11 May 2008) Log Message: ----------- tweaked libstage installation to use versioned header location; removed bogus playercore dependency from libstage Modified Paths: -------------- code/stage/trunk/libstage/Makefile.am code/stage/trunk/stage.pc.in Modified: code/stage/trunk/libstage/Makefile.am =================================================================== --- code/stage/trunk/libstage/Makefile.am 2008-05-11 22:31:33 UTC (rev 6424) +++ code/stage/trunk/libstage/Makefile.am 2008-05-12 00:09:57 UTC (rev 6425) @@ -5,7 +5,8 @@ # $Id: Makefile.am,v 1.11 2008-04-01 23:57:41 rtv Exp $ # install the header file for the Stage library -include_HEADERS = stage.hh +versionedincludedir = $(prefix)/include/stage-3.0 +versionedinclude_HEADERS = stage.hh # install the color database pkgdata_DATA = rgb.txt Modified: code/stage/trunk/stage.pc.in =================================================================== --- code/stage/trunk/stage.pc.in 2008-05-11 22:31:33 UTC (rev 6424) +++ code/stage/trunk/stage.pc.in 2008-05-12 00:09:57 UTC (rev 6425) @@ -3,6 +3,6 @@ Name: stage Description: Stage robot simulation C library and Player plugin - part of the Player/Stage Project Version: @VERSION@ -Requires: gtk+-2.0 >= 2.4 gthread-2.0 >= 2.4 playercore >= 2.1 playerc >= 2.1 +Requires: gtk+-2.0 >= 2.4 gthread-2.0 >= 2.4 Libs: -L${prefix}/lib -lstage Cflags: -I${prefix}/include/stage-3.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-05-22 18:34:37
|
Revision: 6452 http://playerstage.svn.sourceforge.net/playerstage/?rev=6452&view=rev Author: rtv Date: 2008-05-22 18:34:45 -0700 (Thu, 22 May 2008) Log Message: ----------- more vertex arrays Modified Paths: -------------- code/stage/trunk/libstage/block.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldgui.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/libstage/block.cc =================================================================== --- code/stage/trunk/libstage/block.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/block.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -25,7 +25,9 @@ this->pt_count = pt_count; this->pts = (stg_point_t*)g_memdup( pts, pt_count * sizeof(stg_point_t)); // allocate space for the integer version of the block vertices - this->pts_global = new stg_point_int_t[pt_count]; + this->pts_global_pixels = new stg_point_int_t[pt_count]; + this->global_vertices = new stg_vertex_t[2*pt_count+2]; + this->zmin = zmin; this->zmax = zmax; this->color = color; @@ -36,6 +38,18 @@ // flag these as unset until StgBlock::Map() is called. this->global_zmin = -1; this->global_zmax = -1; + + this->edge_indices = new GLubyte[ 6 * pt_count ]; + for( int i=0; i<pt_count; i++ ) + { + this->edge_indices[6*i] = 2*i; + this->edge_indices[6*i+1] = 2*i+1; + this->edge_indices[6*i+2] = 2*i; + this->edge_indices[6*i+3] = 2*i+2; + this->edge_indices[6*i+4] = 2*i+1; + this->edge_indices[6*i+5] = 2*i+3; + } + } StgBlock::~StgBlock() @@ -43,6 +57,8 @@ this->UnMap(); g_free( pts ); g_array_free( rendered_points, TRUE ); + + delete[] edge_indices; } void Stg::stg_block_list_destroy( GList* list ) @@ -57,18 +73,16 @@ void StgBlock::DrawTop() { // draw a top that fits over the side strip - glBegin(GL_POLYGON); - - for( unsigned int p=0; p<pt_count; p++ ) - glVertex3f( pts[p].x, pts[p].y, zmax ); - - glEnd(); + glPushMatrix(); + glTranslatef( 0,0,zmax); + glVertexPointer( 2, GL_DOUBLE, 0, pts ); + glDrawArrays( GL_POLYGON, 0, pt_count ); + glPopMatrix(); } void StgBlock::DrawSides() { - // construct a strip that wraps around the polygon - + // construct a strip that wraps around the polygon glBegin(GL_QUAD_STRIP); for( unsigned int p=0; p<pt_count; p++) { @@ -91,6 +105,7 @@ glEnd(); } + void StgBlock::Draw() { // draw filled color polygons @@ -119,6 +134,45 @@ PopColor(); } +void StgBlock::DrawGlobal() +{ + // draw filled color polygons + stg_color_t color = Color(); + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); + PushColor( color ); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1.0, 1.0); + + // glColorPointer(3, GL_UNSIGNED_BYTE, 0, colors ); + + // top - we skip every 2nd vertex + glVertexPointer( 3, GL_FLOAT, 6*sizeof(GLfloat), global_vertices ); + glDrawArrays( GL_TRIANGLE_FAN, 0, pt_count ); + + // sides - we use all vertices + glVertexPointer( 3, GL_FLOAT, 0, global_vertices ); + glDrawArrays( GL_TRIANGLE_STRIP, 0, pt_count*2+2 ); + + 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( color, &r, &g, &b, &a ); + PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a )); + + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); + glDepthMask(GL_FALSE); + + // we use the array of vertices + glDrawElements( GL_LINES, pt_count*6, GL_UNSIGNED_BYTE, edge_indices ); + + glDepthMask(GL_TRUE); + + PopColor(); + PopColor(); +} + void StgBlock::Draw2D() { // draw filled color polygons @@ -175,19 +229,35 @@ local.z = zmin; global = mod->LocalToGlobal( local ); - - pts_global[p].x = (int32_t)floor(global.x*ppm); - pts_global[p].y = (int32_t)floor(global.y*ppm); + // top surface vertex + global_vertices[2*p].x = global.x; + global_vertices[2*p].y = global.y; + global_vertices[2*p].z = global.z + zmax; + + // bottom surface vertex + global_vertices[2*p+1].x = global.x; + global_vertices[2*p+1].y = global.y; + global_vertices[2*p+1].z = global.z; + + pts_global_pixels[p].x = (int32_t)floor(global.x*ppm); + pts_global_pixels[p].y = (int32_t)floor(global.y*ppm); + PRINT_DEBUG2("loc [%.2f %.2f]", pts[p].x, pts[p].y ); PRINT_DEBUG2("glb [%d %d]", - pts_global[p].x, - pts_global[p].y ); + pts_global_pixels[p].x, + pts_global_pixels[p].y ); } - + + // close the strip + // top surface vertex + global_vertices[2*pt_count] = global_vertices[0]; + global_vertices[2*pt_count+1] = global_vertices[1]; + + // store the block's global vertical bounds for inspection by the // raytracer global_zmin = global.z; @@ -197,7 +267,7 @@ render_info.world = mod->GetWorld(); render_info.block = this; - stg_polygon_3d( pts_global, pt_count, + stg_polygon_3d( pts_global_pixels, pt_count, (stg_line3d_func_t)StgWorld::AddBlockPixel, (void*)&render_info ); Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/canvas.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -27,7 +27,7 @@ selected_models = NULL; last_selection = NULL; - startx = starty = 0; + startx = starty = 0; panx = pany = stheta = sphi = 0.0; scale = 15.0; interval = 100; //msec between redraws @@ -389,8 +389,13 @@ glRotatef( rtod(sphi), 0,0,1 ); // rotate about z - yaw // ... to here to get rotation about the center of the window (but broken panning) + + // enable vertex arrays + glEnableClientState( GL_VERTEX_ARRAY ); + //glEnableClientState( GL_COLOR_ARRAY ); } + // Clear screen to bg color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); @@ -459,18 +464,18 @@ { glDisable( GL_DEPTH_TEST ); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - + for( GList* it=world->children; it; it=it->next ) { ((StgModel*)it->data)->DrawTrailFootprint(); } glEnable( GL_DEPTH_TEST ); } - + if( showflags & STG_SHOW_TRAILS ) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - + for( GList* it=world->children; it; it=it->next ) { ((StgModel*)it->data)->DrawTrailBlocks(); @@ -487,15 +492,14 @@ } if( showflags & STG_SHOW_BLOCKS ) - for( GList* it=world->children; it; it=it->next ) { - uint32_t flags = showflags; - - if( (stheta == 0) && (sphi == 0) ) - flags |= STG_SHOW_BLOCKS_2D; - - ((StgModel*)it->data)->Draw( flags ); + for( GList* it=world->children; it; it=it->next ) + ((StgModel*)it->data)->DrawBlocks(); } + + // draw everything else + for( GList* it=world->children; it; it=it->next ) + ((StgModel*)it->data)->Draw( showflags ); } if( world->GetRayList() ) @@ -532,9 +536,6 @@ glEnable( GL_DEPTH_TEST ); glPopMatrix(); } - - // find all the flags - //GList* flags = NULL; } void StgCanvas::resize(int X,int Y,int W,int H) Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/model.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -878,7 +878,20 @@ } +void StgModel::DrawBlocks( ) +{ + LISTMETHOD( this->children, StgModel*, DrawBlocks ); + LISTMETHOD( this->blocks, StgBlock*, DrawGlobal ); +} + +void StgModel::DrawBlocks( gpointer dummykey, + StgModel* mod, void* dummyarg ) +{ + mod->DrawBlocks(); + +} + void StgModel::Draw( uint32_t flags ) { //PRINT_DEBUG1( "Drawing %s", token ); @@ -889,17 +902,6 @@ gl_pose_shift( &this->pose ); gl_pose_shift( &this->geom.pose ); - // draw all the blocks - if( flags & STG_SHOW_BLOCKS_2D ) - { - LISTMETHOD( this->blocks, StgBlock*, Draw2D ); - } - else if( flags & STG_SHOW_BLOCKS ) - { - LISTMETHOD( this->blocks, StgBlock*, Draw ); - } - //else - //if( this->say_string ) // gl_speech_bubble( 0,0,0, this->say_string ); Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/model_laser.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -299,6 +299,7 @@ this->data_dirty = true; } + void StgModelLaser::DataVisualize( void ) { if( ! (samples && sample_count) ) @@ -316,6 +317,10 @@ PushColor( 0, 0, 1, 0.5 ); + glPointSize( 4.0 ); + + glVertexPointer( 2, GL_FLOAT, 0, pts ); + for( unsigned int s=0; s<sample_count; s++ ) { double ray_angle = (s * (fov / (sample_count-1))) - fov/2.0; @@ -325,24 +330,23 @@ // if the sample is unusually bright, draw a little blob if( samples[s].reflectance > 0 ) { - glPointSize( 4.0 ); glBegin( GL_POINTS ); - glVertex2f( pts[2*s+2], pts[2*s+3] ); + glVertex2f( pts[2*s+2], pts[2*s+3] ); glEnd(); + + // why doesn't this work? + //glDrawArrays( GL_POINTS, 2*s+2, 1 ); } } PopColor(); - - - glEnableClientState( GL_VERTEX_ARRAY ); - glVertexPointer( 2, GL_FLOAT, 0, pts ); - + glDepthMask( GL_FALSE ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); // draw the filled polygon in transparent blue PushColor( 0, 0, 1, 0.1 ); + glDrawArrays( GL_POLYGON, 0, sample_count+1 ); // draw the beam strike points in black Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/stage.hh 2008-05-23 01:34:45 UTC (rev 6452) @@ -312,6 +312,18 @@ /** define a point in 3d space */ typedef struct { + float x, y, z; + } stg_vertex_t; + + /** define vertex and its color */ + typedef struct + { + float x, y, z, r, g, b, a; + } stg_colorvertex_t; + + /** define a point in 3d space */ + typedef struct + { stg_meters_t x, y, z; } stg_point3_t; @@ -1016,6 +1028,9 @@ /** Enlarge the bounding volume to include this point */ void Extend( stg_point3_t pt ); + + //GHashTable* blocks; + GArray lines; public: @@ -1033,9 +1048,13 @@ stg_usec_t RealTimeSinceStart(void); void PauseUntilNextUpdateTime(void); void IdleUntilNextUpdateTime( int (*idler)(void) ); + + void AddBlock( StgBlock* block ); + void RemoveBlock( StgBlock* block ); stg_usec_t GetSimInterval(){ return interval_sim; }; - + + Worldfile* GetWorldFile(){ return wf; }; virtual void Load( const char* worldfile_path ); @@ -1225,6 +1244,14 @@ virtual void Update(); virtual void UpdatePose(); virtual void Draw( uint32_t flags ); + + virtual void DrawBlocks(); + + // static wrapper for DrawBlocks() + static void DrawBlocks( gpointer dummykey, + StgModel* mod, + void* arg ); + virtual void DrawPicker(); virtual void DataVisualize(); @@ -1572,6 +1599,7 @@ void Map(); void UnMap(); // draw the block into the world + void DrawGlobal(); // draw the block in OpenGL using pts_global coords void Draw(); // draw the block in OpenGL void Draw2D(); // draw the block in OpenGL void DrawSolid(); // draw the block in OpenGL as a solid single color @@ -1601,9 +1629,12 @@ stg_meters_t global_zmax; StgModel* mod; //< model to which this block belongs - stg_point_int_t* pts_global; //< points defining a polygon in global coords - + stg_point_int_t* pts_global_pixels; //< points defining a polygon in global coords + stg_vertex_t* global_vertices; //< points defining a polygon in global coords + //GLubyte* colors; + GLubyte* edge_indices; + stg_color_t color; bool inherit_color; Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/world.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -147,6 +147,10 @@ this->paused = false; this->destroy = false; + // store a global table of all blocks, so they can be rendered all + // at once. + //this->blocks = g_hash_table_new( NULL, NULL ); + bzero( &this->extent, sizeof(this->extent)); for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ ) Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/libstage/worldgui.cc 2008-05-23 01:34:45 UTC (rev 6452) @@ -350,4 +350,3 @@ g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Floor_cb, NULL ); PopColor(); } - Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-05-21 13:36:13 UTC (rev 6451) +++ code/stage/trunk/worlds/fasr.world 2008-05-23 01:34:45 UTC (rev 6452) @@ -18,7 +18,7 @@ resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 10 # real-time interval between simulation updates in milliseconds +interval_real 0 # real-time interval between simulation updates in milliseconds paused 1 # configure the GUI window @@ -59,7 +59,7 @@ define autorob pioneer2dx ( color "red" - sicklaser(pose [ 0.040 0.000 0.000 ] samples 32 ) + sicklaser(pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) ctrl "fasr" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-05-23 11:58:53
|
Revision: 6456 http://playerstage.svn.sourceforge.net/playerstage/?rev=6456&view=rev Author: rtv Date: 2008-05-23 11:59:01 -0700 (Fri, 23 May 2008) Log Message: ----------- added -g flag to disable GUI from cmdline Modified Paths: -------------- code/stage/trunk/examples/ctrl/fasr.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/stage.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/examples/ctrl/fasr.cc =================================================================== --- code/stage/trunk/examples/ctrl/fasr.cc 2008-05-23 14:31:55 UTC (rev 6455) +++ code/stage/trunk/examples/ctrl/fasr.cc 2008-05-23 18:59:01 UTC (rev 6456) @@ -52,7 +52,6 @@ robot->work_get = 0; robot->work_put = 0; - //robot->flag = new StgFlag( stg_color_pack( 1,1,0,0.5 ), 3 ); robot->pos = (StgModelPosition*)mod; robot->laser = (StgModelLaser*)mod->GetModel( "laser:0" ); Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-05-23 14:31:55 UTC (rev 6455) +++ code/stage/trunk/libstage/main.cc 2008-05-23 18:59:01 UTC (rev 6456) @@ -4,31 +4,56 @@ Here is where I describe the Stage standalone program. */ +#include <getopt.h> -//#include "config.h" #include "stage_internal.hh" const char* PACKAGE = "Stage"; const char* VERSION = "3.dev"; +/* options descriptor */ +static struct option longopts[] = { + { "gui", no_argument, NULL, 'g' }, + // { "fast", no_argument, NULL, 'f' }, + { NULL, 0, NULL, 0 } +}; + + int main( int argc, char* argv[] ) { - printf( "%s %s\n", PACKAGE, VERSION ); - - if( argc < 2 ) + printf( "%s %s ", PACKAGE, VERSION ); + + int ch=0, optindex=0; + bool usegui = true; + + while ((ch = getopt_long(argc, argv, "gf", longopts, &optindex)) != -1) { - printf( "Usage: %s <worldfile>", PACKAGE ); - exit(0); + switch( ch ) + { + case 0: // long option given + printf( "option %s given", longopts[optindex].name ); + break; + case 'g': + usegui = false; + printf( "[GUI disabled]" ); + break; + case '?': + break; + default: + printf("unhandled option %c\n", ch ); + } } + + puts("");// end the first start-up line // initialize libstage Stg::Init( &argc, &argv ); - StgWorldGui world(800, 700, argv[0]); + StgWorld* world = usegui ? new StgWorldGui(800, 700, argv[0]) : new StgWorld(); - world.Load( argv[1] ); + world->Load( argv[argc-1] ); - while( ! world.TestQuit() ) - world.RealTimeUpdate(); + while( ! world->TestQuit() ) + world->RealTimeUpdate(); } Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-05-23 14:31:55 UTC (rev 6455) +++ code/stage/trunk/libstage/stage.cc 2008-05-23 18:59:01 UTC (rev 6456) @@ -427,7 +427,6 @@ int y, x; for(y = 0; y < img_height; y++) { - puts(""); for(x = 0; x < img_width; x++) { // skip blank (white) pixels Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-05-23 14:31:55 UTC (rev 6455) +++ code/stage/trunk/worlds/fasr.world 2008-05-23 18:59:01 UTC (rev 6456) @@ -5,21 +5,18 @@ # defines Pioneer-like robots include "pioneer.inc" - # defines 'map' object used for floorplans include "map.inc" - # defines sick laser include "sick.inc" - # set the resolution of the underlying raytrace model in meters resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 0 # real-time interval between simulation updates in milliseconds -paused 1 +interval_real 10 # real-time interval between simulation updates in milliseconds +paused 0 # configure the GUI window window This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-03 10:18:26
|
Revision: 6462 http://playerstage.svn.sourceforge.net/playerstage/?rev=6462&view=rev Author: rtv Date: 2008-06-03 10:18:26 -0700 (Tue, 03 Jun 2008) Log Message: ----------- many GL and FLTK improvements Modified Paths: -------------- code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/block.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/gl.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/stage_internal.hh code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldgui.cc code/stage/trunk/todo code/stage/trunk/worlds/fasr.world code/stage/trunk/worlds/pioneer.inc Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-03 17:18:26 UTC (rev 6462) @@ -13,43 +13,42 @@ glcolorstack.cc model.cc model_blinkenlight.cc + model_blobfinder.cc model_callbacks.cc model_fiducial.cc model_laser.cc model_load.cc model_position.cc - model_ranger.cc - model_blobfinder.cc model_props.cc + model_ranger.cc resource.cc stage.cc typetable.cc world.cc worldfile.cc - worldgui.cc + worldgui.cc ) - target_link_libraries( stage ${GLIB_LIBRARIES} - ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES} + ${FLTK_LIBRARIES} ltdl ) -add_executable( stagebinary main.cc -) +add_executable( stagebinary main.cc ) set_target_properties( stagebinary PROPERTIES OUTPUT_NAME stage ) target_link_libraries( stagebinary - stage + stage ) INSTALL(TARGETS stagebinary stage RUNTIME DESTINATION bin LIBRARY DESTINATION lib ) + INSTALL(FILES stage.hh DESTINATION include/stage-3.0) Modified: code/stage/trunk/libstage/block.cc =================================================================== --- code/stage/trunk/libstage/block.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/block.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -26,7 +26,6 @@ this->pts = (stg_point_t*)g_memdup( pts, pt_count * sizeof(stg_point_t)); // allocate space for the integer version of the block vertices this->pts_global_pixels = new stg_point_int_t[pt_count]; - this->global_vertices = new stg_vertex_t[2*pt_count+2]; this->zmin = zmin; this->zmax = zmax; @@ -38,18 +37,6 @@ // flag these as unset until StgBlock::Map() is called. this->global_zmin = -1; this->global_zmax = -1; - - this->edge_indices = new GLubyte[ 6 * pt_count ]; - for( int i=0; i<pt_count; i++ ) - { - this->edge_indices[6*i] = 2*i; - this->edge_indices[6*i+1] = 2*i+1; - this->edge_indices[6*i+2] = 2*i; - this->edge_indices[6*i+3] = 2*i+2; - this->edge_indices[6*i+4] = 2*i+1; - this->edge_indices[6*i+5] = 2*i+3; - } - } StgBlock::~StgBlock() @@ -58,7 +45,7 @@ g_free( pts ); g_array_free( rendered_points, TRUE ); - delete[] edge_indices; + //delete[] edge_indices; } void Stg::stg_block_list_destroy( GList* list ) @@ -111,18 +98,18 @@ // draw filled color polygons stg_color_t color = Color(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - PushColor( color ); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1.0, 1.0); - DrawSides(); - DrawTop(); - glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); + PushColor( color ); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1.0, 1.0); + DrawSides(); + 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( color, &r, &g, &b, &a ); - 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 + double r,g,b,a; + stg_color_unpack( color, &r, &g, &b, &a ); + PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a )); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); glDepthMask(GL_FALSE); @@ -134,74 +121,6 @@ PopColor(); } -void StgBlock::DrawGlobal() -{ - // draw filled color polygons - stg_color_t color = Color(); - - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - PushColor( color ); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1.0, 1.0); - - // glColorPointer(3, GL_UNSIGNED_BYTE, 0, colors ); - - // top - we skip every 2nd vertex - glVertexPointer( 3, GL_FLOAT, 6*sizeof(GLfloat), global_vertices ); - glDrawArrays( GL_TRIANGLE_FAN, 0, pt_count ); - - // sides - we use all vertices - glVertexPointer( 3, GL_FLOAT, 0, global_vertices ); - glDrawArrays( GL_TRIANGLE_STRIP, 0, pt_count*2+2 ); - - 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( color, &r, &g, &b, &a ); - PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a )); - - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); - glDepthMask(GL_FALSE); - - // we use the array of vertices - glDrawElements( GL_LINES, pt_count*6, GL_UNSIGNED_BYTE, edge_indices ); - - glDepthMask(GL_TRUE); - - PopColor(); - PopColor(); -} - -void StgBlock::Draw2D() -{ - // draw filled color polygons - stg_color_t color = Color(); - - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - PushColor( color ); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1.0, 1.0); - //DrawSides(); - 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( color, &r, &g, &b, &a ); - PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a )); - - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); - glDepthMask(GL_FALSE); - DrawTop(); - //DrawSides(); // skip this in 2d mode - faster! - glDepthMask(GL_TRUE); - - PopColor(); - PopColor(); -} - - void StgBlock::DrawSolid( void ) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); @@ -215,34 +134,21 @@ mod->Token(), (int)pt_count ); - double ppm = mod->GetWorld()->ppm; - // update the global coordinate list - stg_point3_t global; - + stg_point3_t local; + for( unsigned int p=0; p<pt_count; p++ ) { - stg_point3_t local; local.x = pts[p].x; local.y = pts[p].y; local.z = zmin; global = mod->LocalToGlobal( local ); - - // top surface vertex - global_vertices[2*p].x = global.x; - global_vertices[2*p].y = global.y; - global_vertices[2*p].z = global.z + zmax; - // bottom surface vertex - global_vertices[2*p+1].x = global.x; - global_vertices[2*p+1].y = global.y; - global_vertices[2*p+1].z = global.z; + pts_global_pixels[p].x = mod->GetWorld()->MetersToPixels( global.x ); + pts_global_pixels[p].y = mod->GetWorld()->MetersToPixels( global.y ); - pts_global_pixels[p].x = (int32_t)floor(global.x*ppm); - pts_global_pixels[p].y = (int32_t)floor(global.y*ppm); - PRINT_DEBUG2("loc [%.2f %.2f]", pts[p].x, pts[p].y ); @@ -251,13 +157,7 @@ pts_global_pixels[p].x, pts_global_pixels[p].y ); } - - // close the strip - // top surface vertex - global_vertices[2*pt_count] = global_vertices[0]; - global_vertices[2*pt_count+1] = global_vertices[1]; - - + // store the block's global vertical bounds for inspection by the // raytracer global_zmin = global.z; @@ -329,7 +229,7 @@ // examine all the points in the polygon StgBlock* block = (StgBlock*)it->data; - block->UnMap(); + block->UnMap(); // just in case for( unsigned int p=0; p < block->pt_count; p++ ) { @@ -375,8 +275,6 @@ // todo - scale min properly block->zmax *= scalez; block->zmin *= scalez; - - //block->Map(); } } Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/canvas.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -6,6 +6,8 @@ #include "stage_internal.hh" +using namespace Stg; + void StgCanvas::TimerCallback( StgCanvas* c ) { c->redraw(); @@ -27,10 +29,10 @@ selected_models = NULL; last_selection = NULL; - startx = starty = 0; + startx = starty = 0; panx = pany = stheta = sphi = 0.0; scale = 15.0; - interval = 100; //msec between redraws + interval = 50; //msec between redraws graphics = true; dragging = false; @@ -288,6 +290,7 @@ redraw(); } return 1; + case FL_FOCUS : case FL_UNFOCUS : //.... Return 1 if you want keyboard events, 0 otherwise @@ -338,7 +341,8 @@ void StgCanvas::draw() { // static int centerx = 0, centery = 0; - + //puts( "CANVAS" ); + if (!valid()) { valid(1); @@ -393,13 +397,13 @@ // enable vertex arrays glEnableClientState( GL_VERTEX_ARRAY ); //glEnableClientState( GL_COLOR_ARRAY ); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } + if( ! (showflags & STG_SHOW_TRAILS) ) + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - // Clear screen to bg color - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - // if following selected, shift the view to above the selected robot if( (showflags & STG_SHOW_FOLLOW) && last_selection ) { @@ -472,7 +476,7 @@ glEnable( GL_DEPTH_TEST ); } - if( showflags & STG_SHOW_TRAILS ) + if( showflags & STG_SHOW_TRAILRISE ) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); @@ -494,12 +498,32 @@ if( showflags & STG_SHOW_BLOCKS ) { for( GList* it=world->children; it; it=it->next ) - ((StgModel*)it->data)->DrawBlocks(); + { + StgModel* mod = ((StgModel*)it->data); + + if( mod->displaylist == 0 ) + { + mod->displaylist = glGenLists(1); + mod->BuildDisplayList( showflags ); // ready to be rendered + } + + // move into this model's local coordinate frame + glPushMatrix(); + gl_pose_shift( &mod->pose ); + gl_pose_shift( &mod->geom.pose ); + + // render the pre-recorded graphics for this model and + // its children + glCallList( mod->displaylist ); + + glPopMatrix(); + } } + //mod->Draw( showflags ); // draw the stuff that changes every update // draw everything else for( GList* it=world->children; it; it=it->next ) - ((StgModel*)it->data)->Draw( showflags ); + ((StgModel*)it->data)->Draw( showflags ); } if( world->GetRayList() ) @@ -526,6 +550,14 @@ glLoadIdentity(); glDisable( GL_DEPTH_TEST ); + // if trails are on, we need to clear the clock background + + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + + colorstack.Push( 0.8,0.8,1.0 ); // pale blue + glRectf( -w()/2, -h()/2, -w()/2 +120, -h()/2+20 ); + colorstack.Pop(); + char clockstr[50]; world->ClockString( clockstr, 50 ); Modified: code/stage/trunk/libstage/gl.cc =================================================================== --- code/stage/trunk/libstage/gl.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/gl.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -1,7 +1,6 @@ #include "stage_internal.hh" - // transform the current coordinate frame by the given pose void Stg::gl_coord_shift( double x, double y, double z, double a ) { @@ -16,15 +15,20 @@ } // TODO - this could be faster, but we don't draw a lot of text -void Stg::gl_draw_string( float x, float y, float z, char *str ) +void Stg::gl_draw_string( float x, float y, float z, const char *str ) { - char *c; + const char *c; glRasterPos3f(x, y,z); for (c=str; *c != '\0'; c++) glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, *c); } +void Stg::gl_speech_bubble( float x, float y, float z, const char* str ) +{ + gl_draw_string( x, y, z, str ); +} + void Stg::gl_draw_grid( stg_bounds3d_t vol ) { glBegin(GL_LINES); Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/main.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -49,11 +49,10 @@ // initialize libstage Stg::Init( &argc, &argv ); - StgWorld* world = usegui ? new StgWorldGui(800, 700, argv[0]) : new StgWorld(); + StgWorldGui world( 800, 700, argv[0]); - world->Load( argv[argc-1] ); + world.Load( argv[argc-1] ); - while( ! world->TestQuit() ) - world->RealTimeUpdate(); + world.Run(); } Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/model.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -44,6 +44,8 @@ ) @endverbatim +TODO PLAN: single array of all polygon vertices - model just keeps an index + @par Details - pose [x_pos:float y_pos:float heading:float] - specify the pose of the model in its parent's coordinate system @@ -169,6 +171,8 @@ world->AddModel( this ); bzero( &pose, sizeof(pose)); + if( parent ) + pose.z = parent->geom.size.z; bzero( &global_pose, sizeof(global_pose)); this->trail = g_array_new( false, false, sizeof(stg_trail_item_t) ); @@ -184,6 +188,8 @@ this->subs = 0; this->stall = false; + this->displaylist = 0; + this->geom.size.x = STG_DEFAULT_MOD_GEOM_SIZEX; this->geom.size.y = STG_DEFAULT_MOD_GEOM_SIZEX; this->geom.size.z = STG_DEFAULT_MOD_GEOM_SIZEX; @@ -349,7 +355,6 @@ const void* arg, stg_raytrace_sample_t* sample ) { - //LocalToGlobal( &pose ); world->Raytrace( LocalToGlobal(pose), range, func, @@ -379,7 +384,6 @@ stg_raytrace_sample_t* samples, uint32_t sample_count ) { - //LocalToGlobal( &pose ); world->Raytrace( LocalToGlobal(pose), range, fov, @@ -441,7 +445,7 @@ // pose->x, pose->y, pose->a ); } -void StgModel::Say( char* str ) +void StgModel::Say( const char* str ) { if( say_string ) free( say_string ); @@ -614,19 +618,19 @@ { //PRINT_DEBUG1( "%s.Map()", token ); - if( world->graphics && this->debug ) - { - double scale = 1.0 / world->ppm; - glPushMatrix(); - glTranslatef( 0,0,1 ); - glScalef( scale,scale,scale ); - } +// if( world->graphics && this->debug ) +// { +// double scale = 1.0 / world->ppm; +// glPushMatrix(); +// glTranslatef( 0,0,1 ); +// glScalef( scale,scale,scale ); +// } for( GList* it=blocks; it; it=it->next ) ((StgBlock*)it->data)->Map(); - if( world->graphics && this->debug ) - glPopMatrix(); +// if( world->graphics && this->debug ) +// glPopMatrix(); } void StgModel::UnMap() @@ -814,7 +818,7 @@ glPushMatrix(); gl_pose_shift( &pose ); gl_pose_shift( &geom.pose ); - LISTMETHOD( this->blocks, StgBlock*, Draw ); + glCallList( displaylist); glPopMatrix(); } } @@ -827,8 +831,6 @@ double dx = 0.2; double dy = 0.07; - //double z; - double timescale = 0.0000001; for( unsigned int i=0; i<trail->len; i++ ) @@ -880,18 +882,25 @@ void StgModel::DrawBlocks( ) { - LISTMETHOD( this->children, StgModel*, DrawBlocks ); + LISTMETHOD( this->blocks, StgBlock*, Draw ); + + // recursively draw the tree below this model + for( GList* it=children; it; it=it->next ) + { + StgModel* child = ((StgModel*)it->data); - LISTMETHOD( this->blocks, StgBlock*, DrawGlobal ); -} + glPushMatrix(); + gl_pose_shift( &child->pose ); + gl_pose_shift( &child->geom.pose ); + + child->DrawBlocks(); -void StgModel::DrawBlocks( gpointer dummykey, - StgModel* mod, void* dummyarg ) -{ - mod->DrawBlocks(); + glPopMatrix(); + } } + void StgModel::Draw( uint32_t flags ) { //PRINT_DEBUG1( "Drawing %s", token ); @@ -902,9 +911,31 @@ gl_pose_shift( &this->pose ); gl_pose_shift( &this->geom.pose ); - //if( this->say_string ) - // gl_speech_bubble( 0,0,0, this->say_string ); - + + if( this->say_string ) + { + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + + glPushMatrix(); + + PushColor( 0.8,0.8,1.0,1.0 ); // pale blue + + + glRotatef( -rtod(global_pose.a), 0,0,1 ); // out of the robot pose CS + // out of the world view CS + glRotatef( 90, 1,0,0 ); // out of the ground plane + + glRectf( 0,0,1,1 ); + PopColor(); + + PushColor( color ); + gl_speech_bubble( 0.3,0.3,0, this->say_string ); + PopColor(); + + glPopMatrix(); + } + + if( flags & STG_SHOW_DATA ) DataVisualize(); @@ -918,7 +949,7 @@ DrawBlinkenlights(); if( stall ) - gl_draw_string( 0,0,0.5, "!" ); + gl_draw_string( 0,0,0.5, "X" ); // shift up the CS to the top of this model gl_coord_shift( 0,0, this->geom.size.z, 0 ); @@ -986,7 +1017,7 @@ //stg_pose_t gpose = GetGlobalPose(); //glRotatef( 180 + rtod(-gpose.a),0,0,1 ); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); for( unsigned int i=0; i<blinkenlights->len; i++ ) { @@ -1035,7 +1066,16 @@ glPopMatrix(); // drop out of local coords } +void StgModel::BuildDisplayList( int flags ) +{ + glNewList( displaylist, GL_COMPILE ); + //printf("Model %s blocks %d\n", token, g_list_length( blocks ) ); + DrawBlocks(); + + glEndList(); +} + void StgModel::DataVisualize( void ) { // do nothing - subclasses will do more here @@ -1105,14 +1145,8 @@ pose.a = normalize( pose.a ); this->pose = pose; - - //memcpy( &this->pose, &pose, sizeof(stg_pose_t)); - - //this->pose.a = normalize(this->pose.a); + this->pose.a = normalize(this->pose.a); - //double hitx, hity; - //stg_model_test_collision2( mod, &hitx, &hity ); - this->NeedRedraw(); this->GPoseDirtyTree(); // global pose may have changed Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/model_load.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -343,6 +343,9 @@ else LoadControllerModule( lib ); } + + if( wf->PropertyExists( this->id, "say" )) + this->Say( wf->ReadString(this->id, "say", NULL )); // call any type-specific load callbacks this->CallCallbacks( &this->load ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/stage.hh 2008-06-03 17:18:26 UTC (rev 6462) @@ -518,6 +518,7 @@ const uint32_t STG_SHOW_ARROWS = (1<<9); const uint32_t STG_SHOW_FOOTPRINT = (1<<10); const uint32_t STG_SHOW_BLOCKS_2D = (1<<10); + const uint32_t STG_SHOW_TRAILRISE = (1<<11); // forward declare class StgWorld; @@ -550,7 +551,8 @@ }; /** Render a string at [x,y,z] in the current color */ - void gl_draw_string( float x, float y, float z, char *string); + void gl_draw_string( float x, float y, float z, const char *string); + void gl_speech_bubble( float x, float y, float z, const char* str ); void stg_block_list_scale( GList* blocks, @@ -926,9 +928,9 @@ friend class StgTime; private: - + static bool quit_all; // quit all worlds ASAP - static unsigned int next_id; //< initialized to zero, used to + static unsigned int next_id; //< initialized to zero, used tob //allocate unique sequential world ids static int AddBlockPixel( int x, int y, int z, stg_render_info_t* rinfo ) ; //< used as a callback by StgModel @@ -938,17 +940,13 @@ bool quit; // quit this world ASAP - - inline void MetersToPixels( stg_meters_t mx, stg_meters_t my, - int32_t *px, int32_t *py ); - + // convert a distance in meters to a distance in world occupancy grid pixels + int32_t MetersToPixels( stg_meters_t x ){ return (int32_t)floor(x * ppm) ; }; + void Initialize( const char* token, stg_msec_t interval_sim, stg_msec_t interval_real, double ppm ); - // double width, - // double height ); - virtual void PushColor( stg_color_t col ) { /* do nothing */ }; virtual void PushColor( double r, double g, double b, double a ) { /* do nothing */ }; @@ -974,7 +972,6 @@ bool dirty; ///< iff true, a gui redraw would be required - stg_usec_t interval_sleep_max; stg_usec_t interval_sim; ///< temporal resolution: milliseconds that elapse between simulated time steps stg_usec_t interval_log[INTERVAL_LOG_LEN]; @@ -989,8 +986,6 @@ void StartUpdatingModel( StgModel* mod ); void StopUpdatingModel( StgModel* mod ); - - //void MapBlock( StgBlock* block ); SuperRegion* CreateSuperRegion( int32_t x, int32_t y ); void DestroySuperRegion( SuperRegion* sr ); @@ -1019,6 +1014,8 @@ GHashTable* superregions; + static void UpdateCb( StgWorld* world); + GList* ray_list; // store rays traced for debugging purposes void RecordRay( double x1, double y1, double x2, double y2 ); @@ -1061,9 +1058,6 @@ virtual void Reload(); virtual void Save(); virtual bool Update(void); - virtual bool RealTimeUpdate(void); - virtual bool RealTimeUpdateWithIdler( int (*idler)(void) ); - virtual void AddModel( StgModel* mod ); virtual void RemoveModel( StgModel* mod ); @@ -1275,6 +1269,12 @@ GPtrArray* blinkenlights; void DrawBlinkenlights(); + /** OpenGL display list identifier */ + int displaylist; + + /** Compile the display list for this model */ + void BuildDisplayList( int flags ); + public: // constructor @@ -1283,7 +1283,7 @@ // destructor virtual ~StgModel(); - void Say( char* str ); + void Say( const char* str ); stg_id_t Id(){ return id; }; @@ -1295,7 +1295,7 @@ /** Should be called after all models are loaded, to do any last-minute setup */ void Init(); - + void AddFlag( StgFlag* flag ); void RemoveFlag( StgFlag* flag ); @@ -1351,7 +1351,7 @@ StgModel* GetModel( const char* name ); bool Stall(){ return this->stall; } int GuiMask(){ return this->gui_mask; }; - StgWorld* GetWorld(){ return this->world; } + inline StgWorld* GetWorld(){ return this->world; } /// return the root model of the tree containing this model StgModel* Root() @@ -1601,7 +1601,7 @@ void DrawGlobal(); // draw the block in OpenGL using pts_global coords void Draw(); // draw the block in OpenGL - void Draw2D(); // draw the block in OpenGL + //void Draw2D(); // draw the block in OpenGL void DrawSolid(); // draw the block in OpenGL as a solid single color void DrawFootPrint(); // draw the projection of the block onto the z=0 plane @@ -1631,9 +1631,7 @@ StgModel* mod; //< model to which this block belongs stg_point_int_t* pts_global_pixels; //< points defining a polygon in global coords - stg_vertex_t* global_vertices; //< points defining a polygon in global coords - //GLubyte* colors; - GLubyte* edge_indices; + //GLubyte* edge_indices; stg_color_t color; bool inherit_color; @@ -1674,110 +1672,120 @@ GQueue* colorstack; }; +// FLTK Gui includes +#include <FL/Fl.H> +//#include <FL/Fl_Box.H> +//#include <FL/Fl_Double_Window.H> +#include <FL/Fl_Gl_Window.H> +#include <FL/Fl_Menu_Bar.H> +#include <FL/Fl_Menu_Button.H> +#include <FL/Fl_Value_Slider.H> +#include <FL/Fl_Window.H> +#include <FL/Fl_Box.H> +#include <FL/fl_draw.H> +#include <FL/gl.h> // FLTK takes care of platform-specific GL stuff +#include <FL/glut.H> -/** Implements a FLTK / OpenGL graphical user interfae. -*/ - class StgCanvas : public Fl_Gl_Window - { - friend class StgWorldGui; // allow access to private members - - private: - GlColorStack colorstack; - double scale; - double panx, pany, stheta, sphi; - int startx, starty; - bool dragging; - bool rotating; - GList* selected_models; ///< a list of models that are currently - ///selected by the user - StgModel* last_selection; ///< the most recently selected model - ///(even if it is now unselected). - uint32_t showflags; - stg_msec_t interval; // window refresh interval in ms - - GList* ray_list; - void RecordRay( double x1, double y1, double x2, double y2 ); - void DrawRays(); - void ClearRays(); - void DrawGlobalGrid(); - - public: - StgCanvas( StgWorld* world, int x, int y, int W,int H); - ~StgCanvas(); +class StgCanvas : public Fl_Gl_Window +{ + friend class StgWorldGui; // allow access to private members - bool graphics; +private: + GlColorStack colorstack; + double scale; + double panx, pany, stheta, sphi; + int startx, starty; + bool dragging; + bool rotating; + GList* selected_models; ///< a list of models that are currently + ///selected by the user + StgModel* last_selection; ///< the most recently selected model + ///(even if it is now unselected). + uint32_t showflags; + stg_msec_t interval; // window refresh interval in ms + + GList* ray_list; + void RecordRay( double x1, double y1, double x2, double y2 ); + void DrawRays(); + void ClearRays(); + void DrawGlobalGrid(); + +public: + StgCanvas( StgWorld* world, int x, int y, int W,int H); + ~StgCanvas(); + + bool graphics; StgWorld* world; - - void FixViewport(int W,int H); - virtual void draw(); - virtual int handle( int event ); - void resize(int X,int Y,int W,int H); - - void CanvasToWorld( int px, int py, - double *wx, double *wy, double* wz ); - - StgModel* Select( int x, int y ); - inline void PushColor( stg_color_t col ) - { colorstack.Push( col ); } + void FixViewport(int W,int H); + virtual void draw(); + virtual int handle( int event ); + void resize(int X,int Y,int W,int H); - void PushColor( double r, double g, double b, double a ) - { colorstack.Push( r,g,b,a ); } + void CanvasToWorld( int px, int py, + double *wx, double *wy, double* wz ); - void PopColor(){ colorstack.Pop(); } + StgModel* Select( int x, int y ); - void InvertView( uint32_t invertflags ); + inline void PushColor( stg_color_t col ) + { colorstack.Push( col ); } + + void PushColor( double r, double g, double b, double a ) + { colorstack.Push( r,g,b,a ); } + + void PopColor(){ colorstack.Pop(); } + + void InvertView( uint32_t invertflags ); + + uint32_t GetShowFlags(){ return showflags; } + + void SetShowFlags( uint32_t flags ){ showflags = flags; } + + static void TimerCallback( StgCanvas* canvas ); +}; - uint32_t GetShowFlags(){ return showflags; } - void SetShowFlags( uint32_t flags ){ showflags = flags; } - static void TimerCallback( StgCanvas* canvas ); - }; - /** Extends StgWorld to present an OpenGL-based GUI to the user */ - class StgWorldGui : public StgWorld, public Fl_Window - { - friend class StgCanvas; +/** Extends StgWorld to implements an FLTK / OpenGL graphical user + interface. +*/ +class StgWorldGui : public StgWorld, public Fl_Window +{ + friend class StgCanvas; - private: - int wf_section; - StgCanvas* canvas; - Fl_Menu_Bar* mbar; - //StgBlockGrid* GetBlockGrid(){ return bgridx; }; - - public: - StgWorldGui(int W,int H,const char*L=0); - ~StgWorldGui(); - - // overload inherited methods - virtual bool RealTimeUpdate(); - virtual bool Update(); - - virtual void Load( const char* filename ); - virtual void Save(); +private: + int wf_section; + StgCanvas* canvas; + Fl_Menu_Bar* mbar; - // static callback functions - static void SaveCallback( Fl_Widget* wid, StgWorldGui* world ); +public: + StgWorldGui(int W,int H,const char*L=0); + ~StgWorldGui(); - virtual void PushColor( stg_color_t col ) - { canvas->PushColor( col ); } + /** Start the simulation and GUI. Does not return */ + void Run(); - virtual void PushColor( double r, double g, double b, double a ) - { canvas->PushColor( r,g,b,a ); } + virtual void Load( const char* filename ); + virtual void Save(); - virtual void PopColor() - { canvas->PopColor(); } + // static callback functions + static void SaveCallback( Fl_Widget* wid, StgWorldGui* world ); + + virtual void PushColor( stg_color_t col ) + { canvas->PushColor( col ); } + + virtual void PushColor( double r, double g, double b, double a ) + { canvas->PushColor( r,g,b,a ); } + + virtual void PopColor() + { canvas->PopColor(); } + + void DrawTree( bool leaves ); + void DrawFloor(); +}; - void DrawTree( bool leaves ); - void DrawFloor(); - }; - - - // end doc group libstage_utilities - - // BLOBFINDER MODEL -------------------------------------------------------- /** blobfinder data packet Modified: code/stage/trunk/libstage/stage_internal.hh =================================================================== --- code/stage/trunk/libstage/stage_internal.hh 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/stage_internal.hh 2008-06-03 17:18:26 UTC (rev 6462) @@ -1,4 +1,4 @@ -/** Stage internal header file - all libstage implementation *.cpp +/** Stage internal header file - all libstage implementation *.cc files include this header Author: Richard Vaughan (vaughan@...) Date: 13 Jan 2008 Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/world.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -386,9 +386,11 @@ } +#define DEBUG 1 + bool StgWorld::Update() { - //PRINT_DEBUG( "StgWorld::Update()" ); + PRINT_DEBUG( "StgWorld::Update()" ); if( paused ) return false; @@ -408,30 +410,16 @@ if( (quit_time > 0) && (sim_time >= quit_time) ) quit = true; - //interval_log[updates%INTERVAL_LOG_LEN] = RealTimeSinceStart() - real_time_now; - - return true; -} + stg_usec_t timenow = RealTimeSinceStart(); -bool StgWorld::RealTimeUpdate() - -{ - //PRINT_DEBUG( "StageWorld::RealTimeUpdate()" ); - bool updated = Update(); - if( interval_real ) - PauseUntilNextUpdateTime(); + interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - return updated; -} + //interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; -bool StgWorld::RealTimeUpdateWithIdler( int (*idler)(void) ) - -{ - //PRINT_DEBUG( "StageWorld::RealTimeUpdate()" ); - bool updated = Update(); - IdleUntilNextUpdateTime( idler ); - - return updated; + real_time_now = timenow; + //real_time_next_update += interval_real; + + return true; } void StgWorld::AddModel( StgModel* mod ) @@ -696,12 +684,10 @@ this->update_list = g_list_remove( this->update_list, mod ); } -void StgWorld::MetersToPixels( stg_meters_t mx, stg_meters_t my, - int32_t *px, int32_t *py ) -{ - *px = (int32_t)floor(mx* ppm); - *py = (int32_t)floor(my* ppm); -} +// int32_t StgWorld::MetersToPixels( stg_meters_t m ) +// { +// return (int32_t)floor(m * ppm); +// } int StgWorld::AddBlockPixel( int x, int y, int z, stg_render_info_t* rinfo ) Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-03 17:18:26 UTC (rev 6462) @@ -95,7 +95,6 @@ */ -//#include "config.h" // for PACKAGE strings etc #include "stage_internal.hh" #include "region.hh" @@ -113,10 +112,11 @@ static const char* MITEM_VIEW_FOLLOW = "View/Follow"; static const char* MITEM_VIEW_CLOCK = "View/Clock"; static const char* MITEM_VIEW_FOOTPRINTS = "View/Trails/Footprints"; -static const char* MITEM_VIEW_TRAILS = "View/Trails/Blocks"; -static const char* MITEM_VIEW_ARROWS = "View/Trails/Arrows"; +static const char* MITEM_VIEW_BLOCKSRISING = "View/Trails/Blocks rising"; +static const char* MITEM_VIEW_ARROWS = "View/Trails/Arrows rising"; +static const char* MITEM_VIEW_TRAILS = "View/Trail"; -// hack - get this from somewhere sensible +// hack - get this from somewhere sensible, like CMake's config file const char* PACKAGE_STRING = "Stage-3.dev"; void dummy_cb(Fl_Widget*, void* v) @@ -147,12 +147,6 @@ Fl::run(); } - -void StgWorldGui::SaveCallback( Fl_Widget* wid, StgWorldGui* world ) -{ - world->Save(); -} - void view_toggle_cb(Fl_Menu_Bar* menubar, StgCanvas* canvas ) { char picked[128]; @@ -171,13 +165,14 @@ else if( strcmp(picked, MITEM_VIEW_FOOTPRINTS ) == 0 ) canvas->InvertView( STG_SHOW_FOOTPRINT ); else if( strcmp(picked, MITEM_VIEW_ARROWS ) == 0 ) canvas->InvertView( STG_SHOW_ARROWS ); else if( strcmp(picked, MITEM_VIEW_TRAILS ) == 0 ) canvas->InvertView( STG_SHOW_TRAILS ); + else if( strcmp(picked, MITEM_VIEW_BLOCKSRISING ) == 0 ) canvas->InvertView( STG_SHOW_TRAILRISE ); else PRINT_ERR1( "Unrecognized menu item \"%s\" not handled", picked ); //printf( "value: %d\n", item->value() ); } -StgWorldGui::StgWorldGui(int W,int H,const char*L) +StgWorldGui::StgWorldGui(int W,int H,const char* L) : Fl_Window(0,0,W,H,L) { //size_range( 100,100 ); // set minimum window size @@ -213,15 +208,18 @@ mbar->add( MITEM_VIEW_CLOCK, 'c', (Fl_Callback*)view_toggle_cb, (void*)canvas, FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_CLOCK ? FL_MENU_VALUE : 0 )); + mbar->add( MITEM_VIEW_TRAILS, 't', (Fl_Callback*)view_toggle_cb, (void*)canvas, + FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_TRAILS ? FL_MENU_VALUE : 0 )); + mbar->add( MITEM_VIEW_FOOTPRINTS, FL_CTRL+'f', (Fl_Callback*)view_toggle_cb, (void*)canvas, FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_FOOTPRINT ? FL_MENU_VALUE : 0 )); mbar->add( MITEM_VIEW_ARROWS, FL_CTRL+'a', (Fl_Callback*)view_toggle_cb, (void*)canvas, FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_ARROWS ? FL_MENU_VALUE : 0 )); - mbar->add( MITEM_VIEW_TRAILS, FL_CTRL+'t', (Fl_Callback*)view_toggle_cb, (void*)canvas, - FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_TRAILS ? FL_MENU_VALUE : 0 )); - + mbar->add( MITEM_VIEW_BLOCKSRISING, FL_CTRL+'t', (Fl_Callback*)view_toggle_cb, (void*)canvas, + FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_TRAILRISE ? FL_MENU_VALUE : 0 )); + mbar->add( "Help", 0, 0, 0, FL_SUBMENU ); - mbar->add( "Help/About Stage...", FL_CTRL + 'f', (Fl_Callback *)About_cb ); + mbar->add( "Help/About Stage...", NULL, (Fl_Callback *)About_cb ); //mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback *)dummy_cb ); show(); } @@ -262,11 +260,12 @@ uint32_t quadtree = wf->ReadInt(wf_section, "show_tree", flags & STG_SHOW_QUADTREE ) ? STG_SHOW_QUADTREE : 0; uint32_t clock = wf->ReadInt(wf_section, "show_clock", flags & STG_SHOW_CLOCK ) ? STG_SHOW_CLOCK : 0; uint32_t trails = wf->ReadInt(wf_section, "show_trails", flags & STG_SHOW_TRAILS ) ? STG_SHOW_TRAILS : 0; + uint32_t trailsrising = wf->ReadInt(wf_section, "show_trails_rising", flags & STG_SHOW_TRAILRISE ) ? STG_SHOW_TRAILRISE : 0; uint32_t arrows = wf->ReadInt(wf_section, "show_arrows", flags & STG_SHOW_ARROWS ) ? STG_SHOW_ARROWS : 0; uint32_t footprints = wf->ReadInt(wf_section, "show_footprints", flags & STG_SHOW_FOOTPRINT ) ? STG_SHOW_FOOTPRINT : 0; canvas->SetShowFlags( grid | data | follow | blocks | quadtree | clock - | trails | arrows | footprints ); + | trails | arrows | footprints | trailsrising ); canvas->invalidate(); // we probably changed something // fix the GUI menu checkboxes to match @@ -295,6 +294,11 @@ // TODO - per model visualizations load } + void StgWorldGui::SaveCallback( Fl_Widget* wid, StgWorldGui* world ) + { + world->Save(); + } + void StgWorldGui::Save( void ) { PRINT_DEBUG1( "%s.Save()", token ); @@ -324,21 +328,34 @@ StgWorld::Save(); } -bool StgWorldGui::RealTimeUpdate() +void StgWorld::UpdateCb( StgWorld* world ) { - if( interval_real ) - return StgWorld::RealTimeUpdateWithIdler( Fl::check); - else - return Update(); + world->Update(); + + // need to reinstantiatethe timeout each time + Fl::repeat_timeout( world->interval_real/1e6, + (Fl_Timeout_Handler)UpdateCb, world ); } -bool StgWorldGui::Update() +static void idle_callback( StgWorld* world ) { - bool updated = StgWorld::Update(); - Fl::check(); // may redraw the window - return updated; + world->Update(); } +void StgWorldGui::Run() +{ + + // if a non-zero interval was requested, call Update() after that + // interval + if( interval_real > 0 ) + Fl::add_timeout( interval_real/1e6, (Fl_Timeout_Handler)UpdateCb, this ); + else // otherwise call Update() whenever there's no GUI work to do + Fl::add_idle( (Fl_Timeout_Handler)idle_callback, this ); + + Fl::run(); +} + + void StgWorldGui::DrawTree( bool drawall ) { g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Draw_cb, NULL ); Modified: code/stage/trunk/todo =================================================================== --- code/stage/trunk/todo 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/todo 2008-06-03 17:18:26 UTC (rev 6462) @@ -1,12 +1,17 @@ -- TODO -- +ESSENTIAL - 3d ray tracing - GUI rotations - docs + - finish CMake scripts + - clean up graphics implementation + +NICE - gripper + - pucks - power - energy - - pucks -- DONE -- @@ -15,8 +20,8 @@ multiple interfaces. See note in stg_driver.cc -- Large Scale Robotics paper - - 0.01M robots - - two or three benchmark controllers + - 0.1M robots + - two or three benchmark controllers (ended up as 1) - experimental design - sensible defaults - laser (all devices) Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/worlds/fasr.world 2008-06-03 17:18:26 UTC (rev 6462) @@ -26,16 +26,17 @@ rotate [ 0.000 0.000 ] scale 33.306 show_data 0 + interval 50 ) # load an environment bitmap -floorplan -( - name "cave" - size3 [16 16 0.5] - pose [0.000 0.000 0.000] - bitmap "bitmaps/cave.png" -) +#floorplan +#( +# name "cave" +# size3 [16 16 0.5] +# pose [0.000 0.000 0.000] +# bitmap "bitmaps/cave.png" +#) zone ( @@ -56,29 +57,29 @@ define autorob pioneer2dx ( color "red" - sicklaser(pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) + sicklaser( pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) ctrl "fasr" ) -autorob( pose [4.461 6.406 1.930] ) +autorob( pose [4.461 6.406 1.930] say "Booga" ) autorob( pose [6.635 6.458 -52.629] ) autorob( pose [6.385 5.805 -87.082] ) autorob( pose [7.004 5.327 170.536] ) autorob( pose [5.770 6.492 -10.539] ) autorob( pose [7.493 4.852 -156.719] ) autorob( pose [5.078 6.853 -37.549] ) -autorob( pose [6.147 7.399 4.964] ) -autorob( pose [4.065 5.583 125.796] ) -autorob( pose [7.487 6.926 -40.634] ) +#autorob( pose [6.147 7.399 4.964] ) +#autorob( pose [4.065 5.583 125.796] ) +#autorob( pose [7.487 6.926 -40.634] ) -autorob( pose [4.530 7.367 -113.456] ) -autorob( pose [6.071 5.138 -1.177] ) -autorob( pose [6.591 4.622 -68.007] ) -autorob( pose [5.454 7.540 135.162] ) -autorob( pose [4.707 5.855 -3.588] ) -autorob( pose [6.714 7.447 -73.332] ) -autorob( pose [5.582 5.724 -48.161] ) -autorob( pose [3.958 6.851 -102.651] ) -autorob( pose [5.127 5.109 23.582] ) -autorob( pose [7.534 5.825 -70.230] ) +#autorob( pose [4.530 7.367 -113.456] ) +#autorob( pose [6.071 5.138 -1.177] ) +#autorob( pose [6.591 4.622 -68.007] ) +#autorob( pose [5.454 7.540 135.162] ) +#autorob( pose [4.707 5.855 -3.588] ) +#autorob( pose [6.714 7.447 -73.332] ) +#autorob( pose [5.582 5.724 -48.161] ) +#autorob( pose [3.958 6.851 -102.651] ) +#autorob( pose [5.127 5.109 23.582] ) +#autorob( pose [7.534 5.825 -70.230] ) Modified: code/stage/trunk/worlds/pioneer.inc =================================================================== --- code/stage/trunk/worlds/pioneer.inc 2008-06-01 02:05:23 UTC (rev 6461) +++ code/stage/trunk/worlds/pioneer.inc 2008-06-03 17:18:26 UTC (rev 6462) @@ -36,7 +36,6 @@ ssize [0.01 0.05] ) - define pioneer2dx position ( # actual size This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-03 15:26:53
|
Revision: 6463 http://playerstage.svn.sourceforge.net/playerstage/?rev=6463&view=rev Author: rtv Date: 2008-06-03 15:27:00 -0700 (Tue, 03 Jun 2008) Log Message: ----------- fixed z-aware raytracing Modified Paths: -------------- code/stage/trunk/examples/ctrl/fasr.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_blobfinder.cc code/stage/trunk/libstage/model_fiducial.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.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-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/examples/ctrl/fasr.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -88,6 +88,8 @@ // there's anything in front double minleft = 1e6; double minright = 1e6; + + //return 0; for (uint32_t i = 0; i < sample_count; i++) { @@ -155,6 +157,9 @@ //printf( "Pose: [%.2f %.2f %.2f %.2f]\n", // pose.x, pose.y, pose.z, pose.a ); + //pose.z += 0.0001; + //robot->pos->SetPose( pose ); + if( robot->pos->GetFlagCount() < payload && hypot( -7-pose.x, -7-pose.y ) < 2.0 ) { Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/model.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -349,67 +349,68 @@ AddBlock( pts, 4, 0, 1, 0, true ); } + void StgModel::Raytrace( stg_pose_t pose, stg_meters_t range, stg_block_match_func_t func, const void* arg, - stg_raytrace_sample_t* sample ) + stg_raytrace_sample_t* sample, + bool ztest ) { world->Raytrace( LocalToGlobal(pose), range, func, this, arg, - sample ); + sample, + ztest ); } void StgModel::Raytrace( stg_radians_t bearing, stg_meters_t range, stg_block_match_func_t func, const void* arg, - stg_raytrace_sample_t* sample ) + stg_raytrace_sample_t* sample, + bool ztest ) { - stg_pose_t pose; - bzero(&pose,sizeof(pose)); - pose.a = bearing; - - Raytrace( pose, range, func, arg, sample ); + stg_pose_t raystart; + bzero( &raystart, sizeof(raystart)); + raystart.a = bearing; + + world->Raytrace( LocalToGlobal(raystart), + range, + func, + this, + arg, + sample, + ztest ); } -void StgModel::Raytrace( stg_pose_t pose, + +void StgModel::Raytrace( stg_radians_t bearing, stg_meters_t range, stg_radians_t fov, stg_block_match_func_t func, const void* arg, stg_raytrace_sample_t* samples, - uint32_t sample_count ) + uint32_t sample_count, + bool ztest ) { - world->Raytrace( LocalToGlobal(pose), + stg_pose_t raystart; + bzero( &raystart, sizeof(raystart)); + raystart.a = bearing; + + world->Raytrace( LocalToGlobal(raystart), range, fov, func, this, arg, samples, - sample_count ); + sample_count, + ztest ); } -void StgModel::Raytrace( stg_radians_t bearing, - stg_meters_t range, - stg_radians_t fov, - stg_block_match_func_t func, - const void* arg, - stg_raytrace_sample_t* samples, - uint32_t sample_count ) -{ - stg_pose_t pose; - bzero(&pose,sizeof(pose)); - pose.a = bearing; - - Raytrace( pose, range, fov, func, arg, samples, sample_count ); -} - - // utility for g_free()ing everything in a list void list_gfree( GList* list ) { @@ -948,11 +949,15 @@ if( blinkenlights ) DrawBlinkenlights(); - if( stall ) - gl_draw_string( 0,0,0.5, "X" ); - + if( stall ) + { + PushColor( 1,0,0,1 ); + gl_draw_string( 0,0,0.5, "!" ); + PopColor(); + } + // shift up the CS to the top of this model - gl_coord_shift( 0,0, this->geom.size.z, 0 ); + //gl_coord_shift( 0,0, this->geom.size.z, 0 ); // recursively draw the tree below this model for( GList* it=children; it; it=it->next ) @@ -1415,7 +1420,8 @@ range, (stg_block_match_func_t)collision_match, NULL, - &sample ); + &sample, + true ); if( sample.block ) hitmod = sample.block->Model(); Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/model_blobfinder.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -184,8 +184,7 @@ stg_raytrace_sample_t* samples = new stg_raytrace_sample_t[scan_width]; - Raytrace( pan, range, fov, blob_match, NULL, samples, scan_width ); - + Raytrace( pan, range, fov, blob_match, NULL, samples, scan_width, false ); // now the colors and ranges are filled in - time to do blob detection double yRadsPerPixel = fov / scan_height; Modified: code/stage/trunk/libstage/model_fiducial.cc =================================================================== --- code/stage/trunk/libstage/model_fiducial.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/model_fiducial.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -157,12 +157,13 @@ //printf( "bearing %.2f\n", RTOD(bearing) ); stg_raytrace_sample_t ray; - + Raytrace( dtheta, max_range_anon, fiducial_raytrace_match, NULL, - &ray ); + &ray, + false ); range = ray.range; StgModel* hitmod = ray.block->Model(); Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/model_laser.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -158,15 +158,12 @@ static bool laser_raytrace_match( StgBlock* testblock, StgModel* finder, - const void* zp ) + const void* dummy ) { // Ignore the model that's looking and things that are invisible to // lasers - double z = *(stg_meters_t*)zp; - if( (testblock->Model() != finder) && - testblock->IntersectGlobalZ( z ) && (testblock->Model()->GetLaserReturn() > 0 ) ) return true; // match! @@ -178,19 +175,24 @@ double bearing = -fov/2.0; double sample_incr = fov / (double)(sample_count-1); - stg_pose_t gpose = GetGlobalPose(); - stg_meters_t zscan = gpose.z + geom.size.z /2.0; - samples = g_renew( stg_laser_sample_t, samples, sample_count ); + + stg_pose_t rayorg; + bzero( &rayorg, sizeof(rayorg)); + rayorg.z = geom.size.z/2; for( unsigned int t=0; t<sample_count; t += resolution ) { stg_raytrace_sample_t sample; - Raytrace( bearing, + + rayorg.a = pose.a + bearing; + + Raytrace( rayorg, range_max, laser_raytrace_match, - &zscan, // height of scan line - &sample ); + NULL, + &sample, + true ); // z testing enabled samples[t].range = sample.range; @@ -306,6 +308,7 @@ return; glPushMatrix(); + //glTranslatef( 0,0, 0 ); // shoot the laser beam out at the right height glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at the right height // pack the laser hit points into a vertex array for fast rendering Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/model_load.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -350,6 +350,12 @@ // call any type-specific load callbacks this->CallCallbacks( &this->load ); + // MUST BE THE LAST THING LOADED + if( wf->PropertyExists( this->id, "alwayson" )) + { + if( wf->ReadInt( this->id, "alwayson", 0) > 0 ) + Startup(); + } if( this->debug ) printf( "Model \"%s\" is in debug mode\n", token ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/stage.hh 2008-06-03 22:27:00 UTC (rev 6463) @@ -995,7 +995,8 @@ stg_block_match_func_t func, StgModel* finder, const void* arg, - stg_raytrace_sample_t* sample ); + stg_raytrace_sample_t* sample, + bool ztest ); void Raytrace( stg_pose_t pose, stg_meters_t range, @@ -1004,7 +1005,8 @@ StgModel* finder, const void* arg, stg_raytrace_sample_t* samples, - uint32_t sample_count ); + uint32_t sample_count, + bool ztest ); void RemoveBlock( int x, int y, StgBlock* block ); //{ }//bgrid->RemoveBlock( x, y, block ); }; @@ -1195,39 +1197,43 @@ int TreeToPtrArray( GPtrArray* array ); - // raytraces from the point and heading identified by pose, in local coords + /** raytraces a single ray from the point and heading identified by + pose, in local coords */ void Raytrace( stg_pose_t pose, stg_meters_t range, stg_block_match_func_t func, const void* arg, - stg_raytrace_sample_t* sample ); - - // this version raytraces from our local origin in the direction [angle] - void Raytrace( stg_radians_t angle, - stg_meters_t range, - stg_block_match_func_t func, - const void* arg, - stg_raytrace_sample_t* sample ); - - // raytraces from the point and heading identified by pose, in local coords + stg_raytrace_sample_t* sample, + bool ztest = true ); + + /** raytraces multiple rays around the point and heading identified + by pose, in local coords */ void Raytrace( stg_pose_t pose, stg_meters_t range, stg_radians_t fov, stg_block_match_func_t func, const void* arg, stg_raytrace_sample_t* samples, - uint32_t sample_count ); + uint32_t sample_count, + bool ztest = true ); - // this version raytraces from our local origin in the direction [angle] - void Raytrace( stg_radians_t angle, - stg_meters_t range, - stg_radians_t fov, + void Raytrace( stg_radians_t bearing, + stg_meters_t range, stg_block_match_func_t func, const void* arg, + stg_raytrace_sample_t* sample, + bool ztest = true ); + + void Raytrace( stg_radians_t bearing, + stg_meters_t range, + stg_radians_t fov, + stg_block_match_func_t func, + const void* arg, stg_raytrace_sample_t* samples, - uint32_t sample_count ); + uint32_t sample_count, + bool ztest = true ); - + /** Causes this model and its children to recompute their global position instead of using a cached pose in StgModel::GetGlobalPose()..*/ @@ -1614,7 +1620,7 @@ { if( count ) *count = pt_count; return pts; }; bool IntersectGlobalZ( stg_meters_t z ) - { return( z >= global_zmin && z < global_zmax ); } + { return( z >= global_zmin && z <= global_zmax ); } stg_color_t Color() { return( inherit_color ? mod->GetColor() : color ); } Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/libstage/world.cc 2008-06-03 22:27:00 UTC (rev 6463) @@ -485,14 +485,15 @@ StgModel* model, const void* arg, stg_raytrace_sample_t* samples, // preallocated storage for samples - uint32_t sample_count ) // number of samples + uint32_t sample_count, + bool ztest ) // number of samples { pose.a -= fov/2.0; // direction of first ray stg_radians_t angle_incr = fov/(double)sample_count; for( uint32_t s=0; s < sample_count; s++ ) { - Raytrace( pose, range, func, model, arg, &samples[s] ); + Raytrace( pose, range, func, model, arg, &samples[s], ztest ); pose.a += angle_incr; } } @@ -504,7 +505,8 @@ stg_block_match_func_t func, StgModel* mod, const void* arg, - stg_raytrace_sample_t* sample ) + stg_raytrace_sample_t* sample, + bool ztest ) { // initialize the sample memcpy( &sample->pose, &pose, sizeof(stg_pose_t)); // pose stays fixed @@ -606,7 +608,7 @@ // if this block does not belong to the searching model and it // matches the predicate and it's in the right z range if( //block && (block->Model() != finder) && - //block->IntersectGlobalZ( pose.z ) && + (ztest ? block->IntersectGlobalZ( pose.z ) : true) && (*func)( block, mod, arg ) ) { // a hit! Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/worlds/fasr.world 2008-06-03 22:27:00 UTC (rev 6463) @@ -21,7 +21,7 @@ # configure the GUI window window ( - size [ 698.000 628.000 ] + #size [ 698.000 628.000 ] center [6.990 -4.040] rotate [ 0.000 0.000 ] scale 33.306 @@ -30,13 +30,13 @@ ) # load an environment bitmap -#floorplan -#( -# name "cave" -# size3 [16 16 0.5] -# pose [0.000 0.000 0.000] -# bitmap "bitmaps/cave.png" -#) +floorplan +( + name "cave" + size3 [16 16 0.8] + pose [0.000 0.000 0.000] + bitmap "bitmaps/cave.png" +) zone ( @@ -57,20 +57,24 @@ define autorob pioneer2dx ( color "red" + sicklaser( pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) - ctrl "fasr" + + ctrl "fasr" ) -autorob( pose [4.461 6.406 1.930] say "Booga" ) +sicklaser( pose [0 0 0] alwayson 1 color "white") + +autorob( pose [4.461 6.406 1.930] ) autorob( pose [6.635 6.458 -52.629] ) autorob( pose [6.385 5.805 -87.082] ) autorob( pose [7.004 5.327 170.536] ) autorob( pose [5.770 6.492 -10.539] ) autorob( pose [7.493 4.852 -156.719] ) autorob( pose [5.078 6.853 -37.549] ) -#autorob( pose [6.147 7.399 4.964] ) -#autorob( pose [4.065 5.583 125.796] ) -#autorob( pose [7.487 6.926 -40.634] ) +autorob( pose [6.147 7.399 4.964] ) +autorob( pose [4.065 5.583 125.796] ) +autorob( pose [7.487 6.926 -40.634] ) #autorob( pose [4.530 7.367 -113.456] ) #autorob( pose [6.071 5.138 -1.177] ) Modified: code/stage/trunk/worlds/simple.world =================================================================== --- code/stage/trunk/worlds/simple.world 2008-06-03 17:18:26 UTC (rev 6462) +++ code/stage/trunk/worlds/simple.world 2008-06-03 22:27:00 UTC (rev 6463) @@ -37,10 +37,10 @@ bitmap "bitmaps/cave.png" ) -define autorob pioneer2dx +define autorob fancypioneer2dx ( color "red" - #sicklaser( pose [ 0.040 0.000 0.000 ] samples 32 ) + fancysicklaser( pose [ 0.040 0.000 0.000 ] samples 32 ) #ctrl "wander" blinkenlight( pose [ 0.15 0.1 0 ] color "red" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <alexcb@us...> - 2008-06-04 11:02:18
|
Revision: 6467 http://playerstage.svn.sourceforge.net/playerstage/?rev=6467&view=rev Author: alexcb Date: 2008-06-04 11:02:22 -0700 (Wed, 04 Jun 2008) Log Message: ----------- added texture manager, and GL code to draw an image above stalled robots Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh Added Paths: ----------- code/stage/trunk/worlds/assets/readme.txt code/stage/trunk/worlds/assets/stall.png Removed Paths: ------------- code/stage/trunk/worlds/assets/beer_mark.png code/stage/trunk/worlds/assets/exclamation_mark.png code/stage/trunk/worlds/assets/exclamation_mark_2.png Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-04 00:15:13 UTC (rev 6466) +++ code/stage/trunk/libstage/canvas.cc 2008-06-04 18:02:22 UTC (rev 6467) @@ -5,6 +5,8 @@ */ #include "stage_internal.hh" +#include "texture_manager.hh" +#include "replace.h" using namespace Stg; @@ -340,6 +342,7 @@ void StgCanvas::draw() { + static bool loaded_texture = false; // static int centerx = 0, centery = 0; //puts( "CANVAS" ); @@ -361,7 +364,29 @@ glEnable( GL_LINE_SMOOTH ); glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); glDepthMask(GL_TRUE); - + glEnable( GL_TEXTURE_2D ); + + + //TODO find a better home for loading textures + if( loaded_texture == false ) { + + char* tmp = strdup( world->GetWorldFile()->filename ); + char* fullpath = (char*) malloc(PATH_MAX); + + //find path of images relative to the + getcwd(fullpath, PATH_MAX); + strcat( fullpath, "/" ); + strcat( fullpath, dirname(tmp)); + strcat( fullpath, "/assets/stall.png" ); + + GLuint stall_id = TextureManager::getInstance().loadTexture( fullpath ); + TextureManager::getInstance()._stall_texture_id = stall_id; + + loaded_texture = true; + free( tmp ); + free( fullpath ); + } + // install a font gl_font( FL_HELVETICA, 12 ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-04 00:15:13 UTC (rev 6466) +++ code/stage/trunk/libstage/model.cc 2008-06-04 18:02:22 UTC (rev 6467) @@ -105,6 +105,7 @@ //#define DEBUG #include "stage_internal.hh" +#include "texture_manager.hh" #include <limits.h> // basic model @@ -901,8 +902,40 @@ } +void StgModel::DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float alpha ) +{ + double sphi = canvas->sphi; + double stheta = canvas->stheta; -void StgModel::Draw( uint32_t flags, StgCanvas* canvas ) + glBindTexture( GL_TEXTURE_2D, 1 ); + + glColor4f( 1.0, 1.0, 1.0, alpha ); + glPushMatrix(); + + glTranslatef( 0.0, 0.0, 0.75 ); + + //orient 2d sprites to face the camera (left-right) + float a = rtod( sphi + pose.a ); + glRotatef( -a, 0.0, 0.0, 1.0 ); + + //orient to face camera (from top-front) + a = rtod( stheta ); + glRotatef( -(90.0-a), 1.0, 0.0, 0.0 ); + + //draw a square, with the textured image + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.25f, 0, -0.25f ); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.25f, 0, -0.25f ); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.25f, 0, 0.25f ); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.25f, 0, 0.25f ); + glEnd(); + + glPopMatrix(); + glBindTexture( GL_TEXTURE_2D, 0 ); +} + + +void StgModel::Draw( uint32_t flags, Stg::StgCanvas* canvas ) { //PRINT_DEBUG1( "Drawing %s", token ); @@ -958,12 +991,10 @@ if( stall ) { - PushColor( 1,0,0,1 ); - gl_draw_string( 0,0,0.5, "!" ); - PopColor(); + DrawImage( TextureManager::getInstance()._stall_texture_id, canvas, 0.85 ); } - // shift up the CS to the top of this model + // shift up the CS to the top of this model //gl_coord_shift( 0,0, this->geom.size.z, 0 ); // recursively draw the tree below this model Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-04 00:15:13 UTC (rev 6466) +++ code/stage/trunk/libstage/stage.hh 2008-06-04 18:02:22 UTC (rev 6467) @@ -1246,7 +1246,11 @@ virtual void Draw( uint32_t flags, StgCanvas* canvas ); virtual void DrawBlocks(); + + ///Draw the image stored in texture_id above the model + void DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float alpha ); + // static wrapper for DrawBlocks() static void DrawBlocks( gpointer dummykey, StgModel* mod, Deleted: code/stage/trunk/worlds/assets/beer_mark.png =================================================================== (Binary files differ) Deleted: code/stage/trunk/worlds/assets/exclamation_mark.png =================================================================== (Binary files differ) Deleted: code/stage/trunk/worlds/assets/exclamation_mark_2.png =================================================================== (Binary files differ) Added: code/stage/trunk/worlds/assets/readme.txt =================================================================== --- code/stage/trunk/worlds/assets/readme.txt (rev 0) +++ code/stage/trunk/worlds/assets/readme.txt 2008-06-04 18:02:22 UTC (rev 6467) @@ -0,0 +1,3 @@ +All images, must be square in some 2^x number, to a maximum of 512x512 (2^9) +The images should have depth 3 (RGB) or 4 (RGBA) + Added: code/stage/trunk/worlds/assets/stall.png =================================================================== (Binary files differ) Property changes on: code/stage/trunk/worlds/assets/stall.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-04 22:35:56
|
Revision: 6471 http://playerstage.svn.sourceforge.net/playerstage/?rev=6471&view=rev Author: rtv Date: 2008-06-04 22:35:21 -0700 (Wed, 04 Jun 2008) Log Message: ----------- improved the CMake build scripts to the point where the autotools stuff is now retired and will be removed Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/README.cmake code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/main.cc code/stage/trunk/libstageplugin/p_driver.cc Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-04 18:48:36 UTC (rev 6470) +++ code/stage/trunk/CMakeLists.txt 2008-06-05 05:35:21 UTC (rev 6471) @@ -1,26 +1,51 @@ PROJECT(Stage) -SET (STAGE_VERSION 3.0.0 CACHE STRING "Stage distribution version") -SET (STAGE_API_VERSION 3.0.0 CACHE STRING "Stage API version") -MESSAGE (STATUS "${PROJECT_NAME} version ${STAGE_VERSION}") +SET( V_MAJOR 3 ) +SET( V_MINOR 0 ) +SET( V_BUGFIX 0 ) +SET( VERSION ${V_MAJOR}.${V_MINOR}.${V_BUGFIX} ) + +MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}") + +# define some preprocessor strings that the code is expecting +ADD_DEFINITIONS( -DPROJECT='"'${PROJECT_NAME}'"' + -DVERSION='"'${VERSION}'"' ) + include(FindPkgConfig) pkg_check_modules( GLIB glib-2.0 ) - +pkg_check_modules( PLAYER playercore ) find_package(OPENGL REQUIRED) -if(APPLE) - set(FLTK_INCLUDE_DIR /opt/local/include) # MacPorts' install path -endif(APPLE) +# include(FindFLTK) doesn't seem to work for me, so we work a bit harder +set(FLTK_INCLUDE_DIR CMAKE_INCLUDE_PATH ) find_package(FLTK REQUIRED) -include_directories( . +# all targets need these include directories +include_directories( . + libstage replace - libstage ${GLIB_INCLUDE_DIRS} ${FLTK_INCLUDE_DIR} - ${OPENGL_INCLUDE_DIR} + ${OPENGL_INCLUDE_DIR} ) + +# all targets need these library directories +link_directories(${GLIB_LIBRARY_DIRS} + ${FLTK_LIBRARY_DIRS} + ${OPENGL_LIBRARY_DIRS} +) + +# generate a configuration header file in this dir +# CONFIGURE_FILE( config.h.cmake config.h ) + +# work through these subdirs ADD_SUBDIRECTORY(libstage) ADD_SUBDIRECTORY(examples) + +IF( PLAYER_FOUND ) +MESSAGE( "Found Player in ${PLAYER_INCLUDE_DIRS}") +ADD_SUBDIRECTORY(libstageplugin) +ENDIF( PLAYER_FOUND ) + Modified: code/stage/trunk/README.cmake =================================================================== --- code/stage/trunk/README.cmake 2008-06-04 18:48:36 UTC (rev 6470) +++ code/stage/trunk/README.cmake 2008-06-05 05:35:21 UTC (rev 6471) @@ -1,6 +1,6 @@ -Stage build using CMake instructions -author: Richard Vaughan, 2008.4.11 $Id$ +Stage v.3 build using CMake instructions +Author: Richard Vaughan, 2008.4.11 $Id$ * Purpose * @@ -15,12 +15,32 @@ Unpack the distribution or check it out from SVN. Change directory to the top level of the Stage source tree. -First, decide where you want to install Stage. The default -installation directory varies by system, but is often /usr/local on -Unix variants. This is easy and is often a good choice, but has the -disadvantage that installation needs root/sudo priviliges. To install -in the default location, do: +First, you may need to help CMake find your the libraries on which +Stage depends. For example, if you use MacPorts on OS X, packages are +usually installed in /opt/local, which is not in CMake's default +system search path. Add your non-standard software directories to +CMake's search paths by setting environment variables, e.g. in bash: +export CMAKE_INCLUDE_PATH=/opt/local/include +export CMAKE_LIBRARY_PATH=/opt/local/lib + +If you want to use Player with Stage, install Player first, then make +sure that pkg-config can find it. Test it like so: + +pkg-config --modversion playercore + +This should output the version number of the Player installation +(probably 2.2.0 or later). If not, add the location of Player's +pkg-config file to your PKG_CONFIG_PATH, eg. in bash: + +export PKG_CONFIG_PATH+=<Player installation prefix>/lib/pkgconfig + +Now that the supporting software is set up, you can decide where you +want to install Stage. The default installation directory varies by +system, but is often /usr/local on Unix variants. This is easy and is +often a good choice, but has the disadvantage that installation needs +root/sudo priviliges. To install in the default location, do: + $ cmake . If you wish to install Stage elsewhere, define the CMAKE_INSTALL_PATH @@ -28,11 +48,11 @@ substituting <prefix> with your chosen installation directory. - $ cmake -DCMAKE_INSTALL_PREFIX=PATH:<prefix> + $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> -For example to install in $HOME/stage, do: +For example to install in $HOME/playerstage, do: - $ cmake -DCMAKE_INSTALL_PREFIX=PATH:$HOME/stage + $ cmake -DCMAKE_INSTALL_PREFIX=$HOME/playerstage CMake will generate makefiles specifically for your machine. When this is done, you can inspect and edit the build settings using ccmake, or Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-04 18:48:36 UTC (rev 6470) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-05 05:35:21 UTC (rev 6471) @@ -1,10 +1,4 @@ -link_directories(${GLIB_LIBRARY_DIRS} - ${FLTK_LIBRARY_DIRS} - ${OPENGL_LIBRARY_DIRS} -) - - add_library( stage SHARED ancestor.cc block.cc @@ -37,11 +31,23 @@ ltdl ) +# causes the shared library to have a version number +set_target_properties( stage PROPERTIES + VERSION ${VERSION} +) + + add_executable( stagebinary main.cc ) set_target_properties( stagebinary PROPERTIES - OUTPUT_NAME stage ) + OUTPUT_NAME stage +) + +set_target_properties( stagebinary PROPERTIES + OUTPUT_NAME stage +) + target_link_libraries( stagebinary stage ) @@ -52,4 +58,4 @@ ) INSTALL(FILES stage.hh - DESTINATION include/stage-3.0) + DESTINATION include/${PROJECT_NAME}-${V_MAJOR}.${V_MINOR}) Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-04 18:48:36 UTC (rev 6470) +++ code/stage/trunk/libstage/main.cc 2008-06-05 05:35:21 UTC (rev 6471) @@ -8,8 +8,8 @@ #include "stage_internal.hh" -const char* PACKAGE = "Stage"; -const char* VERSION = "3.dev"; +//const char* PACKAGE = "Stage"; +//const char* VERSION = "3.dev"; /* options descriptor */ static struct option longopts[] = { @@ -21,7 +21,7 @@ int main( int argc, char* argv[] ) { - printf( "%s %s ", PACKAGE, VERSION ); + printf( "%s %s ", PROJECT, VERSION ); int ch=0, optindex=0; bool usegui = true; Modified: code/stage/trunk/libstageplugin/p_driver.cc =================================================================== --- code/stage/trunk/libstageplugin/p_driver.cc 2008-06-04 18:48:36 UTC (rev 6470) +++ code/stage/trunk/libstageplugin/p_driver.cc 2008-06-05 05:35:21 UTC (rev 6471) @@ -194,7 +194,7 @@ // driver can support and how to create a driver instance. void StgDriver_Register(DriverTable* table) { - printf( "\n ** Stage plugin v%s **", PACKAGE_VERSION ); + printf( "\n ** Stage plugin v%s **", "3.0dev" ); // XX TODO if( !player_quiet_startup ) { @@ -323,7 +323,7 @@ ifsrc = new InterfacePosition( player_addr, this, cf, section ); break; - case PLAYER_SONAR_CODE: + case PLAYER_SONAR_CODE: ifsrc = new InterfaceSonar( player_addr, this, cf, section ); break; @@ -351,9 +351,9 @@ // ifsrc = new InterfaceGraphics2d( player_addr, this, cf, section ); // break; - case PLAYER_GRAPHICS3D_CODE: - ifsrc = new InterfaceGraphics3d( player_addr, this, cf, section ); - break; +// case PLAYER_GRAPHICS3D_CODE: + // ifsrc = new InterfaceGraphics3d( player_addr, this, cf, section ); + //break; // case PLAYER_GRIPPER_CODE: // ifsrc = new InterfaceGripper( player_addr, this, cf, section ); @@ -568,7 +568,7 @@ { case PLAYER_SIMULATION_CODE: //if( stg_world_update( this->world, FALSE ) ) - world->RealTimeUpdate(); + world->Update(); //player_quit = TRUE; // set Player's global quit flag break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-04 22:36:40
|
Revision: 6472 http://playerstage.svn.sourceforge.net/playerstage/?rev=6472&view=rev Author: rtv Date: 2008-06-04 22:36:48 -0700 (Wed, 04 Jun 2008) Log Message: ----------- removed some of the autotools files Removed Paths: ------------- code/stage/trunk/Makefile.am code/stage/trunk/configure.ac code/stage/trunk/examples/Makefile.am code/stage/trunk/examples/ctrl/Makefile.am code/stage/trunk/libstage/Makefile.am code/stage/trunk/libstageplugin/Makefile.am Deleted: code/stage/trunk/Makefile.am =================================================================== --- code/stage/trunk/Makefile.am 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/Makefile.am 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,13 +0,0 @@ -SUBDIRS = replace libstage libstageplugin worlds docsrc examples - -# create the pkg-config entries -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = stage.pc - -clean-local: - rm -f config.cache - -LIBTOOL_DEPS = @LIBTOOL_DEPS@ - -libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck Deleted: code/stage/trunk/configure.ac =================================================================== --- code/stage/trunk/configure.ac 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/configure.ac 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,155 +0,0 @@ -dnl ----------------------------------------------------------------------- -dnl Stage Autoconf script -dnl $Id: configure.ac,v 1.24 2008-02-24 20:46:12 rtv Exp $ -dnl ----------------------------------------------------------------------- - -dnl AC_INIT( package, version ) -AC_INIT(Stage,3.0.0) - -dnl Check for a source file, to make sure any user-specified source -dnl dir is correct -AC_CONFIG_SRCDIR(libstage/model.cc) - -dnl Determine system type. We need to know if we're on Darwin so we -dnl can make spacial arrangements for OS X's weird framework system -AC_CANONICAL_SYSTEM -darwin=no -case $host in - *-darwin*) - darwin=yes ;; -esac -AM_CONDITIONAL(DARWIN, test "x$darwin" = "xyes") - - -dnl Initialize automake, requiring version 1.9 or better, -dnl using modern tar format and generate bzip tarballs -AM_INIT_AUTOMAKE([tar-ustar dist-bzip2 1.9]) - -dnl Need AC_PROG_MAKE_SET for recursive building -AC_PROG_MAKE_SET - -dnl Generate a configuration header called <config.h> and put all the C -dnl preprocessor defines in there -AC_CONFIG_HEADERS(config.h) - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_PROG_INSTALL - -dnl tell libtool to enable dynamic-loadable libraries -AC_LIBTOOL_DLOPEN -dnl enable libtool for building shared libraries in a platform-independent way -AC_PROG_LIBTOOL -AC_SUBST(LIBTOOL_DEPS) - -dnl Checks for header files of required libraries -AC_CHECK_HEADERS(stdint.h strings.h) - -dnl build mplementations of these in libreplace.a if these are missing -AC_REPLACE_FUNCS(dirname scandir basename) - -dnl Do we have pkg-config? -AC_CHECK_PROG(have_pkg_config,pkg-config,yes,no) -if test "x$have_pkg_config" = "xno"; then - AC_MSG_ERROR([pkg-config is required to build Stage. Install pkg-config, then run configure again.]) -fi - -dnl ==== OPEN GL ===== -dnl AX_CHECK_GLU - -dnl ==== GRAPHICS FILES ==== - -PKG_CHECK_MODULES(PIXBUF, gdk-pixbuf-2.0 >= 1.0, , - AC_MSG_ERROR([Required library gdk-pixbuf-2.0 not found. Install it and try again.]) -) - -dnl ==== FLTK GUI ==== - -AC_CHECK_PROGS(HAVE_FLTK_CONFIG, fltk-config, "") -if test -n "$HAVE_FLTK_CONFIG"; then - AC_SUBST(FLTK_CFLAGS,"`fltk-config --use-gl --use-images --cxxflags`") - AC_SUBST(FLTK_LIBS,"`fltk-config --use-gl --use-images --ldflags`") -else - AC_MSG_ERROR(Could not find fltk-config. Check that FLTK is installed.) -fi - -dnl ==== PLAYER ==== - -dnl add prefix to the pkg-config path in case things were installed there -dnl and the user didn't add it manually -export PKG_CONFIG_PATH=$prefix/lib/pkgconfig:$PKG_CONFIG_PATH - -dnl for libstageplugin, we need Player 2.1 or higher -PKG_CHECK_MODULES( PLAYER, playercore >= 2.1.0, - AC_DEFINE(INCLUDE_PLAYER,1,[building Player plugin]) - have_player=yes, - AC_MSG_WARN([No suitable Player installation detected.]) - have_player=no -) -AM_CONDITIONAL(HAVE_PLAYER, test "x$have_player" = "xyes") - - -dnl for libplayerc examples, we need libplayerc -PKG_CHECK_MODULES( PLAYERC, playerc >= 2.0.1, - AC_DEFINE(INCLUDE_PLAYERC,1,[building libplayerc examples]) - have_playerc=yes - , - AC_MSG_WARN([libplayerc was not found. ]) - have_playerc=no -) -AM_CONDITIONAL(HAVE_PLAYERC, test "x$have_playerc" = "xyes") - -AC_OUTPUT(Makefile - libstage/Makefile - libstageplugin/Makefile - docsrc/Makefile - worlds/Makefile - worlds/wifi/Makefile - worlds/bitmaps/Makefile - replace/Makefile - examples/Makefile - examples/libstage/Makefile - examples/libplayerc/Makefile - examples/ctrl/Makefile - stage.pc ) - -dnl should use AC_MSG_NOTICE(), but that's apparently not defined in -dnl autoconf 2.13. -AC_MSG_RESULT([]) -AC_MSG_RESULT([*************************************************************]) -AC_MSG_RESULT([]) -AC_MSG_RESULT([Stage will be built for a $host system, with the following tools and options:]) -AC_MSG_RESULT([ C++ compiler: $CXX $CXXFLAGS $PIXBUF_CFLAGS $FLTK_CFLAGS ]) -AC_MSG_RESULT([]) - -if test $have_player = yes; then - AC_MSG_RESULT([The Player plugin (libstageplugin) will be built using the following flags: ]) - AC_MSG_RESULT([ compiler: $PLAYER_CFLAGS]) - AC_MSG_RESULT([ linker: $PLAYER_LIBS]) - AC_MSG_RESULT([]) -else - AC_MSG_RESULT([Player was not found, so the Stage plugin for Player will NOT be built.]) - AC_MSG_RESULT([If you want the Player/Stage system, you must install Player and configure Stage again.]) - AC_MSG_RESULT([]) -fi - -if test "x$have_playerc" = "xyes"; then - AC_MSG_RESULT([libplayerc examples will be built using the following flags: ]) -dnl AC_MSG_RESULT([ compiler: $PLAYERC_CFLAGS]) -dnl AC_MSG_RESULT([ linker: $PLAYERC_LIBS]) - AC_MSG_RESULT([]) -else - AC_MSG_RESULT([libplayerc was not found, so the the examples will NOT be built.]) - AC_MSG_RESULT([]) -fi - -AC_MSG_RESULT([]) -AC_MSG_RESULT([Stage will be installed in:]) -AC_MSG_RESULT([ $prefix/]) -AC_MSG_RESULT([]) -AC_MSG_RESULT([To see the configuration options, do:]) -AC_MSG_RESULT([ ./configure --help]) -AC_MSG_RESULT([]) -AC_MSG_RESULT([When you're satisfied with the configuration, type 'make install'. ]) -AC_MSG_RESULT([]) Deleted: code/stage/trunk/examples/Makefile.am =================================================================== --- code/stage/trunk/examples/Makefile.am 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/examples/Makefile.am 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,3 +0,0 @@ -# $Id: Makefile.am,v 1.2 2008-02-22 21:20:47 rtv Exp $ - -SUBDIRS = libstage libplayerc ctrl Deleted: code/stage/trunk/examples/ctrl/Makefile.am =================================================================== --- code/stage/trunk/examples/ctrl/Makefile.am 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/examples/ctrl/Makefile.am 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,39 +0,0 @@ -# $Id: Makefile.am,v 1.4 2008-04-01 23:57:41 rtv Exp $ - -# system-wide compile flags - target-specific flags are added to each target below -AM_CPPFLAGS = -Wall -I. -I../../libstage -I$(top_srcdir)/replace @PIXBUF_CFLAGS@ @FLTK_CFLAGS@ -DRGBFILE=\"$(RGB)\" - - -lib_LTLIBRARIES = wander.la fasr.la source.la sink.la lasernoise.la - -# WANDER CONTROLLER -wander_la_SOURCES = wander.cc ../../libstage/stage.hh -wander_la_LDFLAGS = -module - -# FASR controller -fasr_la_SOURCES = fasr.cc ../../libstage/stage.hh -fasr_la_LDFLAGS = -module - -# resource source -source_la_SOURCES = source.cc ../../libstage/stage.hh -source_la_LDFLAGS = -module - -# resource sink -sink_la_SOURCES = sink.cc ../../libstage/stage.hh -sink_la_LDFLAGS = -module - -# laser noise -lasernoise_la_SOURCES = lasernoise.cc ../../libstage/stage.hh -lasernoise_la_LDFLAGS = -module - - -#lib_LTLIBRARIES += predator.la prey.la - -# PREDATOR CONTROLLER -#predator_la_SOURCES = predator.cc mydef.cc mydef.hh ../../libstage/stage.hh -#predator_la_LDFLAGS = -module - -# PREY CONTROLLER -#prey_la_SOURCES = prey.cc mydef.cc mydef.hh ../../libstage/stage.hh -#prey_la_LDFLAGS = -module - Deleted: code/stage/trunk/libstage/Makefile.am =================================================================== --- code/stage/trunk/libstage/Makefile.am 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/libstage/Makefile.am 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,65 +0,0 @@ - -# Automake script to build Stage's Makefile -# -# RTV 20021026 -# $Id: Makefile.am,v 1.11 2008-04-01 23:57:41 rtv Exp $ - -# install the header file for the Stage library -versionedincludedir = $(prefix)/include/stage-3.0 -versionedinclude_HEADERS = stage.hh - -# install the color database -pkgdata_DATA = rgb.txt - -RGB=$(datadir)/@PACKAGE@/rgb.txt - -# system-wide compile flags - target-specific flags are added to each target below -AM_CPPFLAGS = -Wall -I. -I$(top_srcdir)/replace @PIXBUF_CFLAGS@ @FLTK_CFLAGS@ -DRGBFILE=\"$(RGB)\" - -# build the stage library and program -lib_LTLIBRARIES = libstage.la -bin_PROGRAMS = stage - -libstage_la_SOURCES = \ - ../config.h \ - ancestor.cc \ - block.cc \ - canvas.cc \ - gl.cc \ - glcolorstack.cc \ - model.cc \ - model_callbacks.cc \ - model_fiducial.cc \ - model_laser.cc \ - model_load.cc \ - model_position.cc \ - model_ranger.cc \ - model_blobfinder.cc \ - model_blinkenlight.cc \ - model_props.cc \ - resource.cc \ - stage.cc \ - stage.hh \ - stage_internal.hh \ - texture_manager.cc \ - typetable.cc \ - world.cc \ - worldfile.cc \ - worldfile.hh \ - worldgui.cc - -libstage_la_LDFLAGS = -version-info 3:1:0 -rpath $(libdir) -libstage_la_LIBADD = @PIXBUF_LIBS@ @FLTK_LIBS@ -lltdl - -if DARWIN -libstage_la_LIBADD += -else -libstage_la_LIBADD += -lGLU -endif - - -# STAGE -stage_DEPENDENCIES = libstage.la -stage_SOURCES = main.cc -stage_LDADD = libstage.la - Deleted: code/stage/trunk/libstageplugin/Makefile.am =================================================================== --- code/stage/trunk/libstageplugin/Makefile.am 2008-06-05 05:35:21 UTC (rev 6471) +++ code/stage/trunk/libstageplugin/Makefile.am 2008-06-05 05:36:48 UTC (rev 6472) @@ -1,54 +0,0 @@ -# Automake script to build Libstageplugin's Makefile -# -# RTV 20071126 -# $Id: Makefile.am,v 1.3 2008-02-22 21:20:47 rtv Exp $ - -SUBDIRS = - -# system-wide compile flags - target-specific flags are added to each target below -AM_CPPFLAGS = -Wall -I. -I../libstage -I$(top_srcdir)/replace @PIXBUF_CFLAGS@ @FLTK_CFLAGS@ - -# if Player is present, build the plugin and the test program -if HAVE_PLAYER - lib_LTLIBRARIES = libstageplugin.la -endif - -# build a Player plugin from libstage plus Player driver hooks. -libstageplugin_la_SOURCES = \ - p_driver.cc \ - p_driver.h \ - p_graphics3d.cc \ - p_laser.cc \ - p_position.cc \ - p_simulation.cc \ - p_sonar.cc \ - stg_time.cc - -# TODO -# p_gripper.cc -# p_power.cc -# p_graphics2d.cc -# p_bumper.cc -# p_fiducial.cc -# p_ptz.cc -# p_wifi.cc -# p_speech.cc -# p_localize.cc -# p_map.cc -# p_blobfinder.cc - -libstageplugin_la_CPPFLAGS = $(AM_CPPFLAGS) @PLAYER_CFLAGS@ -libstageplugin_la_LDFLAGS = -version-info 1:0:0 -rpath $(libdir) -L../libstage -libstageplugin_la_LIBADD = ../libstage/libstage.la @PLAYER_LIBS@ - -# build a Player plugin from libstage plus Player driver hooks. -#libglutgraphics_la_SOURCES = glutgraphics.cc -#libglutgraphics_la_CPPFLAGS = $(AM_CPPFLAGS) @PLAYER_CFLAGS@ -#libglutgraphics_la_LDFLAGS = -version-info 1:0:0 -rpath $(libdir) -framework GLUT -#libglutgraphics_la_LIBADD = libstage.la @PLAYER_LIBS@ - -# build a player client that tests the plugin -#ptest_DEPENDENCIES = -#ptest_SOURCES = ptest.c -#ptest_CFLAGS = $(AM_CFLAGS) @PLAYER_CFLAGS@ -#ptest_LDADD = @PLAYERC_LIBS@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-04 22:43:39
|
Revision: 6473 http://playerstage.svn.sourceforge.net/playerstage/?rev=6473&view=rev Author: rtv Date: 2008-06-04 22:43:47 -0700 (Wed, 04 Jun 2008) Log Message: ----------- tweaking build scripts Modified Paths: -------------- code/stage/trunk/CMakeLists.txt Added Paths: ----------- code/stage/trunk/stagelogo.png Removed Paths: ------------- code/stage/trunk/bootstrap code/stage/trunk/logo.png Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-05 05:36:48 UTC (rev 6472) +++ code/stage/trunk/CMakeLists.txt 2008-06-05 05:43:47 UTC (rev 6473) @@ -49,3 +49,8 @@ ADD_SUBDIRECTORY(libstageplugin) ENDIF( PLAYER_FOUND ) +INSTALL(FILES rgb.txt stagelogo.png + DESTINATION share +) + + Deleted: code/stage/trunk/bootstrap =================================================================== --- code/stage/trunk/bootstrap 2008-06-05 05:36:48 UTC (rev 6472) +++ code/stage/trunk/bootstrap 2008-06-05 05:43:47 UTC (rev 6473) @@ -1,6 +0,0 @@ -#!/bin/sh - -# Generic bootstrap file. -# If this fails for you, check for a bootstrap file for your platform. - -autoreconf -fi Deleted: code/stage/trunk/logo.png =================================================================== (Binary files differ) Copied: code/stage/trunk/stagelogo.png (from rev 6470, code/stage/trunk/logo.png) =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-04 23:29:50
|
Revision: 6474 http://playerstage.svn.sourceforge.net/playerstage/?rev=6474&view=rev Author: rtv Date: 2008-06-04 23:29:49 -0700 (Wed, 04 Jun 2008) Log Message: ----------- working on fixing player plugin. now it works but timing could be better Modified Paths: -------------- code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model_ranger.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc code/stage/trunk/libstageplugin/p_driver.cc code/stage/trunk/libstageplugin/p_driver.h code/stage/trunk/worlds/simple.world Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstage/main.cc 2008-06-05 06:29:49 UTC (rev 6474) @@ -52,7 +52,7 @@ StgWorldGui world( 800, 700, argv[0]); world.Load( argv[argc-1] ); - + world.Start(); world.Run(); } Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstage/model_ranger.cc 2008-06-05 06:29:49 UTC (rev 6474) @@ -346,10 +346,10 @@ //double dz = rngr->size.z/2.0; // DEBUG: draw a point for the sensor pose - //glPointSize( 6 ); - //glBegin( GL_POINTS ); - //glVertex3f( rngr->pose.x, rngr->pose.y, rngr->pose.z ); - //glEnd(); + glPointSize( 6 ); + glBegin( GL_POINTS ); + glVertex3f( rngr->pose.x, rngr->pose.y, rngr->pose.z ); + glEnd(); // sensor FOV double sidelen = samples[s]; Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstage/stage.hh 2008-06-05 06:29:49 UTC (rev 6474) @@ -1776,6 +1776,8 @@ /** Start the simulation and GUI. Does not return */ void Run(); + void Start(); + void Cycle(); virtual void Load( const char* filename ); virtual void Save(); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-05 06:29:49 UTC (rev 6474) @@ -342,20 +342,28 @@ world->Update(); } -void StgWorldGui::Run() +void StgWorldGui::Start() { - // if a non-zero interval was requested, call Update() after that // interval if( interval_real > 0 ) Fl::add_timeout( interval_real/1e6, (Fl_Timeout_Handler)UpdateCb, this ); else // otherwise call Update() whenever there's no GUI work to do Fl::add_idle( (Fl_Timeout_Handler)idle_callback, this ); +} +void StgWorldGui::Run() +{ Fl::run(); } +void StgWorldGui::Cycle() +{ + if( Fl::ready() ) + Fl::check(); +} + void StgWorldGui::DrawTree( bool drawall ) { g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Draw_cb, NULL ); Modified: code/stage/trunk/libstageplugin/p_driver.cc =================================================================== --- code/stage/trunk/libstageplugin/p_driver.cc 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstageplugin/p_driver.cc 2008-06-05 06:29:49 UTC (rev 6474) @@ -168,7 +168,7 @@ extern bool player_quit; // init static vars -StgWorld* StgDriver::world = NULL; +StgWorldGui* StgDriver::world = NULL; int update_request = 0; @@ -437,7 +437,8 @@ // Set up the device. Return 0 if things go well, and -1 otherwise. int StgDriver::Setup() { - //puts("stage driver setup"); + puts("stage driver setup"); + world->Start(); return(0); } @@ -557,7 +558,7 @@ { Driver::ProcessMessages(); - //puts( "STG driver update" ); + // puts( "STG driver update" ); for( int i=0; i<(int)this->devices->len; i++ ) { @@ -568,7 +569,7 @@ { case PLAYER_SIMULATION_CODE: //if( stg_world_update( this->world, FALSE ) ) - world->Update(); + world->Cycle(); //player_quit = TRUE; // set Player's global quit flag break; @@ -578,11 +579,11 @@ // interface? This really needs some thought, as each model/interface // should have a configurable publishing rate. For now, I'm using the // world's update rate (which appears to be stored as msec). - BPG - double currtime; - GlobalTime->GetTimeDouble(&currtime); - if((currtime - interface->last_publish_time) >= - (interface->publish_interval_msec / 1e3)) - { + double currtime; + GlobalTime->GetTimeDouble(&currtime); + if((currtime - interface->last_publish_time) >= + (interface->publish_interval_msec / 1e3)) + { interface->Publish(); interface->last_publish_time = currtime; } Modified: code/stage/trunk/libstageplugin/p_driver.h =================================================================== --- code/stage/trunk/libstageplugin/p_driver.h 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/libstageplugin/p_driver.h 2008-06-05 06:29:49 UTC (rev 6474) @@ -38,7 +38,7 @@ virtual void Update(); /// all player devices share the same Stage world (for now) - static StgWorld* world; + static StgWorldGui* world; /// find the device record with this Player id Interface* LookupDevice( player_devaddr_t addr ); Modified: code/stage/trunk/worlds/simple.world =================================================================== --- code/stage/trunk/worlds/simple.world 2008-06-05 05:43:47 UTC (rev 6473) +++ code/stage/trunk/worlds/simple.world 2008-06-05 06:29:49 UTC (rev 6474) @@ -15,7 +15,7 @@ resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 10 # real-time interval between simulation updates in milliseconds +interval_real 100 # real-time interval between simulation updates in milliseconds paused 0 @@ -29,13 +29,13 @@ ) # load an environment bitmap -floorplan -( - name "cave" - size3 [16 16 0.5] - pose [0.000 0.000 0.000] - bitmap "bitmaps/cave.png" -) +#floorplan +#( +# name "cave" +# size3 [16 16 0.5] +# pose [0.000 0.000 0.000] +# bitmap "bitmaps/cave.png" +#) define autorob fancypioneer2dx ( @@ -51,23 +51,23 @@ autorob( pose [3.537 7.177 158.268] name "r0" ) autorob( pose [4.142 -7.764 -52.629] ) autorob( pose [6.320 3.775 22.445] ) -autorob( pose [-1.915 3.332 156.191] ) -autorob( pose [3.309 5.546 -109.062] ) -autorob( pose [7.209 4.552 89.455] ) -autorob( pose [-6.329 1.151 -164.935] ) -autorob( pose [-6.320 -5.692 -103.425] ) -autorob( pose [3.187 -7.170 -57.759] ) -autorob( pose [7.407 2.058 -57.823] ) +#autorob( pose [-1.915 3.332 156.191] ) +#autorob( pose [3.309 5.546 -109.062] ) +#autorob( pose [7.209 4.552 89.455] ) +#autorob( pose [-6.329 1.151 -164.935] ) +#autorob( pose [-6.320 -5.692 -103.425] ) +#autorob( pose [3.187 -7.170 -57.759] ) +#autorob( pose [7.407 2.058 -57.823] ) -autorob( pose [-6.370 2.754 -113.456] ) -autorob( pose [0.402 -6.819 -1.177] ) -autorob( pose [-2.892 -0.583 46.585] ) -autorob( pose [2.284 5.478 135.162] ) -autorob( pose [-2.483 -1.567 -3.588] ) -autorob( pose [-6.321 4.372 93.535] ) -autorob( pose [-4.204 -5.882 -35.760] ) -autorob( pose [-2.409 -4.979 -17.538] ) -autorob( pose [-6.692 5.179 -23.903] ) -autorob( pose [-1.958 0.013 -17.092] ) +#autorob( pose [-6.370 2.754 -113.456] ) +#autorob( pose [0.402 -6.819 -1.177] ) +#autorob( pose [-2.892 -0.583 46.585] ) +#autorob( pose [2.284 5.478 135.162] ) +#autorob( pose [-2.483 -1.567 -3.588] ) +#autorob( pose [-6.321 4.372 93.535] ) +#autorob( pose [-4.204 -5.882 -35.760] ) +#autorob( pose [-2.409 -4.979 -17.538] ) +#autorob( pose [-6.692 5.179 -23.903] ) +#autorob( pose [-1.958 0.013 -17.092] ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-05 12:40:44
|
Revision: 6479 http://playerstage.svn.sourceforge.net/playerstage/?rev=6479&view=rev Author: rtv Date: 2008-06-05 12:40:52 -0700 (Thu, 05 Jun 2008) Log Message: ----------- making sure Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/README code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/CMakeLists.txt 2008-06-05 19:40:52 UTC (rev 6479) @@ -5,6 +5,7 @@ SET( V_BUGFIX 0 ) SET( VERSION ${V_MAJOR}.${V_MINOR}.${V_BUGFIX} ) +SET( APIVERSION ${V_MAJOR}.${V_MINOR} ) MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}") Modified: code/stage/trunk/README =================================================================== --- code/stage/trunk/README 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/README 2008-06-05 19:40:52 UTC (rev 6479) @@ -4,6 +4,15 @@ * $Id: README,v 1.18 2006-03-29 05:13:44 rtv Exp $ **************************************************************************** +CMAKE building notes - to be integrated properly: + +export PLAYER=$HOME/Stage-3.0 +export PKG_CONFIG_PATH=$PLAYER/lib/pkgconfig + +export CMAKE_INCLUDE_PATH=/opt/local/include +export CMAKE_LIBRARY_PATH=/opt/local/lib +export CMAKE_INSTALL_PREFIX=$PLAYER + ** Release Notes for 2.0.2 ** New features: Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/libstage/main.cc 2008-06-05 19:40:52 UTC (rev 6479) @@ -8,9 +8,6 @@ #include "stage_internal.hh" -//const char* PACKAGE = "Stage"; -//const char* VERSION = "3.dev"; - /* options descriptor */ static struct option longopts[] = { { "gui", no_argument, NULL, 'g' }, @@ -18,7 +15,6 @@ { NULL, 0, NULL, 0 } }; - int main( int argc, char* argv[] ) { printf( "%s %s ", PROJECT, VERSION ); @@ -48,11 +44,22 @@ // initialize libstage Stg::Init( &argc, &argv ); + + // arguments at index optindex and later are not options, so they + // must be world file names - StgWorldGui world( 800, 700, argv[0]); - - world.Load( argv[argc-1] ); - world.Start(); - world.Run(); + while( optindex < argc ) + { + if( optindex > 0 ) + { + const char* worldfilename = argv[optindex]; + StgWorldGui* world = new StgWorldGui( 400, 300, worldfilename ); + world->Load( worldfilename ); + world->Start(); + } + optindex++; + } + + StgWorldGui::Run(); // run all the simulations } Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/libstage/model.cc 2008-06-05 19:40:52 UTC (rev 6479) @@ -965,7 +965,7 @@ float h = gl_height() / canvas->scale + 2*margin; - PushColor( 0.8,0.8,1.0,1.0 ); // pale blue + PushColor( 0,1,0,0.5 ); // transparent green glRectf( 0,0, w,h ); // draw bubble PopColor(); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/libstage/stage.hh 2008-06-05 19:40:52 UTC (rev 6479) @@ -1775,7 +1775,7 @@ ~StgWorldGui(); /** Start the simulation and GUI. Does not return */ - void Run(); + static void Run(); void Start(); void Cycle(); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-05 19:40:52 UTC (rev 6479) @@ -171,7 +171,6 @@ //printf( "value: %d\n", item->value() ); } - StgWorldGui::StgWorldGui(int W,int H,const char* L) : Fl_Window(0,0,W,H,L) { @@ -342,6 +341,7 @@ world->Update(); } + void StgWorldGui::Start() { // if a non-zero interval was requested, call Update() after that Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-05 18:33:59 UTC (rev 6478) +++ code/stage/trunk/worlds/fasr.world 2008-06-05 19:40:52 UTC (rev 6479) @@ -26,7 +26,7 @@ rotate [ 0.000 0.000 ] scale 33.306 show_data 0 - interval 50 + interval 100 ) # load an environment bitmap @@ -61,6 +61,8 @@ sicklaser( pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) ctrl "fasr" + + say "Autolab" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <alexcb@us...> - 2008-06-06 12:16:20
|
Revision: 6481 http://playerstage.svn.sourceforge.net/playerstage/?rev=6481&view=rev Author: alexcb Date: 2008-06-06 12:16:27 -0700 (Fri, 06 Jun 2008) Log Message: ----------- moved around status icon assets and modified install script Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/texture_manager.cc code/stage/trunk/libstage/texture_manager.hh Added Paths: ----------- code/stage/trunk/assets/ Removed Paths: ------------- code/stage/trunk/worlds/assets/ Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-05 20:59:40 UTC (rev 6480) +++ code/stage/trunk/CMakeLists.txt 2008-06-06 19:16:27 UTC (rev 6481) @@ -16,7 +16,8 @@ # define some preprocessor strings that the code is expecting ADD_DEFINITIONS( -DPROJECT=\"${PROJECT_NAME}\" - -DVERSION=\"${VERSION}\" ) + -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" + -DVERSION=\"${VERSION}\" ) include(FindPkgConfig) pkg_check_modules( GLIB glib-2.0 ) @@ -34,7 +35,7 @@ ${GLIB_INCLUDE_DIRS} ${FLTK_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} - /opt/local/include + ${CMAKE_INCLUDE_PATH} ) @@ -57,7 +58,12 @@ ENDIF( PLAYER_FOUND ) INSTALL(FILES rgb.txt stagelogo.png - DESTINATION share + DESTINATION share/stage ) +FILE( GLOB assets "assets/*.png" ) +INSTALL(FILES ${assets} + DESTINATION share/stage/assets +) + Copied: code/stage/trunk/assets (from rev 6480, code/stage/trunk/worlds/assets) Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-05 20:59:40 UTC (rev 6480) +++ code/stage/trunk/libstage/canvas.cc 2008-06-06 19:16:27 UTC (rev 6481) @@ -370,21 +370,10 @@ //TODO find a better home for loading textures if( loaded_texture == false ) { - char* tmp = strdup( world->GetWorldFile()->filename ); - char* fullpath = (char*) malloc(PATH_MAX); - - //find path of images relative to the - getcwd(fullpath, PATH_MAX); - strcat( fullpath, "/" ); - strcat( fullpath, dirname(tmp)); - strcat( fullpath, "/assets/stall.png" ); - - GLuint stall_id = TextureManager::getInstance().loadTexture( fullpath ); + GLuint stall_id = TextureManager::getInstance().loadTexture( "assets/stall.png" ); TextureManager::getInstance()._stall_texture_id = stall_id; loaded_texture = true; - free( tmp ); - free( fullpath ); } // install a font Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-05 20:59:40 UTC (rev 6480) +++ code/stage/trunk/libstage/main.cc 2008-06-06 19:16:27 UTC (rev 6481) @@ -48,6 +48,7 @@ // arguments at index optindex and later are not options, so they // must be world file names + bool loaded_world_file = false; while( optindex < argc ) { if( optindex > 0 ) @@ -56,9 +57,16 @@ StgWorldGui* world = new StgWorldGui( 400, 300, worldfilename ); world->Load( worldfilename ); world->Start(); + loaded_world_file = true; } optindex++; } + + if( loaded_world_file == false ) { + printf( "No world file specified.\n" ); + } + + StgWorldGui::Run(); // run all the simulations } Modified: code/stage/trunk/libstage/texture_manager.cc =================================================================== --- code/stage/trunk/libstage/texture_manager.cc 2008-06-05 20:59:40 UTC (rev 6480) +++ code/stage/trunk/libstage/texture_manager.cc 2008-06-06 19:16:27 UTC (rev 6481) @@ -8,26 +8,47 @@ */ #include "texture_manager.hh" +#include <sstream> +//TODO Windows Port +Fl_Shared_Image* TextureManager::loadImage( const char* filename ) +{ + if( filename[ 0 ] == '/' || filename[ 0 ] == '~' ) + return Fl_Shared_Image::get( filename ); + + const char* prefixes[] = { + ".", + INSTALL_PREFIX "/share/stage", + NULL + }; + + Fl_Shared_Image *img = NULL; + int i = 0; + while( img == NULL && prefixes[ i ] != NULL ) { + std::ostringstream oss; + oss << prefixes[ i ] << "/" << filename; + img = Fl_Shared_Image::get( oss.str().c_str() ); + std::cout << "loading from: " << oss.str() << std::endl; + i++; + } + return img; +} + GLuint TextureManager::loadTexture( const char *filename ) { GLuint texName; - Fl_Shared_Image *img = Fl_Shared_Image::get( filename ); + Fl_Shared_Image *img = loadImage( filename ); if( img == NULL ) { printf( "unable to open image: %s\n", filename ); return 0; } - std::cout << "loading image 1 " << std::endl; - //TODO display an error for incorrect depths if( img->d() != 3 && img->d() != 4 ) { printf( "unable to open image: %s - incorrect depth - should be 3 or 4\n", filename ); return 0; } - std::cout << "loading image 2 " << std::endl; - //TODO check for correct width/height - or convert it. guchar* pixels = (guchar*)(img->data()[0]); Modified: code/stage/trunk/libstage/texture_manager.hh =================================================================== --- code/stage/trunk/libstage/texture_manager.hh 2008-06-05 20:59:40 UTC (rev 6480) +++ code/stage/trunk/libstage/texture_manager.hh 2008-06-06 19:16:27 UTC (rev 6481) @@ -18,6 +18,9 @@ class TextureManager { private: TextureManager( void ) { } + + //try to load filename from relative dir, then install path + Fl_Shared_Image* loadImage( const char* filename ); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jeremy_asher@us...> - 2008-06-06 15:57:01
|
Revision: 6486 http://playerstage.svn.sourceforge.net/playerstage/?rev=6486&view=rev Author: jeremy_asher Date: 2008-06-06 15:57:04 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Improved speech bubbles Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/gl.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-06 21:09:56 UTC (rev 6485) +++ code/stage/trunk/CMakeLists.txt 2008-06-06 22:57:04 UTC (rev 6486) @@ -52,10 +52,10 @@ ADD_SUBDIRECTORY(libstage) ADD_SUBDIRECTORY(examples) -IF( PLAYER_FOUND ) -MESSAGE( "Found Player in ${PLAYER_INCLUDE_DIRS}") -ADD_SUBDIRECTORY(libstageplugin) -ENDIF( PLAYER_FOUND ) +#IF( PLAYER_FOUND ) +#MESSAGE( "Found Player in ${PLAYER_INCLUDE_DIRS}") +#ADD_SUBDIRECTORY(libstageplugin) +#ENDIF( PLAYER_FOUND ) INSTALL(FILES rgb.txt stagelogo.png DESTINATION share/stage Modified: code/stage/trunk/libstage/gl.cc =================================================================== --- code/stage/trunk/libstage/gl.cc 2008-06-06 21:09:56 UTC (rev 6485) +++ code/stage/trunk/libstage/gl.cc 2008-06-06 22:57:04 UTC (rev 6486) @@ -5,7 +5,7 @@ void Stg::gl_coord_shift( double x, double y, double z, double a ) { glTranslatef( x,y,z ); - glRotatef( rtod(a), 0,0,1 ); + glRotatef( rtod(a), 0,0,1 ); } // transform the current coordinate frame by the given pose @@ -28,7 +28,23 @@ gl_draw_string( x, y, z, str ); } +// draw an octagon with center rectangle dimensions w/h +// and outside margin m +void Stg::gl_draw_octagon( float w, float h, float m ) +{ + glBegin(GL_POLYGON); + glVertex2f( m+w, 0 ); + glVertex2f( w+2*m, m ); + glVertex2f( w+2*m, h+m ); + glVertex2f( m+w, h+2*m ); + glVertex2f( m, h+2*m ); + glVertex2f( 0, h+m ); + glVertex2f( 0, m ); + glVertex2f( m, 0 ); + glEnd(); +} + void Stg::gl_draw_grid( stg_bounds3d_t vol ) { glBegin(GL_LINES); Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-06 21:09:56 UTC (rev 6485) +++ code/stage/trunk/libstage/main.cc 2008-06-06 22:57:04 UTC (rev 6486) @@ -17,7 +17,7 @@ int main( int argc, char* argv[] ) { - printf( "%s %s ", PROJECT, VERSION ); + //printf( "%s %s ", PROJECT, VERSION ); int ch=0, optindex=0; bool usegui = true; Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-06 21:09:56 UTC (rev 6485) +++ code/stage/trunk/libstage/model.cc 2008-06-06 22:57:04 UTC (rev 6486) @@ -131,6 +131,12 @@ const bool STG_DEFAULT_MOD_OUTLINE = true; const bool STG_DEFAULT_MOD_RANGERRETURN = true; + +// speech bubble colors +const stg_color_t STG_BUBBLE_FILL = 0xFFC8C8FF; // light blue/grey +const stg_color_t STG_BUBBLE_BORDER = 0xFF000000; // black +const stg_color_t STG_BUBBLE_TEXT = 0xFF000000; // black + // constructor StgModel::StgModel( StgWorld* world, StgModel* parent, @@ -946,49 +952,64 @@ gl_pose_shift( &this->geom.pose ); + + + if( flags & STG_SHOW_DATA ) + DataVisualize(); + + if( gui_grid && (flags & STG_SHOW_GRID) ) + DrawGrid(); + + if( flag_list ) + DrawFlagList(); + + if( blinkenlights ) + DrawBlinkenlights(); + + // draw speech bubble if( this->say_string ) { - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - glPushMatrix(); + // move above the robot glTranslatef( 0, 0, 0.5 ); - glRotatef( -rtod(global_pose.a), 0,0,1 ); // out of the robot pose CS - glRotatef( -rtod(canvas->sphi), 0,0,1 ); // out of the world view CS - glRotatef( rtod(canvas->stheta)-90, 1,0,0 ); - glRotatef( 90, 1,0,0 ); // out of the ground plane + // rotate to face screen + glRotatef( -rtod(global_pose.a + canvas->sphi), 0,0,1 ); + glRotatef( rtod(canvas->stheta), 1,0,0 ); + const float m = 4 / canvas->scale; // margin + float w = gl_width( this->say_string ) / canvas->scale; // scaled text width + float h = gl_height() / canvas->scale; // scaled text height - const float margin = 0.1; - float w = gl_width( this->say_string ) / canvas->scale + 2*margin; - float h = gl_height() / canvas->scale + 2*margin; + // draw inside of bubble + PushColor( STG_BUBBLE_FILL ); + glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT ); + glPolygonMode( GL_FRONT, GL_FILL ); + glEnable( GL_POLYGON_OFFSET_FILL ); + glPolygonOffset( 1.0, 1.0 ); + gl_draw_octagon( w, h, m ); + glDisable( GL_POLYGON_OFFSET_FILL ); + PopColor(); + // draw outline of bubble + PushColor( STG_BUBBLE_BORDER ); + glLineWidth( 1 ); + glEnable( GL_LINE_SMOOTH ); + glPolygonMode( GL_FRONT, GL_LINE ); + gl_draw_octagon( w, h, m ); + glPopAttrib(); + PopColor(); - PushColor( 0,1,0,0.5 ); // transparent green - glRectf( 0,0, w,h ); // draw bubble - PopColor(); - + // draw text + PushColor( STG_BUBBLE_TEXT ); glTranslatef( 0, 0, 0.1 ); // draw text forwards of bubble - PushColor( color ); - gl_draw_string( margin, margin, 0.0, this->say_string ); + gl_draw_string( m, m, 0.0, this->say_string ); PopColor(); - + glPopMatrix(); } - - if( flags & STG_SHOW_DATA ) - DataVisualize(); - - if( gui_grid && (flags & STG_SHOW_GRID) ) - DrawGrid(); - - if( flag_list ) - DrawFlagList(); - - if( blinkenlights ) - DrawBlinkenlights(); - + if( stall ) { DrawImage( TextureManager::getInstance()._stall_texture_id, canvas, 0.85 ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-06 21:09:56 UTC (rev 6485) +++ code/stage/trunk/libstage/stage.hh 2008-06-06 22:57:04 UTC (rev 6486) @@ -553,8 +553,8 @@ /** Render a string at [x,y,z] in the current color */ void gl_draw_string( float x, float y, float z, const char *string); void gl_speech_bubble( float x, float y, float z, const char* str ); + void gl_draw_octagon( float w, float h, float m ); - void stg_block_list_scale( GList* blocks, stg_size_t* size ); void stg_block_list_destroy( GList* list ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jeremy_asher@us...> - 2008-06-10 11:58:48
|
Revision: 6526 http://playerstage.svn.sourceforge.net/playerstage/?rev=6526&view=rev Author: jeremy_asher Date: 2008-06-10 11:58:52 -0700 (Tue, 10 Jun 2008) Log Message: ----------- FLTK menu updates Modified Paths: -------------- code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Added Paths: ----------- code/stage/trunk/assets/logo.png Removed Paths: ------------- code/stage/trunk/libstage/logo.png Copied: code/stage/trunk/assets/logo.png (from rev 6494, code/stage/trunk/libstage/logo.png) =================================================================== (Binary files differ) Deleted: code/stage/trunk/libstage/logo.png =================================================================== (Binary files differ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-10 18:26:41 UTC (rev 6525) +++ code/stage/trunk/libstage/stage.hh 2008-06-10 18:58:52 UTC (rev 6526) @@ -1874,9 +1874,12 @@ virtual bool Save( const char* filename ); // static callback functions + static void LoadCallback( Fl_Widget* wid, StgWorldGui* world ); static void SaveCallback( Fl_Widget* wid, StgWorldGui* world ); static void SaveAsCallback( Fl_Widget* wid, StgWorldGui* world ); static void QuitCallback( Fl_Widget* wid, StgWorldGui* world ); + static void About_cb( Fl_Widget* wid ); + static void view_toggle_cb(Fl_Menu_Bar* menubar, StgCanvas* canvas ); static void WindowCallback( Fl_Widget* wid, StgWorldGui* world ); bool SaveAsDialog(); Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-10 18:26:41 UTC (rev 6525) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-10 18:58:52 UTC (rev 6526) @@ -120,58 +120,9 @@ // hack - get this from somewhere sensible, like CMake's config file const char* PACKAGE_STRING = "Stage-3.dev"; -void dummy_cb(Fl_Widget*, void* v) -{ -} -void About_cb(Fl_Widget*, void* v) -{ - fl_register_images(); - Fl_Window win(400,200); // make a window - Fl_Box box(10,20,400-20,80 ); // widget that will contain image - // TODO - get image from the install path - Fl_PNG_Image png("logo.png"); // load image into ram - box.image(png); // attach image to box - Fl_Multiline_Output text( 20,120, 400-20, 100 ); - text.box( FL_NO_BOX ); - char buf[256]; - snprintf( buf, 255, - "%s\n" - "Part of the Player Project\n" - "http://playerstage.sourceforge.net\n"; - "Copyright 2000-2008 Richard Vaughan and contributors", - PACKAGE_STRING ); - text.value( buf ); - win.show(); - Fl::run(); -} - -void view_toggle_cb(Fl_Menu_Bar* menubar, StgCanvas* canvas ) -{ - char picked[128]; - menubar->item_pathname(picked, sizeof(picked)-1); - - //printf("CALLBACK: You picked '%s'\n", picked); - - // this is slow and a little ugly, but it's the least hacky approach I think - if( strcmp(picked, MITEM_VIEW_DATA ) == 0 ) canvas->InvertView( STG_SHOW_DATA ); - else if( strcmp(picked, MITEM_VIEW_BLOCKS ) == 0 ) canvas->InvertView( STG_SHOW_BLOCKS ); - else if( strcmp(picked, MITEM_VIEW_GRID ) == 0 ) canvas->InvertView( STG_SHOW_GRID ); - else if( strcmp(picked, MITEM_VIEW_FOLLOW ) == 0 ) canvas->InvertView( STG_SHOW_FOLLOW ); - else if( strcmp(picked, MITEM_VIEW_QUADTREE ) == 0 ) canvas->InvertView( STG_SHOW_QUADTREE ); - else if( strcmp(picked, MITEM_VIEW_OCCUPANCY ) == 0 ) canvas->InvertView( STG_SHOW_OCCUPANCY ); - else if( strcmp(picked, MITEM_VIEW_CLOCK ) == 0 ) canvas->InvertView( STG_SHOW_CLOCK ); - else if( strcmp(picked, MITEM_VIEW_FOOTPRINTS ) == 0 ) canvas->InvertView( STG_SHOW_FOOTPRINT ); - else if( strcmp(picked, MITEM_VIEW_ARROWS ) == 0 ) canvas->InvertView( STG_SHOW_ARROWS ); - else if( strcmp(picked, MITEM_VIEW_TRAILS ) == 0 ) canvas->InvertView( STG_SHOW_TRAILS ); - else if( strcmp(picked, MITEM_VIEW_BLOCKSRISING ) == 0 ) canvas->InvertView( STG_SHOW_TRAILRISE ); - else PRINT_ERR1( "Unrecognized menu item \"%s\" not handled", picked ); - - //printf( "value: %d\n", item->value() ); -} - StgWorldGui::StgWorldGui(int W,int H,const char* L) : Fl_Window(0,0,W,H,L) { @@ -188,8 +139,9 @@ end(); mbar->add( "File", 0, 0, 0, FL_SUBMENU ); - mbar->add( "File/Save File", FL_CTRL + 's', (Fl_Callback *)SaveCallback, this ); - mbar->add( "File/Save File &As...", FL_CTRL + FL_SHIFT + 's', (Fl_Callback *)SaveAsCallback, this, FL_MENU_DIVIDER ); + mbar->add( "File/&Load World...", FL_CTRL + 'l', (Fl_Callback *)LoadCallback, this, FL_MENU_DIVIDER ); + mbar->add( "File/Save World", FL_CTRL + 's', (Fl_Callback *)SaveCallback, this ); + mbar->add( "File/Save World &As...", FL_CTRL + FL_SHIFT + 's', (Fl_Callback *)SaveAsCallback, this, FL_MENU_DIVIDER ); mbar->add( "File/Exit", FL_CTRL+'q', (Fl_Callback *)QuitCallback, this ); mbar->add( "View", 0, 0, 0, FL_SUBMENU ); @@ -298,6 +250,11 @@ // TODO - per model visualizations load } +void StgWorldGui::LoadCallback( Fl_Widget* wid, StgWorldGui* world ) +{ + // implement me +} + void StgWorldGui::SaveCallback( Fl_Widget* wid, StgWorldGui* world ) { // save to current file @@ -350,9 +307,9 @@ { int choice; choice = fl_choice("Do you want to save?", - "Cancel", // ->0: defaults to ESC - "Yes", // ->1 - "No" // ->2 + "&Cancel", // ->0: defaults to ESC + "&Yes", // ->1 + "&No" // ->2 ); switch (choice) { @@ -386,6 +343,62 @@ exit(0); } +void StgWorldGui::view_toggle_cb( Fl_Menu_Bar* menubar, StgCanvas* canvas ) +{ + char picked[128]; + menubar->item_pathname(picked, sizeof(picked)-1); + + //printf("CALLBACK: You picked '%s'\n", picked); + + // this is slow and a little ugly, but it's the least hacky approach I think + if( strcmp(picked, MITEM_VIEW_DATA ) == 0 ) canvas->InvertView( STG_SHOW_DATA ); + else if( strcmp(picked, MITEM_VIEW_BLOCKS ) == 0 ) canvas->InvertView( STG_SHOW_BLOCKS ); + else if( strcmp(picked, MITEM_VIEW_GRID ) == 0 ) canvas->InvertView( STG_SHOW_GRID ); + else if( strcmp(picked, MITEM_VIEW_FOLLOW ) == 0 ) canvas->InvertView( STG_SHOW_FOLLOW ); + else if( strcmp(picked, MITEM_VIEW_QUADTREE ) == 0 ) canvas->InvertView( STG_SHOW_QUADTREE ); + else if( strcmp(picked, MITEM_VIEW_OCCUPANCY ) == 0 ) canvas->InvertView( STG_SHOW_OCCUPANCY ); + else if( strcmp(picked, MITEM_VIEW_CLOCK ) == 0 ) canvas->InvertView( STG_SHOW_CLOCK ); + else if( strcmp(picked, MITEM_VIEW_FOOTPRINTS ) == 0 ) canvas->InvertView( STG_SHOW_FOOTPRINT ); + else if( strcmp(picked, MITEM_VIEW_ARROWS ) == 0 ) canvas->InvertView( STG_SHOW_ARROWS ); + else if( strcmp(picked, MITEM_VIEW_TRAILS ) == 0 ) canvas->InvertView( STG_SHOW_TRAILS ); + else if( strcmp(picked, MITEM_VIEW_BLOCKSRISING ) == 0 ) canvas->InvertView( STG_SHOW_TRAILRISE ); + else PRINT_ERR1( "Unrecognized menu item \"%s\" not handled", picked ); + + //printf( "value: %d\n", item->value() ); +} + +void StgWorldGui::About_cb( Fl_Widget* ) +{ + fl_register_images(); + Fl_Window win(400,200); // make a window + Fl_Box box(10,20,400-20,80 ); // widget that will contain image + + // temporary hack + const char* stagepath = getenv("STAGEPATH"); + const char* logopath = "../../../assets/logo.png"; + char* fullpath = (char*)malloc( strlen(stagepath) + strlen(logopath) + 2 ); + strcpy( fullpath, stagepath ); + strcat( fullpath, "/" ); + strcat( fullpath, logopath ); + printf("fullpath: %s\n", fullpath); + Fl_PNG_Image png(fullpath); // load image into ram + free( fullpath ); + box.image(png); // attach image to box + + Fl_Multiline_Output text( 20,120, 400-20, 100 ); + text.box( FL_NO_BOX ); + char buf[256]; + snprintf( buf, 255, + "%s\n" + "Part of the Player Project\n" + "http://playerstage.sourceforge.net\n"; + "Copyright 2000-2008 Richard Vaughan and contributors", + PACKAGE_STRING ); + text.value( buf ); + win.show(); + Fl::run(); +} + bool StgWorldGui::Save( const char* filename ) { PRINT_DEBUG1( "%s.Save()", token ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jeremy_asher@us...> - 2008-06-10 13:51:21
|
Revision: 6527 http://playerstage.svn.sourceforge.net/playerstage/?rev=6527&view=rev Author: jeremy_asher Date: 2008-06-10 13:51:30 -0700 (Tue, 10 Jun 2008) Log Message: ----------- Fixed minor cmake build issues Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/CMakeLists.txt Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-10 18:58:52 UTC (rev 6526) +++ code/stage/trunk/CMakeLists.txt 2008-06-10 20:51:30 UTC (rev 6527) @@ -23,7 +23,7 @@ #variable_watch(PLAYER_FOUND) #variable_watch(PLAYER_VERSION) pkg_search_module( GLIB glib-2.0 ) -pkg_search_module( PLAYER playercore>=2.1 ) +pkg_search_module( PLAYER playercore ) find_package(OPENGL REQUIRED) # include(FindFLTK) doesn't seem to work for me, so we work a bit harder Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-10 18:58:52 UTC (rev 6526) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-10 20:51:30 UTC (rev 6527) @@ -1,5 +1,6 @@ add_library( stage SHARED + stage.hh # get headers into IDE projects ancestor.cc block.cc canvas.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jeremy_asher@us...> - 2008-06-13 17:54:00
|
Revision: 6562 http://playerstage.svn.sourceforge.net/playerstage/?rev=6562&view=rev Author: jeremy_asher Date: 2008-06-13 16:48:52 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Linux build fixes, thanks Toby Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/worldgui.cc Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-13 23:48:32 UTC (rev 6561) +++ code/stage/trunk/CMakeLists.txt 2008-06-13 23:48:52 UTC (rev 6562) @@ -7,37 +7,69 @@ SET( VERSION ${V_MAJOR}.${V_MINOR}.${V_BUGFIX} ) SET( APIVERSION ${V_MAJOR}.${V_MINOR} ) -cmake_minimum_required( VERSION 2.4 ) +SET( MIN_PLAYER_MAJOR 2 ) +SET( MIN_PLAYER_MINOR 1 ) -cmake_policy( SET CMP0003 NEW ) -cmake_policy( SET CMP0005 NEW ) +cmake_minimum_required( VERSION 2.4 FATAL_ERROR ) +IF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6) + cmake_policy( SET CMP0003 NEW ) + cmake_policy( SET CMP0005 OLD ) +ENDIF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6) + MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}") # define some preprocessor strings that the code is expecting -ADD_DEFINITIONS( -DPROJECT=\"${PROJECT_NAME}\" - -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" - -DVERSION=\"${VERSION}\" ) +ADD_DEFINITIONS( -DPROJECT=\\\"${PROJECT_NAME}\\\" + -DINSTALL_PREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\" + -DVERSION=\\\"${VERSION}\\\" ) include(FindPkgConfig) -#variable_watch(PLAYER_FOUND) -#variable_watch(PLAYER_VERSION) -pkg_search_module( GLIB glib-2.0 ) -pkg_search_module( PLAYER playercore ) -find_package(OPENGL REQUIRED) -# include(FindFLTK) doesn't seem to work for me, so we work a bit harder -set(FLTK_INCLUDE_DIR CMAKE_INCLUDE_PATH ) -find_package(FLTK REQUIRED) +pkg_search_module( GLIB REQUIRED glib-2.0 ) +find_package( OpenGL REQUIRED ) +#pkg_search_module( PLAYER playercore ) +#SET(VER_PATTERN "([0-9]*)\\.([0-9]*)\\.([0-9]*)") +#STRING( REGEX REPLACE ${VER_PATTERN} "\\1" PLAYER_MAJOR_VER ${PLAYER_VERSION} ) +#MESSAGE( "Major: ${PLAYER_MAJOR_VER}" ) +#STRING( REGEX REPLACE ${VER_PATTERN} "\\2" PLAYER_MINOR_VER ${PLAYER_VERSION} ) +#MESSAGE( "Minor: ${PLAYER_MINOR_VER}" ) +#IF( NOT PLAYER_MAJOR_VER LESS MIN_PLAYER_MAJOR ) +# IF( NOT PLAYER_MINOR_VER LESS MIN_PLAYER_MINOR ) +# MESSAGE( STATUS " Player up to date, building plugin") +# ADD_SUBDIRECTORY(libstageplugin) +# ENDIF( NOT PLAYER_MINOR_VER LESS MIN_PLAYER_MINOR ) +#ENDIF( NOT PLAYER_MAJOR_VER LESS MIN_PLAYER_MAJOR ) + +FIND_PROGRAM (FLTKCONFIG NAMES fltk-config) +IF (FLTKCONFIG) + EXECUTE_PROCESS (COMMAND fltk-config --cxxflags --use-gl --use-images + OUTPUT_VARIABLE FLTK_CFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + EXECUTE_PROCESS (COMMAND fltk-config --ldflags --use-gl --use-images + OUTPUT_VARIABLE FLTK_LIBRARIES + OUTPUT_STRIP_TRAILING_WHITESPACE) + MESSAGE (STATUS "Found FLTK") + SET (FLTK_FOUND TRUE) +ELSE (FLTKCONFIG) + MESSAGE (FATAL_ERROR "FLTK not found, aborting") + SET (FLTK_FOUND FALSE) +ENDIF (FLTKCONFIG) + + +IF (APPLE) + MESSAGE(STATUS "Setting Apple specific flags") + SET(APPLE_LIBRARIES "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") +ENDIF (APPLE) + # all targets need these include directories include_directories( . libstage replace ${GLIB_INCLUDE_DIRS} ${FLTK_INCLUDE_DIR} - ${OPENGL_INCLUDE_DIR} - ${CMAKE_INCLUDE_PATH} + ${CMAKE_INCLUDE_PATH} ) @@ -54,16 +86,6 @@ ADD_SUBDIRECTORY(libstage) ADD_SUBDIRECTORY(examples) -string( REGEX MATCH "([0-9]*)\\.([0-9]*)\\." player_ver ${PLAYER_VERSION} ) -SET(min_player_major 2) -SET(min_player_minor 1) -IF( NOT CMAKE_MATCH_1 LESS min_player_major ) - IF( NOT CMAKE_MATCH_2 LESS min_player_minor ) - MESSAGE( "Found Player v${PLAYER_VERSION} in ${PLAYER_INCLUDE_DIRS}") - ADD_SUBDIRECTORY(libstageplugin) - ENDIF() -ENDIF() - INSTALL(FILES rgb.txt stagelogo.png DESTINATION share/stage ) Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-13 23:48:32 UTC (rev 6561) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-13 23:48:52 UTC (rev 6562) @@ -33,6 +33,7 @@ ${GLIB_LIBRARIES} ${OPENGL_LIBRARIES} ${FLTK_LIBRARIES} + ${APPLE_LIBRARIES} ltdl ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-13 23:48:32 UTC (rev 6561) +++ code/stage/trunk/libstage/stage.hh 2008-06-13 23:48:52 UTC (rev 6562) @@ -94,6 +94,7 @@ GHashTable* Typetable(); // foreward declare + class StgCanvas; class Worldfile; /// Copyright string Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-13 23:48:32 UTC (rev 6561) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-13 23:48:52 UTC (rev 6562) @@ -178,7 +178,7 @@ FL_MENU_TOGGLE| (canvas->showflags & STG_SHOW_TRAILRISE ? FL_MENU_VALUE : 0 )); mbar->add( "&Help", 0, 0, 0, FL_SUBMENU ); - mbar->add( "Help/&About Stage...", NULL, (Fl_Callback *)About_cb, this ); + mbar->add( "Help/&About Stage...", 0, (Fl_Callback *)About_cb, this ); //mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback *)dummy_cb ); callback( (Fl_Callback*)WindowCallback, this ); @@ -366,8 +366,7 @@ switch (choice) { case 1: // Yes - bool saved = SaveAsDialog(); - if ( saved ) { + if ( SaveAsDialog() ) { return true; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-13 18:54:04
|
Revision: 6568 http://playerstage.svn.sourceforge.net/playerstage/?rev=6568&view=rev Author: rtv Date: 2008-06-13 18:54:08 -0700 (Fri, 13 Jun 2008) Log Message: ----------- added beginnings of a test program Modified Paths: -------------- code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/TODO code/stage/trunk/libstage/stage.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/worlds/fasr.world Added Paths: ----------- code/stage/trunk/libstage/test.cc Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-14 01:19:37 UTC (rev 6567) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-14 01:54:08 UTC (rev 6568) @@ -58,6 +58,9 @@ stage ) +add_executable( test test.cc ) +target_link_libraries( test stage ) + INSTALL(TARGETS stagebinary stage RUNTIME DESTINATION bin LIBRARY DESTINATION lib Modified: code/stage/trunk/libstage/TODO =================================================================== --- code/stage/trunk/libstage/TODO 2008-06-14 01:19:37 UTC (rev 6567) +++ code/stage/trunk/libstage/TODO 2008-06-14 01:54:08 UTC (rev 6568) @@ -2,20 +2,27 @@ ** 3.0.0 RELEASE ** BUGS -* saving worldfile adds newlines after includes -* Viewing About Box stops simulation + * 3d collision detection broken - e.g. fancypioneer2dx * [OSX only - FLTK bug?] loading window size constrains maximum window size -* alpha properly done INCOMPLETE -* Fix 3D panning and scrolling + * per-model visualization entries in view menu DESIRABLE FEATURES + +* add blocks to world w/o model? * energy model & recharging * runtime update rate UI -** FUTURE RELEASES ** \ No newline at end of file +** FUTURE RELEASES ** + +DONE + +* Viewing About Box stops simulation +* saving worldfile adds newlines after includes +* alpha properly done +* Fix 3D panning and scrolling Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-06-14 01:19:37 UTC (rev 6567) +++ code/stage/trunk/libstage/stage.cc 2008-06-14 01:54:08 UTC (rev 6568) @@ -305,6 +305,17 @@ } } +stg_pose_t Stg::new_pose( stg_meters_t x, stg_meters_t y, stg_meters_t z, stg_radians_t a ) +{ + stg_pose_t p; + p.x = x; + p.y = y; + p.z = z; + p.a = a; + return p; +}; + + // sets [result] to the pose of [p2] in [p1]'s coordinate system void Stg::stg_pose_sum( stg_pose_t* result, stg_pose_t* p1, stg_pose_t* p2 ) { Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-14 01:19:37 UTC (rev 6567) +++ code/stage/trunk/libstage/stage.hh 2008-06-14 01:54:08 UTC (rev 6568) @@ -3,7 +3,7 @@ /* * Stage : a multi-robot simulator. Part of the Player Project * - * Copyright (C) 2001-2007 Richard Vaughan, Brian Gerkey, Andrew + * Copyright (C) 2001-2008 Richard Vaughan, Brian Gerkey, Andrew * Howard * * This program is free software; you can redistribute it and/or modify @@ -372,6 +372,9 @@ stg_line3d_func_t visit_voxel, void* arg ); + /** return a stg_pose_t with its fields initialized by the + parameters */ + stg_pose_t new_pose( stg_meters_t x, stg_meters_t y, stg_meters_t z, stg_radians_t a ); const uint32_t STG_MOVE_TRANS = (1 << 0); const uint32_t STG_MOVE_ROT = (1 << 1); @@ -930,6 +933,7 @@ friend class StgModel; // allow access to private members friend class StgBlock; friend class StgTime; + friend class StgCanvas; private: @@ -1013,15 +1017,15 @@ bool ztest ); void RemoveBlock( int x, int y, StgBlock* block ); - //{ }//bgrid->RemoveBlock( x, y, block ); }; + protected: stg_usec_t interval_real; ///< real-time interval between updates - set this to zero for 'as fast as possible GHashTable* superregions; static void UpdateCb( StgWorld* world); - + GList* ray_list; // store rays traced for debugging purposes void RecordRay( double x1, double y1, double x2, double y2 ); @@ -1035,6 +1039,12 @@ //GHashTable* blocks; GArray lines; + virtual void AddModel( StgModel* mod ); + virtual void RemoveModel( StgModel* mod ); + + GList* GetRayList(){ return ray_list; }; + void ClearRays(); + public: StgWorld(); @@ -1058,7 +1068,6 @@ stg_usec_t GetSimInterval(){ return interval_sim; }; - Worldfile* GetWorldFile(){ return wf; }; virtual void Load( const char* worldfile_path ); @@ -1066,8 +1075,6 @@ virtual void Reload(); virtual bool Save( const char* filename ); virtual bool Update(void); - virtual void AddModel( StgModel* mod ); - virtual void RemoveModel( StgModel* mod ); void Start(){ paused = false; }; void Stop(){ paused = true; }; @@ -1078,22 +1085,31 @@ void CancelQuit(){ quit = false; } void CancelQuitAll(){ quit_all = false; } + /** Get the resolution in pixels-per-metre of the underlying + discrete raytracing model */ double Resolution(){ return ppm; }; + /** Returns a pointer to the model identified by ID, or NULL if + nonexistent */ StgModel* GetModel( const stg_id_t id ); + + /** Returns a pointer to the model identified by name, or NULL if + nonexistent */ StgModel* GetModel( const char* name ); - GList* GetRayList(){ return ray_list; }; - void ClearRays(); - + /** Get human readable string that describes the current simulation + time. */ void ClockString( char* str, size_t maxlen ); - stg_bounds3d_t GetExtent(){ return extent; }; + /** Return the 3D bounding box of the world, in meters */ + stg_bounds3d_t GetExtent(){ return extent; }; + /** call func( model, arg ) for each model in the world */ void ForEachModel( GHFunc func, void* arg ) { g_hash_table_foreach( models_by_id, func, arg ); }; + /** Return the number of times the world has been updated. */ long unsigned int GetUpdateCount() { return updates; } }; Added: code/stage/trunk/libstage/test.cc =================================================================== --- code/stage/trunk/libstage/test.cc (rev 0) +++ code/stage/trunk/libstage/test.cc 2008-06-14 01:54:08 UTC (rev 6568) @@ -0,0 +1,104 @@ +#include "stage.hh" + +/* libstage test program */ + +using namespace Stg; + +const double epsilon = 0.000001; + +void interact( StgWorldGui* wg ) +{ + for( int i=0; i<100; i++ ) + wg->Cycle(); +} + +void test( char* str, double a, double b ) +{ + if( fabs(a-b) > epsilon ) + printf( "FAIL %s expected %.3f saw %.3f\n", str, a, b ); +} + +void test( char* str, stg_pose_t a, stg_pose_t b ) +{ + if( fabs(a.x-b.x) > epsilon ) + printf( "POSE FAIL %s expected pose.x %.3f saw pose.x %.3f\n", str, a.x, b.x ); + if( fabs(a.y-b.y) > epsilon ) + printf( "POSE FAIL %s expected pose.y %.3f saw pose.y %.3f\n", str, a.y, b.y ); + if( fabs(a.z-b.z) > epsilon ) + printf( "POSE FAIL %s expected pose.z %.3f saw pose.z %.3f\n", str, a.z, b.z ); + if( fabs(a.a-b.a) > epsilon ) + printf( "POSE FAIL %s expected pose.a %.3f saw pose.a %.3f\n", str, a.a, b.a ); +} + +int main( int argc, char* argv[] ) +{ + Init( &argc, &argv); + + StgWorldGui world( 400,400, "Test" ); + + StgModel mod( &world, NULL, 0, "model" ); + + + // returned pose must be the same as the set pose + stg_pose_t pose; + + world.Start(); + + for( stg_meters_t x=0; x<5; x+=0.01 ) + { + pose = new_pose( x, 0, 0, 0 ); + mod.SetPose( pose ); + test( "translate X", mod.GetPose(), pose ); + interact( &world ); + } + + for( stg_meters_t y=0; y<5; y+=0.01 ) + { + pose = new_pose( 0, y, 0, 0 ); + mod.SetPose( pose ); + test( "translate Y", mod.GetPose(), pose ); + interact( &world ); + } + + for( stg_meters_t z=0; z<5; z+=0.01 ) + { + pose = new_pose( 0, 0, z, 0 ); + mod.SetPose( pose ); + test( "translate Z", mod.GetPose(), pose ); + interact( &world ); + } + + for( stg_radians_t a=0; a<dtor(360); a+=dtor(1) ) + { + pose = new_pose( 0, 0, 0, a ); + mod.SetPose( pose ); + pose = mod.GetPose(); + test( "rotate", mod.GetPose(), pose ); + interact( &world ); + } + + for( stg_radians_t a=0; a<dtor(360); a+=dtor(1) ) + { + pose = new_pose( cos(a), sin(a), 0, 0 ); + mod.SetPose( pose ); + test( "translate X&Y", mod.GetPose(), pose ); + interact( &world ); + } + + stg_geom_t geom; + bzero( &geom, sizeof(geom) ); + + for( stg_meters_t x=0.01; x<5; x+=0.1 ) + for( stg_meters_t y=0.01; y<5; y+=0.1 ) + //for( stg_meters_t z=0.01; z<5; z+=0.01 ) + { + geom.size.x = x; + geom.size.y = y; + geom.size.z = 1.0; + + mod.SetGeom( geom ); + interact( &world ); + } + + StgWorldGui::Run(); +} Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-14 01:19:37 UTC (rev 6567) +++ code/stage/trunk/worlds/fasr.world 2008-06-14 01:54:08 UTC (rev 6568) @@ -16,7 +16,7 @@ interval_sim 100 # simulation timestep in milliseconds interval_real 10 # real-time interval between simulation updates in milliseconds -paused 0 +paused 1 # configure the GUI window window @@ -74,7 +74,7 @@ autorob( pose [7.493 4.852 -156.719] ) autorob( pose [5.078 6.853 -37.549] ) autorob( pose [6.147 7.399 4.964] ) -autorob( pose [4.065 5.583 125.796] ) +autorob( pose [4.058 5.283 125.796] ) autorob( pose [7.487 6.926 -40.634] ) autorob( pose [4.530 7.367 -113.456] ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-16 15:42:29
|
Revision: 6593 http://playerstage.svn.sourceforge.net/playerstage/?rev=6593&view=rev Author: rtv Date: 2008-06-16 15:42:23 -0700 (Mon, 16 Jun 2008) Log Message: ----------- expanded test prog, reduced unecessary displaylist building, moved constants into namespace, fixed some bugs Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/ancestor.cc code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_blinkenlight.cc code/stage/trunk/libstage/model_blobfinder.cc code/stage/trunk/libstage/model_camera.cc code/stage/trunk/libstage/model_fiducial.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_load.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/test.cc code/stage/trunk/libstage/typetable.cc code/stage/trunk/libstage/world.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/CMakeLists.txt 2008-06-16 22:42:23 UTC (rev 6593) @@ -10,6 +10,11 @@ SET( MIN_PLAYER_MAJOR 2 ) SET( MIN_PLAYER_MINOR 1 ) +#SET(CMAKE_BUILD_TYPE debug) +#SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3") +#SET(CMAKE_C_FLAGS_DISTRIBUTION "-O3") + + cmake_minimum_required( VERSION 2.4 FATAL_ERROR ) IF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6) @@ -60,6 +65,7 @@ IF (APPLE) MESSAGE(STATUS "Setting Apple specific flags") + # work around the OS X 10.5 X11/OpenGL library bug SET(APPLE_LIBRARIES "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") ENDIF (APPLE) Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-16 22:42:23 UTC (rev 6593) @@ -1,5 +1,7 @@ add_library( stage SHARED + stage.cc + typetable.cc stage.hh # get headers into IDE projects file_manager.hh file_manager.cc @@ -21,8 +23,6 @@ model_props.cc model_ranger.cc resource.cc - stage.cc - typetable.cc world.cc worldfile.cc worldgui.cc Modified: code/stage/trunk/libstage/ancestor.cc =================================================================== --- code/stage/trunk/libstage/ancestor.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/ancestor.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -4,7 +4,10 @@ { token = NULL; children = NULL; - child_types = g_hash_table_new( g_str_hash, g_str_equal ); + + for( int i=0; i<MODEL_TYPE_COUNT; i++ ) + child_type_counts[i] = 0; + debug = false; } @@ -18,45 +21,31 @@ g_list_free( children ); } - g_hash_table_destroy( child_types ); } -unsigned int StgAncestor::GetNumChildrenOfType( const char* typestr ) +void StgAncestor::AddChild( StgModel* mod ) { - unsigned int *c = (unsigned int*)g_hash_table_lookup( child_types, typestr); + + // poke a name into the child + char* buf = new char[TOKEN_MAX]; + snprintf( buf, TOKEN_MAX, "%s.%s:%d", + token, typetable[mod->type].token, child_type_counts[mod->type] ); + + //printf( "%s generated a name for my child %s\n", token, buf ); - if( c ) - return *c; - else - return 0; -} + mod->SetToken( buf ); -void StgAncestor::IncrementNumChildrenOfType( const char* typestr ) -{ - unsigned int* c = (unsigned int*)g_hash_table_lookup( child_types, typestr); + children = g_list_append( children, mod ); - if( c == NULL ) - { - c = new unsigned int; - g_hash_table_insert( child_types, (gpointer)typestr, (gpointer)c); - *c = 1; - } - else - (*c)++; -} + child_type_counts[mod->type]++; -void StgAncestor::AddChild( StgModel* mod ) -{ - // increment the count of models of this type - IncrementNumChildrenOfType( mod->typestr ); - - // store as a child - children = g_list_append( children, mod ); + delete buf; } void StgAncestor::RemoveChild( StgModel* mod ) { - puts( "TODO: StgWorld::RemoveChild()" ); + child_type_counts[mod->type]--; + children = g_list_remove( children, mod ); } stg_pose_t StgAncestor::GetGlobalPose() Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/canvas.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -74,6 +74,9 @@ StgModel* StgCanvas::Select( int x, int y ) { + // TODO XX + return NULL; + // render all models in a unique color make_current(); // make sure the GL context is current glClearColor ( 0,0,0,1 ); @@ -88,7 +91,8 @@ if( mod->GuiMask() & (STG_MOVE_TRANS | STG_MOVE_ROT )) { - uint32_t col = (mod->Id() | 0xFF000000); + // TODO XX + uint32_t col = (uint32_t)mod; //(mod->Id() | 0xFF000000); glColor4ubv( (GLubyte*)&col ); mod->DrawPicker(); } @@ -104,9 +108,9 @@ GL_RGBA,GL_UNSIGNED_BYTE,(void*)&id ); // strip off the alpha channel byte to retrieve the model id - id &= 0x00FFFFFF; + //id &= 0x00FFFFFF; - StgModel* mod = world->GetModel( id ); + StgModel* mod = (StgModel*)id;//world->GetModel( id ); //printf("%p %s %d\n", mod, mod ? mod->Token() : "", id ); @@ -447,9 +451,12 @@ if( mod->displaylist == 0 ) mod->displaylist = glGenLists(1); - if( mod->body_dirty ) - mod->BuildDisplayList( showflags ); // ready to be rendered - + if( mod->rebuild_displaylist ) + { + //printf( "Model %s is dirty\n", mod->Token() ); + mod->BuildDisplayList( showflags ); // ready to be rendered + } + // move into this model's local coordinate frame glPushMatrix(); gl_pose_shift( &mod->pose ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -103,92 +103,78 @@ #define _GNU_SOURCE - //#define DEBUG + //#define DEBUG 0 #include "stage_internal.hh" #include "texture_manager.hh" #include <limits.h> // basic model - const bool STG_DEFAULT_MOD_BLOBRETURN = true; - const bool STG_DEFAULT_MOD_BOUNDARY = false; - const stg_color_t STG_DEFAULT_MOD_COLOR = (0xFFFF0000); // solid red - const stg_joules_t STG_DEFAULT_MOD_ENERGY_CAPACITY = 1000.0; - const bool STG_DEFAULT_MOD_ENERGY_CHARGEENABLE = true; - const stg_watts_t STG_DEFAULT_MOD_ENERGY_GIVERATE = 0.0; - const stg_meters_t STG_DEFAULT_MOD_ENERGY_PROBERANGE = 0.0; - const stg_watts_t STG_DEFAULT_MOD_ENERGY_TRICKLERATE = 0.1; - const stg_meters_t STG_DEFAULT_MOD_GEOM_SIZEX = 0.10; - const stg_meters_t STG_DEFAULT_MOD_GEOM_SIZEY = 0.10; - const stg_meters_t STG_DEFAULT_MOD_GEOM_SIZEZ = 0.10; - const bool STG_DEFAULT_MOD_GRID = false; - const bool STG_DEFAULT_MOD_GRIPPERRETURN = false; - const stg_laser_return_t STG_DEFAULT_MOD_LASERRETURN = LaserVisible; - const stg_meters_t STG_DEFAULT_MOD_MAP_RESOLUTION = 0.1; - const stg_movemask_t STG_DEFAULT_MOD_MASK = (STG_MOVE_TRANS | STG_MOVE_ROT); - const stg_kg_t STG_DEFAULT_MOD_MASS = 10.0; - const bool STG_DEFAULT_MOD_NOSE = false; - const bool STG_DEFAULT_MOD_OBSTACLERETURN = true; - const bool STG_DEFAULT_MOD_OUTLINE = true; - const bool STG_DEFAULT_MOD_RANGERRETURN = true; +const bool StgModel::DEFAULT_BLOBRETURN = true; +const bool StgModel::DEFAULT_BOUNDARY = false; +const stg_color_t StgModel::DEFAULT_COLOR = (0xFFFF0000); // solid red +const stg_joules_t StgModel::DEFAULT_ENERGY_CAPACITY = 1000.0; +const bool StgModel::DEFAULT_ENERGY_CHARGEENABLE = true; +const stg_watts_t StgModel::DEFAULT_ENERGY_GIVERATE = 0.0; +const stg_meters_t StgModel::DEFAULT_ENERGY_PROBERANGE = 0.0; +const stg_watts_t StgModel::DEFAULT_ENERGY_TRICKLERATE = 0.1; +const stg_meters_t StgModel::DEFAULT_GEOM_SIZEX = 0.10; +const stg_meters_t StgModel::DEFAULT_GEOM_SIZEY = 0.10; +const stg_meters_t StgModel::DEFAULT_GEOM_SIZEZ = 0.10; +const bool StgModel::DEFAULT_GRID = false; +const bool StgModel::DEFAULT_GRIPPERRETURN = false; +const stg_laser_return_t StgModel::DEFAULT_LASERRETURN = LaserVisible; +const stg_meters_t StgModel::DEFAULT_MAP_RESOLUTION = 0.1; +const stg_movemask_t StgModel::DEFAULT_MASK = (STG_MOVE_TRANS | STG_MOVE_ROT); +const stg_kg_t StgModel::DEFAULT_MASS = 10.0; +const bool StgModel::DEFAULT_NOSE = false; +const bool StgModel::DEFAULT_OBSTACLERETURN = true; +const bool StgModel::DEFAULT_OUTLINE = true; +const bool StgModel::DEFAULT_RANGERRETURN = true; - // speech bubble colors - const stg_color_t STG_BUBBLE_FILL = 0xFFC8C8FF; // light blue/grey - const stg_color_t STG_BUBBLE_BORDER = 0xFF000000; // black - const stg_color_t STG_BUBBLE_TEXT = 0xFF000000; // black +// speech bubble colors +const stg_color_t StgModel::BUBBLE_FILL = 0xFFC8C8FF; // light blue/grey +const stg_color_t StgModel::BUBBLE_BORDER = 0xFF000000; // black +const stg_color_t StgModel::BUBBLE_TEXT = 0xFF000000; // black - // constructor +// constructor StgModel::StgModel( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) + StgModel* parent, + const stg_model_type_t type ) : StgAncestor() -{ - PRINT_DEBUG4( "Constructing model world: %s parent: %s type: %s id: %d", - world->Token(), - parent ? parent->Token() : "(null)", - typestr, - id ); +{ + assert( world ); + + PRINT_DEBUG3( "Constructing model world: %s parent: %s type: %d ", + world->Token(), + parent ? parent->Token() : "(null)", + type ); + + this->parent = parent; + this->world = world; + this->debug = false; + this->type = type; + + // Adding this model to its ancestor also gives this model a + // sensible default name - this->id = id; - this->typestr = typestr; - this->parent = parent; - this->world = world; + StgAncestor* anc = parent ? (StgAncestor*)parent : (StgAncestor*)world; - this->debug = false; - - // generate a name. This might be overwritten if the "name" property - // is set in the worldfile when StgModel::Load() is called - - StgAncestor* anc = parent ? (StgAncestor*)parent : (StgAncestor*)world; - - unsigned int cnt = anc->GetNumChildrenOfType( typestr ); - char* buf = new char[TOKEN_MAX]; - - snprintf( buf, TOKEN_MAX, "%s.%s:%d", - anc->Token(), typestr, cnt ); - - this->token = strdup( buf ); - delete buf; - - PRINT_DEBUG2( "model has token \"%s\" and typestr \"%s\"", - this->token, this->typestr ); - - anc->AddChild( this ); - world->AddModel( this ); - - bzero( &pose, sizeof(pose)); - if( parent ) - pose.z = parent->geom.size.z; - bzero( &global_pose, sizeof(global_pose)); - + anc->AddChild( this ); + world->AddModel( this ); + + bzero( &pose, sizeof(pose)); + if( parent ) + pose.z = parent->geom.size.z; + bzero( &global_pose, sizeof(global_pose)); + this->trail = g_array_new( false, false, sizeof(stg_trail_item_t) ); this->data_fresh = false; this->disabled = false; this->d_list = NULL; this->blocks = NULL; - this->body_dirty = true; + this->rebuild_displaylist = true; this->data_dirty = true; this->gpose_dirty = true; this->say_string = NULL; @@ -197,23 +183,23 @@ this->displaylist = 0; - this->geom.size.x = STG_DEFAULT_MOD_GEOM_SIZEX; - this->geom.size.y = STG_DEFAULT_MOD_GEOM_SIZEX; - this->geom.size.z = STG_DEFAULT_MOD_GEOM_SIZEX; + this->geom.size.x = StgModel::DEFAULT_GEOM_SIZEX; + this->geom.size.y = StgModel::DEFAULT_GEOM_SIZEX; + this->geom.size.z = StgModel::DEFAULT_GEOM_SIZEX; memset( &this->geom.pose, 0, sizeof(this->geom.pose)); - this->obstacle_return = STG_DEFAULT_MOD_OBSTACLERETURN; - this->ranger_return = STG_DEFAULT_MOD_RANGERRETURN; - this->blob_return = STG_DEFAULT_MOD_BLOBRETURN; - this->laser_return = STG_DEFAULT_MOD_LASERRETURN; - this->gripper_return = STG_DEFAULT_MOD_GRIPPERRETURN; - this->boundary = STG_DEFAULT_MOD_BOUNDARY; - this->color = STG_DEFAULT_MOD_COLOR; - this->map_resolution = STG_DEFAULT_MOD_MAP_RESOLUTION; // meters - this->gui_nose = STG_DEFAULT_MOD_NOSE; - this->gui_grid = STG_DEFAULT_MOD_GRID; - this->gui_outline = STG_DEFAULT_MOD_OUTLINE; - this->gui_mask = this->parent ? 0 : STG_DEFAULT_MOD_MASK; + this->obstacle_return = StgModel::DEFAULT_OBSTACLERETURN; + this->ranger_return = StgModel::DEFAULT_RANGERRETURN; + this->blob_return = StgModel::DEFAULT_BLOBRETURN; + this->laser_return = StgModel::DEFAULT_LASERRETURN; + this->gripper_return = StgModel::DEFAULT_GRIPPERRETURN; + this->boundary = StgModel::DEFAULT_BOUNDARY; + this->color = StgModel::DEFAULT_COLOR; + this->map_resolution = StgModel::DEFAULT_MAP_RESOLUTION; // meters + this->gui_nose = StgModel::DEFAULT_NOSE; + this->gui_grid = StgModel::DEFAULT_GRID; + this->gui_outline = StgModel::DEFAULT_OUTLINE; + this->gui_mask = this->parent ? 0 : StgModel::DEFAULT_MASK; this->fiducial_return = 0; this->fiducial_key = 0; @@ -232,22 +218,34 @@ this->interval = 1e4; // 10msec this->initfunc = NULL; - //this->updatefunc = NULL; + this->startup_hook = NULL; + this->shutdown_hook = NULL; + this->load_hook = NULL; + this->save_hook = NULL; + + this->wf = NULL; + this->wf_entity = 0; + // now we can add the basic square shape this->AddBlockRect( -0.5,-0.5,1,1 ); - PRINT_DEBUG2( "finished model %s (%d).", - this->token, - this->id ); + PRINT_DEBUG2( "finished model %s @ %p", + this->token, this ); } StgModel::~StgModel( void ) { - // remove from parent, if there is one - if( parent ) - parent->children = g_list_remove( parent->children, this ); + UnMap(); // remove from the raytrace bitmap + // children are removed in ancestor class + + // remove from parent, if there is one + if( parent ) + parent->children = g_list_remove( parent->children, this ); + else + world->children = g_list_remove( world->children, this ); + if( callbacks ) g_hash_table_destroy( callbacks ); world->RemoveModel( this ); @@ -260,29 +258,6 @@ { if( initfunc ) Subscribe(); - - // anything else to do here? - - // // try some things out; - // stg_blinkenlight_t* b = new stg_blinkenlight_t; - // b->pose.x = 0; - // b->pose.y = 0; - // b->pose.z = 0.4; - // b->pose.a = 0; - // b->enabled = true; - // b->color = stg_color_pack( 1,1,0,0 ); - // b->size = 0.1; - - // //AddBlinkenlight( b ); - - // stg_blinkenlight_t* c = new stg_blinkenlight_t; - // c->pose.x = 0.1; - // c->pose.y = 0; - // c->pose.z = 0.4; - // c->pose.a = 0; - // c->enabled = false; - // c->color = stg_color_pack( 1,1,0,0 ); - // c->size = 0.1; } void StgModel::AddFlag( StgFlag* flag ) @@ -689,10 +664,13 @@ else printf( "Model "); - printf( "%d %s:%s\n", - id, + printf( "%s:%s\n", + // id, world->Token(), token ); + + for( GList* it=children; it; it=it->next ) + ((StgModel*)it->data)->Print( prefix ); } const char* StgModel::PrintWithPose() @@ -718,7 +696,7 @@ world->StartUpdatingModel( this ); - CallCallbacks( &startup ); + CallCallbacks( &startup_hook ); } void StgModel::Shutdown( void ) @@ -727,7 +705,7 @@ world->StopUpdatingModel( this ); - CallCallbacks( &shutdown ); + CallCallbacks( &shutdown_hook ); } void StgModel::UpdateIfDue( void ) @@ -742,12 +720,7 @@ //printf( "[%lu] %s update (%d subs)\n", // this->world->sim_time_ms, this->token, this->subs ); - //puts( "UPDATE" ); - // if( updatefunc ) - // updatefunc( this ); - - CallCallbacks( &update ); - + CallCallbacks( &update_hook ); last_update = world->sim_time; } @@ -890,6 +863,8 @@ void StgModel::DrawBlocks( ) { + //printf( "model %s drawing blocks\n", token ); + LISTMETHOD( this->blocks, StgBlock*, Draw ); // recursively draw the tree below this model @@ -900,9 +875,7 @@ glPushMatrix(); gl_pose_shift( &child->pose ); gl_pose_shift( &child->geom.pose ); - child->DrawBlocks(); - glPopMatrix(); } @@ -988,7 +961,7 @@ // draw inside of bubble - PushColor( STG_BUBBLE_FILL ); + PushColor( BUBBLE_FILL ); glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT ); glPolygonMode( GL_FRONT, GL_FILL ); glEnable( GL_POLYGON_OFFSET_FILL ); @@ -997,7 +970,7 @@ glDisable( GL_POLYGON_OFFSET_FILL ); PopColor(); // draw outline of bubble - PushColor( STG_BUBBLE_BORDER ); + PushColor( BUBBLE_BORDER ); glLineWidth( 1 ); glEnable( GL_LINE_SMOOTH ); glPolygonMode( GL_FRONT, GL_LINE ); @@ -1007,7 +980,7 @@ // draw text - PushColor( STG_BUBBLE_TEXT ); + PushColor( BUBBLE_TEXT ); glTranslatef( 0, 0, 0.1 ); // draw text forwards of bubble gl_draw_string( m, m, 0.0, this->say_string ); PopColor(); @@ -1137,12 +1110,11 @@ void StgModel::BuildDisplayList( int flags ) { - glNewList( displaylist, GL_COMPILE ); - //printf("Model %s blocks %d\n", token, g_list_length( blocks ) ); - + glNewList( displaylist, GL_COMPILE ); DrawBlocks(); - glEndList(); + + rebuild_displaylist = false; // we just did it } void StgModel::DataVisualize( void ) @@ -1191,8 +1163,10 @@ void StgModel::NeedRedraw( void ) { - this->body_dirty = true; - //this->world->dirty = true; + this->rebuild_displaylist = true; + + if( parent ) + parent->NeedRedraw(); } void StgModel::GPoseDirtyTree( void ) @@ -1217,7 +1191,7 @@ this->pose = pose; this->pose.a = normalize(this->pose.a); - this->NeedRedraw(); + //this->NeedRedraw(); this->GPoseDirtyTree(); // global pose may have changed MapWithChildren(); @@ -1690,19 +1664,19 @@ return added; } -StgModel* StgModel::GetUnsubscribedModelOfType( char* modelstr ) +StgModel* StgModel::GetUnsubscribedModelOfType( stg_model_type_t type ) { - // printf( "searching for %s in model %s with string %s\n", modelstr, token, typestr ); + // printf( "searching for %s in model %s with string %s\n", modelstr, token, typestr ); + + if( (this->type == type) && (this->subs == 0) ) + return this; - if( subs == 0 && (strcmp( typestr, modelstr ) == 0) ) - return this; - // this model is no use. try children recursively for( GList* it = children; it; it=it->next ) { StgModel* child = (StgModel*)it->data; - StgModel* found = child->GetUnsubscribedModelOfType( modelstr ); + StgModel* found = child->GetUnsubscribedModelOfType( type ); if( found ) return found; } Modified: code/stage/trunk/libstage/model_blinkenlight.cc =================================================================== --- code/stage/trunk/libstage/model_blinkenlight.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_blinkenlight.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -48,19 +48,10 @@ //#define DEBUG 1 #include "stage_internal.hh" - -//static gboolean blink( bool* enabled ) -//{ -// *enabled = ! *enabled; -// puts( "blink" ); -// return true; -//} - -StgModelBlinkenlight::StgModelBlinkenlight( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + +StgModelBlinkenlight::StgModelBlinkenlight( StgWorld* world, + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_BLINKENLIGHT ) { PRINT_DEBUG2( "Constructing StgModelBlinkenlight %d (%s)\n", id, typestr ); @@ -91,13 +82,11 @@ void StgModelBlinkenlight::Load( void ) { - StgModel::Load(); - - Worldfile* wf = world->GetWorldFile(); - - this->dutycycle = wf->ReadFloat( id, "dutycycle", this->dutycycle ); - this->period = wf->ReadInt( id, "period", this->period ); - this->enabled = wf->ReadInt( id, "dutycycle", this->enabled ); + StgModel::Load(); + + this->dutycycle = wf->ReadFloat( wf_entity, "dutycycle", this->dutycycle ); + this->period = wf->ReadInt( wf_entity, "period", this->period ); + this->enabled = wf->ReadInt( wf_entity, "dutycycle", this->enabled ); } Modified: code/stage/trunk/libstage/model_blobfinder.cc =================================================================== --- code/stage/trunk/libstage/model_blobfinder.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_blobfinder.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -80,10 +80,8 @@ StgModelBlobfinder::StgModelBlobfinder( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_BLOBFINDER ) { PRINT_DEBUG2( "Constructing StgModelBlobfinder %d (%s)\n", id, typestr ); @@ -150,22 +148,22 @@ Worldfile* wf = world->GetWorldFile(); - scan_width = (int)wf->ReadTupleFloat( id, "image", 0, scan_width ); - scan_height= (int)wf->ReadTupleFloat( id, "image", 1, scan_height ); - range = wf->ReadFloat( id, "range", range ); - fov = wf->ReadAngle( id, "fov", fov ); - pan = wf->ReadAngle( id, "pan", pan ); + scan_width = (int)wf->ReadTupleFloat( wf_entity, "image", 0, scan_width ); + scan_height= (int)wf->ReadTupleFloat( wf_entity, "image", 1, scan_height ); + range = wf->ReadFloat( wf_entity, "range", range ); + fov = wf->ReadAngle( wf_entity, "fov", fov ); + pan = wf->ReadAngle( wf_entity, "pan", pan ); - if( wf->PropertyExists( id, "colors" ) ) + if( wf->PropertyExists( wf_entity, "colors" ) ) { RemoveAllColors(); // empty the color list to start from scratch - unsigned int count = wf->ReadFloat( id, "colors_count", 0 ); + unsigned int count = wf->ReadFloat( wf_entity, "colors_count", 0 ); for( unsigned int c=0; c<count; c++ ) { const char* colorstr = - wf->ReadTupleString( id, "colors", c, NULL ); + wf->ReadTupleString( wf_entity, "colors", c, NULL ); if( ! colorstr ) break; Modified: code/stage/trunk/libstage/model_camera.cc =================================================================== --- code/stage/trunk/libstage/model_camera.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_camera.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -15,10 +15,8 @@ StgModelCamera::StgModelCamera( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ), + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_CAMERA ), _frame_data( NULL ), _frame_data_width( 0 ), _frame_data_height( 0 ), _width( 0 ) { PRINT_DEBUG2( "Constructing StgModelCamera %d (%s)\n", @@ -54,18 +52,16 @@ void StgModelCamera::Load( void ) { StgModel::Load(); - Worldfile* wf = world->GetWorldFile(); - _camera.setFov( wf->ReadLength( id, "fov", _camera.fov() ) ); - _camera.setYaw( wf->ReadLength( id, "yaw", _camera.yaw() ) ); - _camera.setPitch( wf->ReadLength( id, "pitch", _camera.pitch() ) ); + _camera.setFov( wf->ReadLength( wf_entity, "fov", _camera.fov() ) ); + _camera.setYaw( wf->ReadLength( wf_entity, "yaw", _camera.yaw() ) ); + _camera.setPitch( wf->ReadLength( wf_entity, "pitch", _camera.pitch() ) ); - _width = wf->ReadLength( id, "width", _width ); + _width = wf->ReadLength( wf_entity, "width", _width ); //TODO move to constructor _frame_data_width = _width; _frame_data_height = 100; - } Modified: code/stage/trunk/libstage/model_fiducial.cc =================================================================== --- code/stage/trunk/libstage/model_fiducial.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_fiducial.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -62,10 +62,8 @@ */ StgModelFiducial::StgModelFiducial( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_FIDUCIAL ) { PRINT_DEBUG2( "Constructing StgModelFiducial %d (%s)\n", id, typestr ); @@ -235,13 +233,11 @@ StgModel::Load(); - Worldfile* wf = world->GetWorldFile(); - // load fiducial-specific properties - min_range = wf->ReadLength( id, "range_min", min_range ); - max_range_anon = wf->ReadLength( id, "range_max", max_range_anon ); - max_range_id = wf->ReadLength( id, "range_max_id", max_range_id ); - fov = wf->ReadAngle( id, "fov", fov ); + min_range = wf->ReadLength( wf_entity, "range_min", min_range ); + max_range_anon = wf->ReadLength( wf_entity, "range_max", max_range_anon ); + max_range_id = wf->ReadLength( wf_entity, "range_max_id", max_range_id ); + fov = wf->ReadAngle( wf_entity, "fov", fov ); } Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_laser.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -76,10 +76,8 @@ */ StgModelLaser::StgModelLaser( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + StgModel* parent ) +: StgModel( world, parent, MODEL_TYPE_LASER ) { PRINT_DEBUG2( "Constructing StgModelLaser %d (%s)\n", id, typestr ); @@ -121,15 +119,12 @@ void StgModelLaser::Load( void ) { StgModel::Load(); + sample_count = wf->ReadInt( wf_entity, "samples", sample_count ); + range_min = wf->ReadLength( wf_entity, "range_min", range_min); + range_max = wf->ReadLength( wf_entity, "range_max", range_max ); + fov = wf->ReadAngle( wf_entity, "fov", fov ); + resolution = wf->ReadInt( wf_entity, "laser_sample_skip", resolution ); - Worldfile* wf = world->GetWorldFile(); - - sample_count = wf->ReadInt( id, "samples", sample_count ); - range_min = wf->ReadLength( id, "range_min", range_min); - range_max = wf->ReadLength( id, "range_max", range_max ); - fov = wf->ReadAngle( id, "fov", fov ); - resolution = wf->ReadInt( id, "laser_sample_skip", resolution ); - if( resolution < 1 ) { PRINT_WARN( "laser resolution set < 1. Forcing to 1" ); Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_load.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -12,22 +12,23 @@ void FooUpdate( StgModel* ); -void StgModel::Load( void ) +void StgModel::Load() { - PRINT_DEBUG1( "Model \"%s\" loading...", token ); + assert( wf ); + assert( wf_entity ); - Worldfile* wf = world->wf; + PRINT_DEBUG1( "Model \"%s\" loading...", token ); - if( wf->PropertyExists( this->id, "debug" ) ) + if( wf->PropertyExists( wf_entity, "debug" ) ) { PRINT_WARN2( "debug property specified for model %d %s\n", - this->id, this->token ); - this->debug = wf->ReadInt( this->id, "debug", this->debug ); + wf_entity, this->token ); + this->debug = wf->ReadInt( wf_entity, "debug", this->debug ); } - if( wf->PropertyExists( this->id, "name" ) ) + if( wf->PropertyExists( wf_entity, "name" ) ) { - char *name = (char*)wf->ReadString(this->id, "name", NULL ); + char *name = (char*)wf->ReadString(wf_entity, "name", NULL ); if( name ) { //printf( "changed %s to %s\n", this->token, token ); @@ -43,93 +44,93 @@ //PRINT_WARN1( "%s::Load", token ); - if( wf->PropertyExists( this->id, "origin" ) ) + if( wf->PropertyExists( wf_entity, "origin" ) ) { stg_geom_t geom = GetGeom(); - geom.pose.x = wf->ReadTupleLength(this->id, "origin", 0, geom.pose.x ); - geom.pose.y = wf->ReadTupleLength(this->id, "origin", 1, geom.pose.y ); - geom.pose.a = wf->ReadTupleAngle(this->id, "origin", 2, geom.pose.a ); + geom.pose.x = wf->ReadTupleLength(wf_entity, "origin", 0, geom.pose.x ); + geom.pose.y = wf->ReadTupleLength(wf_entity, "origin", 1, geom.pose.y ); + geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin", 2, geom.pose.a ); this->SetGeom( geom ); } - if( wf->PropertyExists( this->id, "origin4" ) ) + if( wf->PropertyExists( wf_entity, "origin4" ) ) { stg_geom_t geom = GetGeom(); - geom.pose.x = wf->ReadTupleLength(this->id, "origin4", 0, geom.pose.x ); - geom.pose.y = wf->ReadTupleLength(this->id, "origin4", 1, geom.pose.y ); - geom.pose.z = wf->ReadTupleLength(this->id, "origin4", 2, geom.pose.z ); - geom.pose.a = wf->ReadTupleAngle(this->id, "origin4", 3, geom.pose.a ); + geom.pose.x = wf->ReadTupleLength(wf_entity, "origin4", 0, geom.pose.x ); + geom.pose.y = wf->ReadTupleLength(wf_entity, "origin4", 1, geom.pose.y ); + geom.pose.z = wf->ReadTupleLength(wf_entity, "origin4", 2, geom.pose.z ); + geom.pose.a = wf->ReadTupleAngle(wf_entity, "origin4", 3, geom.pose.a ); this->SetGeom( geom ); } - if( wf->PropertyExists( this->id, "size" ) ) + if( wf->PropertyExists( wf_entity, "size" ) ) { stg_geom_t geom = GetGeom(); - geom.size.x = wf->ReadTupleLength(this->id, "size", 0, geom.size.x ); - geom.size.y = wf->ReadTupleLength(this->id, "size", 1, geom.size.y ); + geom.size.x = wf->ReadTupleLength(wf_entity, "size", 0, geom.size.x ); + geom.size.y = wf->ReadTupleLength(wf_entity, "size", 1, geom.size.y ); this->SetGeom( geom ); } - if( wf->PropertyExists( this->id, "size3" ) ) + if( wf->PropertyExists( wf_entity, "size3" ) ) { stg_geom_t geom = GetGeom(); - geom.size.x = wf->ReadTupleLength(this->id, "size3", 0, geom.size.x ); - geom.size.y = wf->ReadTupleLength(this->id, "size3", 1, geom.size.y ); - geom.size.z = wf->ReadTupleLength(this->id, "size3", 2, geom.size.z ); + geom.size.x = wf->ReadTupleLength(wf_entity, "size3", 0, geom.size.x ); + geom.size.y = wf->ReadTupleLength(wf_entity, "size3", 1, geom.size.y ); + geom.size.z = wf->ReadTupleLength(wf_entity, "size3", 2, geom.size.z ); this->SetGeom( geom ); } - if( wf->PropertyExists( this->id, "pose" )) + if( wf->PropertyExists( wf_entity, "pose" )) { stg_pose_t pose = GetPose(); - pose.x = wf->ReadTupleLength(this->id, "pose", 0, pose.x ); - pose.y = wf->ReadTupleLength(this->id, "pose", 1, pose.y ); - pose.a = wf->ReadTupleAngle(this->id, "pose", 2, pose.a ); + pose.x = wf->ReadTupleLength(wf_entity, "pose", 0, pose.x ); + pose.y = wf->ReadTupleLength(wf_entity, "pose", 1, pose.y ); + pose.a = wf->ReadTupleAngle(wf_entity, "pose", 2, pose.a ); this->SetPose( pose ); } - if( wf->PropertyExists( this->id, "pose4" )) + if( wf->PropertyExists( wf_entity, "pose4" )) { stg_pose_t pose = GetPose(); - pose.x = wf->ReadTupleLength(this->id, "pose4", 0, pose.x ); - pose.y = wf->ReadTupleLength(this->id, "pose4", 1, pose.y ); - pose.z = wf->ReadTupleLength(this->id, "pose4", 2, pose.z ); - pose.a = wf->ReadTupleAngle( this->id, "pose4", 3, pose.a ); + pose.x = wf->ReadTupleLength(wf_entity, "pose4", 0, pose.x ); + pose.y = wf->ReadTupleLength(wf_entity, "pose4", 1, pose.y ); + pose.z = wf->ReadTupleLength(wf_entity, "pose4", 2, pose.z ); + pose.a = wf->ReadTupleAngle( wf_entity, "pose4", 3, pose.a ); this->SetPose( pose ); } - if( wf->PropertyExists( this->id, "velocity" )) + if( wf->PropertyExists( wf_entity, "velocity" )) { stg_velocity_t vel = GetVelocity(); - vel.x = wf->ReadTupleLength(this->id, "velocity", 0, vel.x ); - vel.y = wf->ReadTupleLength(this->id, "velocity", 1, vel.y ); - vel.a = wf->ReadTupleAngle(this->id, "velocity", 3, vel.a ); + vel.x = wf->ReadTupleLength(wf_entity, "velocity", 0, vel.x ); + vel.y = wf->ReadTupleLength(wf_entity, "velocity", 1, vel.y ); + vel.a = wf->ReadTupleAngle(wf_entity, "velocity", 3, vel.a ); this->SetVelocity( vel ); if( vel.x || vel.y || vel.z || vel.a ) world->StartUpdatingModel( this ); } - if( wf->PropertyExists( this->id, "velocity4" )) + if( wf->PropertyExists( wf_entity, "velocity4" )) { stg_velocity_t vel = GetVelocity(); - vel.x = wf->ReadTupleLength(this->id, "velocity4", 0, vel.x ); - vel.y = wf->ReadTupleLength(this->id, "velocity4", 1, vel.y ); - vel.z = wf->ReadTupleLength(this->id, "velocity4", 2, vel.z ); - vel.a = wf->ReadTupleAngle(this->id, "velocity4", 3, vel.a ); + vel.x = wf->ReadTupleLength(wf_entity, "velocity4", 0, vel.x ); + vel.y = wf->ReadTupleLength(wf_entity, "velocity4", 1, vel.y ); + vel.z = wf->ReadTupleLength(wf_entity, "velocity4", 2, vel.z ); + vel.a = wf->ReadTupleAngle(wf_entity, "velocity4", 3, vel.a ); this->SetVelocity( vel ); } - if( wf->PropertyExists( this->id, "boundary" )) + if( wf->PropertyExists( wf_entity, "boundary" )) { - this->SetBoundary( wf->ReadInt(this->id, "boundary", this->boundary )); + this->SetBoundary( wf->ReadInt(wf_entity, "boundary", this->boundary )); } - if( wf->PropertyExists( this->id, "color" )) + if( wf->PropertyExists( wf_entity, "color" )) { stg_color_t col = 0xFFFF0000; // red; - const char* colorstr = wf->ReadString( this->id, "color", NULL ); + const char* colorstr = wf->ReadString( wf_entity, "color", NULL ); if( colorstr ) { if( strcmp( colorstr, "random" ) == 0 ) @@ -145,19 +146,19 @@ } - if( wf->PropertyExists( this->id, "color_rgba" )) + if( wf->PropertyExists( wf_entity, "color_rgba" )) { - double red = wf->ReadTupleFloat( this->id, "color_rgba", 0, 0); - double green = wf->ReadTupleFloat( this->id, "color_rgba", 1, 0); - double blue = wf->ReadTupleFloat( this->id, "color_rgba", 2, 0); - double alpha = wf->ReadTupleFloat( this->id, "color_rgba", 3, 0); + double red = wf->ReadTupleFloat( wf_entity, "color_rgba", 0, 0); + double green = wf->ReadTupleFloat( wf_entity, "color_rgba", 1, 0); + double blue = wf->ReadTupleFloat( wf_entity, "color_rgba", 2, 0); + double alpha = wf->ReadTupleFloat( wf_entity, "color_rgba", 3, 0); this->SetColor( stg_color_pack( red, green, blue, alpha )); } - if( wf->PropertyExists( this->id, "bitmap" ) ) + if( wf->PropertyExists( wf_entity, "bitmap" ) ) { - const char* bitmapfile = wf->ReadString( this->id, "bitmap", NULL ); + const char* bitmapfile = wf->ReadString( wf_entity, "bitmap", NULL ); assert( bitmapfile ); char full[_POSIX_PATH_MAX]; @@ -211,7 +212,7 @@ StgBlock::ScaleList( this->blocks, &this->geom.size ); this->Map(); - this->body_dirty = true; + this->NeedRedraw(); g_free( rects ); } @@ -220,9 +221,9 @@ // token, g_list_length( blocks )); } - if( wf->PropertyExists( this->id, "blocks" ) ) + if( wf->PropertyExists( wf_entity, "blocks" ) ) { - int blockcount = wf->ReadInt( this->id, "blocks", -1 ); + int blockcount = wf->ReadInt( wf_entity, "blocks", -1 ); this->UnMap(); this->ClearBlocks(); @@ -233,7 +234,7 @@ for( int l=0; l<blockcount; l++ ) { snprintf(key, sizeof(key), "block[%d].points", l); - int pointcount = wf->ReadInt(this->id,key,0); + int pointcount = wf->ReadInt(wf_entity,key,0); //printf( "expecting %d points in block %d\n", //pointcount, l ); @@ -244,8 +245,8 @@ for( p=0; p<pointcount; p++ ) { snprintf(key, sizeof(key), "block[%d].point[%d]", l, p ); - pts[p].x = wf->ReadTupleLength(this->id, key, 0, 0); - pts[p].y = wf->ReadTupleLength(this->id, key, 1, 0); + pts[p].x = wf->ReadTupleLength(wf_entity, key, 0, 0); + pts[p].y = wf->ReadTupleLength(wf_entity, key, 1, 0); //printf( "key %s x: %.2f y: %.2f\n", // key, pt.x, pt.y ); @@ -255,10 +256,10 @@ snprintf(key, sizeof(key), "block[%d].z", l); stg_meters_t zmin = - wf->ReadTupleLength(this->id, key, 0, 0.0 ); + wf->ReadTupleLength(wf_entity, key, 0, 0.0 ); stg_meters_t zmax = - wf->ReadTupleLength(this->id, key, 1, 1.0 ); + wf->ReadTupleLength(wf_entity, key, 1, 1.0 ); // block color stg_color_t blockcol = this->color; @@ -266,7 +267,7 @@ snprintf(key, sizeof(key), "block[%d].color", l); - const char* colorstr = wf->ReadString( this->id, key, NULL ); + const char* colorstr = wf->ReadString( wf_entity, key, NULL ); if( colorstr ) { blockcol = stg_lookup_color( colorstr ); @@ -295,48 +296,48 @@ this->Map(); } - if( wf->PropertyExists( this->id, "mass" )) - this->SetMass( wf->ReadFloat(this->id, "mass", this->mass )); + if( wf->PropertyExists( wf_entity, "mass" )) + this->SetMass( wf->ReadFloat(wf_entity, "mass", this->mass )); - if( wf->PropertyExists( this->id, "fiducial_return" )) - this->SetFiducialReturn( wf->ReadInt( this->id, "fiducial_return", this->fiducial_return )); + if( wf->PropertyExists( wf_entity, "fiducial_return" )) + this->SetFiducialReturn( wf->ReadInt( wf_entity, "fiducial_return", this->fiducial_return )); - if( wf->PropertyExists( this->id, "fiducial_key" )) - this->SetFiducialKey( wf->ReadInt( this->id, "fiducial_key", this->fiducial_key )); + if( wf->PropertyExists( wf_entity, "fiducial_key" )) + this->SetFiducialKey( wf->ReadInt( wf_entity, "fiducial_key", this->fiducial_key )); - if( wf->PropertyExists( this->id, "obstacle_return" )) - this->SetObstacleReturn( wf->ReadInt( this->id, "obstacle_return", this->obstacle_return )); + if( wf->PropertyExists( wf_entity, "obstacle_return" )) + this->SetObstacleReturn( wf->ReadInt( wf_entity, "obstacle_return", this->obstacle_return )); - if( wf->PropertyExists( this->id, "ranger_return" )) - this->SetRangerReturn( wf->ReadInt( this->id, "ranger_return", this->ranger_return )); + if( wf->PropertyExists( wf_entity, "ranger_return" )) + this->SetRangerReturn( wf->ReadInt( wf_entity, "ranger_return", this->ranger_return )); - if( wf->PropertyExists( this->id, "blob_return" )) - this->SetBlobReturn( wf->ReadInt( this->id, "blob_return", this->blob_return )); + if( wf->PropertyExists( wf_entity, "blob_return" )) + this->SetBlobReturn( wf->ReadInt( wf_entity, "blob_return", this->blob_return )); - if( wf->PropertyExists( this->id, "laser_return" )) - this->SetLaserReturn( (stg_laser_return_t)wf->ReadInt(this->id, "laser_return", this->laser_return )); + if( wf->PropertyExists( wf_entity, "laser_return" )) + this->SetLaserReturn( (stg_laser_return_t)wf->ReadInt(wf_entity, "laser_return", this->laser_return )); - if( wf->PropertyExists( this->id, "gripper_return" )) - this->SetGripperReturn( wf->ReadInt( this->id, "gripper_return", this->gripper_return )); + if( wf->PropertyExists( wf_entity, "gripper_return" )) + this->SetGripperReturn( wf->ReadInt( wf_entity, "gripper_return", this->gripper_return )); - if( wf->PropertyExists( this->id, "gui_nose" )) - this->SetGuiNose( wf->ReadInt(this->id, "gui_nose", this->gui_nose )); + if( wf->PropertyExists( wf_entity, "gui_nose" )) + this->SetGuiNose( wf->ReadInt(wf_entity, "gui_nose", this->gui_nose )); - if( wf->PropertyExists( this->id, "gui_grid" )) - this->SetGuiGrid( wf->ReadInt(this->id, "gui_grid", this->gui_grid )); + if( wf->PropertyExists( wf_entity, "gui_grid" )) + this->SetGuiGrid( wf->ReadInt(wf_entity, "gui_grid", this->gui_grid )); - if( wf->PropertyExists( this->id, "gui_outline" )) - this->SetGuiOutline( wf->ReadInt(this->id, "gui_outline", this->gui_outline )); + if( wf->PropertyExists( wf_entity, "gui_outline" )) + this->SetGuiOutline( wf->ReadInt(wf_entity, "gui_outline", this->gui_outline )); - if( wf->PropertyExists( this->id, "gui_movemask" )) - this->SetGuiMask( wf->ReadInt(this->id, "gui_movemask", this->gui_mask )); + if( wf->PropertyExists( wf_entity, "gui_movemask" )) + this->SetGuiMask( wf->ReadInt(wf_entity, "gui_movemask", this->gui_mask )); - if( wf->PropertyExists( this->id, "map_resolution" )) - this->SetMapResolution( wf->ReadFloat(this->id, "map_resolution", this->map_resolution )); + if( wf->PropertyExists( wf_entity, "map_resolution" )) + this->SetMapResolution( wf->ReadFloat(wf_entity, "map_resolution", this->map_resolution )); - if( wf->PropertyExists( this->id, "ctrl" )) + if( wf->PropertyExists( wf_entity, "ctrl" )) { - char* lib = (char*)wf->ReadString(this->id, "ctrl", NULL ); + char* lib = (char*)wf->ReadString(wf_entity, "ctrl", NULL ); if( !lib ) puts( "Error - NULL library name" ); @@ -344,16 +345,16 @@ LoadControllerModule( lib ); } - if( wf->PropertyExists( this->id, "say" )) - this->Say( wf->ReadString(this->id, "say", NULL )); + if( wf->PropertyExists( wf_entity, "say" )) + this->Say( wf->ReadString(wf_entity, "say", NULL )); // call any type-specific load callbacks - this->CallCallbacks( &this->load ); + this->CallCallbacks( &this->load_hook ); // MUST BE THE LAST THING LOADED - if( wf->PropertyExists( this->id, "alwayson" )) + if( wf->PropertyExists( wf_entity, "alwayson" )) { - if( wf->ReadInt( this->id, "alwayson", 0) > 0 ) + if( wf->ReadInt( wf_entity, "alwayson", 0) > 0 ) Startup(); } @@ -366,10 +367,11 @@ void StgModel::Save( void ) { + assert( wf ); + assert( wf_entity ); + PRINT_DEBUG1( "Model \"%s\" saving...", token ); - Worldfile* wf = world->wf; - PRINT_DEBUG4( "saving model %s pose %.2f %.2f %.2f", this->token, this->pose.x, @@ -377,17 +379,17 @@ this->pose.a ); // right now we only save poses - wf->WriteTupleLength( this->id, "pose", 0, this->pose.x); - wf->WriteTupleLength( this->id, "pose", 1, this->pose.y); - wf->WriteTupleAngle( this->id, "pose", 2, this->pose.a); + wf->WriteTupleLength( wf_entity, "pose", 0, this->pose.x); + wf->WriteTupleLength( wf_entity, "pose", 1, this->pose.y); + wf->WriteTupleAngle( wf_entity, "pose", 2, this->pose.a); - wf->WriteTupleLength( this->id, "pose3", 0, this->pose.x); - wf->WriteTupleLength( this->id, "pose3", 1, this->pose.y); - wf->WriteTupleLength( this->id, "pose3", 2, this->pose.z); - wf->WriteTupleAngle( this->id, "pose3", 3, this->pose.a); + wf->WriteTupleLength( wf_entity, "pose3", 0, this->pose.x); + wf->WriteTupleLength( wf_entity, "pose3", 1, this->pose.y); + wf->WriteTupleLength( wf_entity, "pose3", 2, this->pose.z); + wf->WriteTupleAngle( wf_entity, "pose3", 3, this->pose.a); // call any type-specific save callbacks - this->CallCallbacks( &this->save ); + this->CallCallbacks( &this->save_hook ); PRINT_DEBUG1( "Model \"%s\" saving complete.", token ); } Modified: code/stage/trunk/libstage/model_position.cc =================================================================== --- code/stage/trunk/libstage/model_position.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_position.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -83,10 +83,8 @@ StgModelPosition::StgModelPosition( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_POSITION ) { PRINT_DEBUG2( "Constructing StgModelPosition %d (%s)\n", id, typestr ); @@ -137,13 +135,11 @@ char* keyword = NULL; - Worldfile* wf = world->GetWorldFile(); - // load steering mode - if( wf->PropertyExists( this->id, "drive" ) ) + if( wf->PropertyExists( wf_entity, "drive" ) ) { const char* mode_str = - wf->ReadString( this->id, "drive", NULL ); + wf->ReadString( wf_entity, "drive", NULL ); if( mode_str ) { @@ -161,7 +157,7 @@ } // load odometry if specified - if( wf->PropertyExists( this->id, "odom" ) ) + if( wf->PropertyExists( wf_entity, "odom" ) ) { PRINT_WARN1( "the odom property is specified for model \"%s\"," " but this property is no longer available." @@ -176,11 +172,11 @@ est_origin = this->GetGlobalPose(); keyword = "localization_origin"; - if( wf->PropertyExists( this->id, keyword ) ) + if( wf->PropertyExists( wf_entity, keyword ) ) { - est_origin.x = wf->ReadTupleLength( id, keyword, 0, est_origin.x ); - est_origin.y = wf->ReadTupleLength( id, keyword, 1, est_origin.y ); - est_origin.a = wf->ReadTupleAngle( id,keyword, 2, est_origin.a ); + est_origin.x = wf->ReadTupleLength( wf_entity, keyword, 0, est_origin.x ); + est_origin.y = wf->ReadTupleLength( wf_entity, keyword, 1, est_origin.y ); + est_origin.a = wf->ReadTupleAngle( wf_entity,keyword, 2, est_origin.a ); // compute our localization pose based on the origin and true pose stg_pose_t gpose = this->GetGlobalPose(); @@ -201,21 +197,21 @@ // odometry model parameters keyword = "odom_error"; - if( wf->PropertyExists( id, keyword ) ) + if( wf->PropertyExists( wf_entity, keyword ) ) { integration_error.x = - wf->ReadTupleLength( id, keyword, 0, integration_error.x ); + wf->ReadTupleLength( wf_entity, keyword, 0, integration_error.x ); integration_error.y = - wf->ReadTupleLength( id, keyword, 1, integration_error.y ); + wf->ReadTupleLength( wf_entity, keyword, 1, integration_error.y ); integration_error.a - = wf->ReadTupleAngle( id, keyword, 2, integration_error.a ); + = wf->ReadTupleAngle( wf_entity, keyword, 2, integration_error.a ); } // choose a localization model - if( wf->PropertyExists( this->id, "localization" ) ) + if( wf->PropertyExists( wf_entity, "localization" ) ) { const char* loc_str = - wf->ReadString( id, "localization", NULL ); + wf->ReadString( wf_entity, "localization", NULL ); if( loc_str ) { Modified: code/stage/trunk/libstage/model_ranger.cc =================================================================== --- code/stage/trunk/libstage/model_ranger.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/model_ranger.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -94,10 +94,8 @@ StgModelRanger::StgModelRanger( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) -: StgModel( world, parent, id, typestr ) + StgModel* parent ) + : StgModel( world, parent, MODEL_TYPE_RANGER ) { PRINT_DEBUG2( "Constructing StgModelRanger %d (%s)\n", id, typestr ); @@ -172,14 +170,12 @@ { StgModel::Load(); - Worldfile* wf = world->GetWorldFile(); - - if( wf->PropertyExists(id, "scount" ) ) + if( wf->PropertyExists( wf_entity, "scount" ) ) { PRINT_DEBUG( "Loading ranger array" ); // Load the geometry of a ranger array - sensor_count = wf->ReadInt( id, "scount", 0); + sensor_count = wf->ReadInt( wf_entity, "scount", 0); assert( sensor_count > 0 ); char key[256]; @@ -188,14 +184,14 @@ sensors = new stg_ranger_sensor_t[sensor_count]; stg_size_t common_size; - common_size.x = wf->ReadTupleLength( id, "ssize", 0, DEFAULT_RANGER_SIZEX ); - common_size.y = wf->ReadTupleLength( id, "ssize", 1, DEFAULT_RANGER_SIZEY ); + common_size.x = wf->ReadTupleLength( wf_entity, "ssize", 0, DEFAULT_RANGER_SIZEX ); + common_size.y = wf->ReadTupleLength( wf_entity, "ssize", 1, DEFAULT_RANGER_SIZEY ); - double common_min = wf->ReadTupleLength( id, "sview", 0, DEFAULT_RANGER_RANGEMIN ); - double common_max = wf->ReadTupleLength( id, "sview", 1, DEFAULT_RANGER_RANGEMAX ); - double common_fov = wf->ReadTupleAngle( id, "sview", 2, M_PI / (double)sensor_count ); + double common_min = wf->ReadTupleLength( wf_entity, "sview", 0, DEFAULT_RANGER_RANGEMIN ); + double common_max = wf->ReadTupleLength( wf_entity, "sview", 1, DEFAULT_RANGER_RANGEMAX ); + double common_fov = wf->ReadTupleAngle( wf_entity, "sview", 2, M_PI / (double)sensor_count ); - int common_ray_count = wf->ReadInt( id, "sraycount", sensors[0].ray_count ); + int common_ray_count = wf->ReadInt( wf_entity, "sraycount", sensors[0].ray_count ); // set all transducers with the common settings for( unsigned int i = 0; i < sensor_count; i++) @@ -213,16 +209,16 @@ for( unsigned int i = 0; i < sensor_count; i++) { snprintf(key, sizeof(key), "spose[%d]", i); - sensors[i].pose.x = wf->ReadTupleLength( id, key, 0, sensors[i].pose.x ); - sensors[i].pose.y = wf->ReadTupleLength( id, key, 1, sensors[i].pose.y ); + sensors[i].pose.x = wf->ReadTupleLength( wf_entity, key, 0, sensors[i].pose.x ); + sensors[i].pose.y = wf->ReadTupleLength( wf_entity, key, 1, sensors[i].pose.y ); sensors[i].pose.z = 0.0; - sensors[i].pose.a = wf->ReadTupleAngle( id, key, 2, sensors[i].pose.a ); + sensors[i].pose.a = wf->ReadTupleAngle( wf_entity, key, 2, sensors[i].pose.a ); snprintf(key, sizeof(key), "spose3[%d]", i); - sensors[i].pose.x = wf->ReadTupleLength( id, key, 0, sensors[i].pose.x ); - sensors[i].pose.y = wf->ReadTupleLength( id, key, 1, sensors[i].pose.y ); - sensors[i].pose.z = wf->ReadTupleLength( id, key, 2, sensors[i].pose.z ); - sensors[i].pose.a = wf->ReadTupleAngle( id, key, 3, sensors[i].pose.a ); + sensors[i].pose.x = wf->ReadTupleLength( wf_entity, key, 0, sensors[i].pose.x ); + sensors[i].pose.y = wf->ReadTupleLength( wf_entity, key, 1, sensors[i].pose.y ); + sensors[i].pose.z = wf->ReadTupleLength( wf_entity, key, 2, sensors[i].pose.z ); + sensors[i].pose.a = wf->ReadTupleAngle( wf_entity, key, 3, sensors[i].pose.a ); /* snprintf(key, sizeof(key), "ssize[%d]", i); */ /* sensors[i].size.x = wf->ReadTuplelength(mod->id, key, 0, 0.01); */ Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/stage.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -20,8 +20,8 @@ //#include "config.h" // results of autoconf's system configuration tests static bool init_called = false; -static GHashTable* typetable = NULL; +stg_typetable_entry_t Stg::typetable[MODEL_TYPE_COUNT]; void Stg::Init( int* argc, char** argv[] ) { @@ -32,8 +32,9 @@ if(!setlocale(LC_ALL,"POSIX")) PRINT_WARN("Failed to setlocale(); config file may not be parse correctly\n" ); + + RegisterModels(); - typetable = stg_create_typetable(); init_called = true; // ask FLTK to load support for various image formats @@ -45,10 +46,15 @@ return init_called; } -GHashTable* Stg::Typetable() + +void Stg::RegisterModel( stg_model_type_t type, + const char* name, + stg_creator_t creator ) { - return typetable; + Stg::typetable[ type ].token = name; + Stg::typetable[ type ].creator = creator; } + void Stg::stg_print_err( const char* err ) Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/stage.hh 2008-06-16 22:42:23 UTC (rev 6593) @@ -90,9 +90,22 @@ /** returns true iff Stg::Init() has been called. */ bool InitDone(); - /** Returns a hash table of model creator functions indexed by worldfile model string */ - GHashTable* Typetable(); + /** Create unique identifying numbers for each type of model, and a + count of the number of types. */ + typedef enum { + MODEL_TYPE_PLAIN = 0, + MODEL_TYPE_LASER, + MODEL_TYPE_FIDUCIAL, + MODEL_TYPE_RANGER, + MODEL_TYPE_POSITION, + MODEL_TYPE_BLOBFINDER, + MODEL_TYPE_BLINKENLIGHT, + MODEL_TYPE_CAMERA, + MODEL_TYPE_COUNT // must be the last entry, to count the number of + // types + } stg_model_type_t; + // foreward declare class StgCanvas; class Worldfile; @@ -134,7 +147,7 @@ "\n" \ "The text of the license may also be available online at\n" \ "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n";; - + /** The maximum length of a Stage model identifier string */ const uint32_t TOKEN_MAX = 64; @@ -536,18 +549,25 @@ class StgWorld; class StgModel; - GHashTable* stg_create_typetable(); - /** A model creator function. Each model type must define a function of this type. */ - typedef StgModel* (*stg_creator_t)( StgWorld*, StgModel*, stg_id_t, char* ); - + /** A model creator function. Each model type must define a function of this type. */ + typedef StgModel* (*stg_creator_t)( StgWorld*, StgModel* ); + typedef struct { const char* token; - stg_creator_t creator_fn; + stg_creator_t creator; } stg_typetable_entry_t; + + /** a global (to the namespace) table mapping names to model types */ + extern stg_typetable_entry_t typetable[MODEL_TYPE_COUNT]; + void RegisterModel( stg_model_type_t type, + const char* name, + stg_creator_t creator ); + void RegisterModels(); + void gl_draw_grid( stg_bounds3d_t vol ); void gl_pose_shift( stg_pose_t* pose ); void gl_coord_shift( double x, double y, double z, double a ); @@ -845,16 +865,22 @@ protected: GList* children; - GHashTable* child_types; - char* token; + //GHashTable* child_types; + + + char* token; bool debug; public: + + /** array contains the number of each type of child model */ + unsigned int child_type_counts[MODEL_TYPE_COUNT]; + StgAncestor(); virtual ~StgAncestor(); - unsigned int GetNumChildrenOfType( const char* typestr ); - void IncrementNumChildrenOfType( const char* typestr ); + // unsigned int GetNumChildrenOfType( const char* typestr ); + // void IncrementNumChildrenOfType( const char* typestr ); virtual void AddChild( StgModel* mod ); virtual void RemoveChild( StgModel* mod ); @@ -863,6 +889,11 @@ const char* Token() { return this->token; } + void SetToken( const char* str ) + { + this->token = strdup( str ); + } + // PURE VIRTUAL - descendents must implement virtual void PushColor( stg_color_t col ) = 0; virtual void PushColor( double r, double g, double b, double a ) = 0; @@ -972,7 +1003,7 @@ bool destroy; - stg_id_t id; + //stg_id_t id; GHashTable* models_by_id; ///< the models that make up the world, indexed by id GHashTable* models_by_name; ///< the models that make up the world, indexed by name @@ -1050,14 +1081,17 @@ GList* GetRayList(){ return ray_list; }; void ClearRays(); + public: - StgWorld(); + static const int DEFAULT_PPM = 50; // default resolution in pixels per meter + static const stg_msec_t DEFAULT_INTERVAL_REAL = 100; ///< real time between updates + static const stg_msec_t DEFAULT_INTERVAL_SIM = 100; ///< duration of sim timestep + + StgWorld( const char* token = "MyWorld", + stg_msec_t interval_sim = DEFAULT_INTERVAL_SIM, + stg_msec_t interval_real = DEFAULT_INTERVAL_REAL, + double ppm = DEFAULT_PPM ); - StgWorld( const char* token, - stg_msec_t interval_sim, - stg_msec_t interval_real, - double ppm ); - virtual ~StgWorld(); FileManager fileMan; @@ -1137,9 +1171,38 @@ friend class StgWorldGui; friend class StgCanvas; - protected: +protected: - const char* typestr; + // basic model + static const bool DEFAULT_BLOBRETURN; + static const bool DEFAULT_BOUNDARY; + static const stg_color_t DEFAULT_COLOR; + static const stg_joules_t DEFAULT_ENERGY_CAPACITY; + static const bool DEFAULT_ENERGY_CHARGEENABLE; + static const stg_watts_t DEFAULT_ENERGY_GIVERATE; + static const stg_meters_t DEFAULT_ENERGY_PROBERANGE; + static const stg_watts_t DEFAULT_ENERGY_TRICKLERATE; + static const stg_meters_t DEFAULT_GEOM_SIZEX; + static const stg_meters_t DEFAULT_GEOM_SIZEY; + static const stg_meters_t DEFAULT_GEOM_SIZEZ; + static const bool DEFAULT_GRID; + static const bool DEFAULT_GRIPPERRETURN; + static const stg_laser_return_t DEFAULT_LASERRETURN; + static const stg_meters_t DEFAULT_MAP_RESOLUTION; + static const stg_movemask_t DEFAULT_MASK; + static const stg_kg_t DEFAULT_MASS; + static const bool DEFAULT_NOSE; + static const bool DEFAULT_OBSTACLERETURN; + static const bool DEFAULT_OUTLINE; + static const bool DEFAULT_RANGERRETURN; + + // speech bubble colors + static const stg_color_t BUBBLE_FILL; + static const stg_color_t BUBBLE_BORDER; + static const stg_color_t BUBBLE_TEXT; + + + //const char* typestr; stg_pose_t pose; stg_velocity_t velocity; stg_watts_t watts; //< power consumed by this model @@ -1193,7 +1256,7 @@ // stg_trail_item_t* history; - bool body_dirty; //< iff true, regenerate block display list before redraw + bool rebuild_displaylist; //< iff true, regenerate block display list before redraw bool data_dirty; //< iff true, regenerate data display list before redraw stg_pose_t global_pose; @@ -1206,7 +1269,7 @@ ///allows polling the model instead of adding a ///data callback. - stg_id_t id; // globally unique ID used as hash table key and + //stg_id_t id; // globally unique ID used as hash table key and // worldfile section identifier StgWorld* world; // pointer to the world in which this model exists @@ -1308,39 +1371,56 @@ void DrawTrailArrows(); void DrawGrid(); void UpdateIfDue(); + + /* hooks for attaching special callback functions (not used as + variables) */ + char startup_hook, shutdown_hook, load_hook, save_hook, update_hook; + + ctrlinit_t* initfunc; + + GList* flag_list; + + Worldfile* wf; + int wf_entity; + + GPtrArray* blinkenlights; + void DrawBlinkenlights(); - /* hooks for attaching special callback functions (not used as - variables) */ - char startup, shutdown, load, save, update; - - ctrlinit_t* initfunc; - //ctrlupdate_t* updatefunc; - - GList* flag_list; - - GPtrArray* blinkenlights; - void DrawBlinkenlights(); - /** OpenGL display list identifier */ int displaylist; /** Compile the display list for this model */ void BuildDisplayList( int flags ); + stg_model_type_t type; + public: + static const char* typestr; + // constructor - StgModel( StgWorld* world, StgModel* parent, stg_id_t id, char* typestr ); + StgModel( StgWorld* world, StgModel* parent, stg_model_type_t type = MODEL_TYPE_PLAIN ); // destructor virtual ~StgModel(); void Say( const char* str ); - stg_id_t Id(){ return id; }; + /** Set the worldfile and worldfile entity ID - must be called + before Load() */ + void Load( Worldfile* wf, int wf_entity ) + { + SetWorldfile( wf, wf_entity ); + Load(); // call virtual load + } - /** configure a model by reading from the current world file */ - virtual void Load(); + /** Set the worldfile and worldfile entity ID */ + void SetWorldfile( Worldfile* wf, int wf_entity ) + { this->wf = wf; this->wf_entity = wf_entity; } + + /** configure a model by reading from the current world file */ + virtual void Load(); + /** save the state of the model to the current world file */ virtual void Save(); @@ -1398,7 +1478,7 @@ /** remove all blocks from this model, freeing their memory */ void ClearBlocks(); - const char* TypeStr(){ return this->typestr; } + //const char* TypeStr(){ return this->typestr; } StgModel* Parent(){ return this->parent; } StgModel* GetModel( const char* name ); bool Stall(){ return this->stall; } @@ -1514,34 +1594,34 @@ some implementation detail */ void AddStartupCallback( stg_model_callback_t cb, void* user ) - { AddCallback( &startup, cb, user ); }; + { AddCallback( &startup_hook, cb, user ); }; void RemoveStartupCallback( stg_model_callback_t cb ) - { RemoveCallback( &startup, cb ); }; + { RemoveCallback( &startup_hook, cb ); }; void AddShutdownCallback( stg_model_callback_t cb, void* user ) - { AddCallback( &shutdown, cb, user ); }; + { AddCallback( &shutdown_hook, cb, user ); }; void RemoveShutdownCallback( stg_model_callback_t cb ) - { RemoveCallback( &shutdown, cb ); } + { RemoveCallback( &shutdown_hook, cb ); } void AddLoadCallback( stg_model_callback_t cb, void* user ) - { AddCallback( &load, cb, user ); } + { AddCallback( &load_hook, cb, user ); } void RemoveLoadCallback( stg_model_callback_t cb ) - { RemoveCallback( &load, cb ); } + { RemoveCallback( &load_hook, cb ); } void AddSaveCallback( stg_model_callback_t cb, void* user ) - { AddCallback( &save, cb, user ); } + { AddCallback( &save_hook, cb, user ); } void RemoveSaveCallback( stg_model_callback_t cb ) - { RemoveCallback( &save, cb ); } + { RemoveCallback( &save_hook, cb ); } void AddUpdateCallback( stg_model_callback_t cb, void* user ) - { AddCallback( &update, cb, user ); } + { AddCallback( &update_hook, cb, user ); } void RemoveUpdateCallback( stg_model_callback_t cb ) - { RemoveCallback( &update, cb ); } + { RemoveCallback( &update_hook, cb ); } /** named-property interface */ @@ -1613,21 +1693,10 @@ /** returns the first descendent of this model that is unsubscribed and has the type indicated by the string */ - StgModel* GetUnsubscribedModelOfType( char* modelstr ); + StgModel* GetUnsubscribedModelOfType( stg_model_type_t type ); - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return new StgModel( world, parent, id, typestr ); - } - // iff true, model may output some debugging visualizations and other info bool debug; - }; // BLOCKS @@ -1998,17 +2067,16 @@ stg_radians_t fov; stg_radians_t pan; - // constructor - StgModelBlobfinder( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr); + static const char* typestr; - // destructor - ~StgModelBlobfinder(); - - virtual void Startup(); - virtual void Shutdown(); + // constructor + StgModelBlobfinder( StgWorld* world, + StgModel* parent ); + // destructor + ~StgModelBlobfinder(); + + virtual void Startup(); + virtual void Shutdown(); virtual void Update(); virtual void Load(); virtual void DataVisualize(); @@ -2028,16 +2096,6 @@ /** Stop tracking all colors. Call this to clear the defaults, then add colors individually with AddColor(); */ void RemoveAllColors(); - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelBlobfinder( world, parent, id, typestr ); - } }; // ENERGY model -------------------------------------------------------------- @@ -2101,54 +2159,42 @@ class StgModelLaser : public StgModel { - private: - int dl_debug_laser; - - stg_laser_sample_t* samples; - uint32_t sample_count; - stg_meters_t range_min, range_max; - stg_radians_t fov; - uint32_t resolution; - - public: - // constructor - StgModelLaser( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ); - - // destructor - ~StgModelLaser(); - - virtual void Startup(); - virtual void Shutdown(); - virtual void Update(); - virtual void Load(); - virtual void Print( char* prefix ); - virtual void DataVisualize(); - - uint32_t GetSampleCount(){ return sample_count; } - - stg_laser_sample_t* GetSamples( uint32_t* count=NULL); - - void SetSamples( stg_laser_sample_t* samples, uint32_t count); - - // Get the user-tweakable configuration of the laser - stg_laser_cfg_t GetConfig( ); - - // Set the user-tweakable configuration of the laser - void SetConfig( stg_laser_cfg_t cfg ); - - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelLaser( world, parent, id, typestr ); - } +private: + int dl_debug_laser; + + stg_laser_sample_t* samples; + uint32_t sample_count; + stg_meters_t range_min, range_max; + stg_radians_t fov; + uint32_t resolution; + +public: + static const char* typestr; + // constructor + StgModelLaser( StgWorld* world, + StgModel* parent ); + + // destructor + ~StgModelLaser(); + + virtual void Startup(); + virtual void Shutdown(); + virtual void Update(); + virtual void Load(); + virtual void Print( char* prefix ); + virtual void DataVisualize(); + + uint32_t GetSampleCount(){ return sample_count; } + + stg_laser_sample_t* GetSamples( uint32_t* count=NULL); + + void SetSamples( stg_laser_sample_t* samples, uint32_t count); + + // Get the user-tweakable configuration of the laser + stg_laser_cfg_t GetConfig( ); + + // Set the user-tweakable configuration of the laser + void SetConfig( stg_laser_cfg_t cfg ); }; // \todo GRIPPER MODEL -------------------------------------------------------- @@ -2294,15 +2340,13 @@ GArray* data; public: - // constructor - StgModelFiducial( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ); - - // destructor - virtual ~StgModelFiducial(); - + static const char* typestr; + // constructor + StgModelFiducial( StgWorld* world, + StgModel* parent ); + // destructor + virtual ~StgModelFiducial(); + virtual void Load(); stg_meters_t max_range_anon; //< maximum detection range @@ -2314,16 +2358,6 @@ stg_fiducial_t* fiducials; ///< array of detected fiducials uint32_t fiducial_count; ///< the number of fiducials detected - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelFiducial( world, parent, id, typestr ); - } }; @@ -2348,12 +2382,10 @@ virtual void DataVisualize(); public: + static const char* typestr; // constructor StgModelRanger( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ); - + StgModel* parent ); // destructor virtual ~StgModelRanger(); @@ -2363,16 +2395,6 @@ uint32_t sensor_count; stg_ranger_sensor_t* sensors; stg_meters_t* samples; - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelRanger( world, parent, id, typestr ); - } }; // BLINKENLIGHT MODEL ---------------------------------------------------- @@ -2386,26 +2408,15 @@ public: + static const char* typestr; StgModelBlinkenlight( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ); + StgModel* parent ); ~StgModelBlinkenlight(); virtual void Load(); virtual void Update(); virtual void Draw( uint32_t flags, StgCanvas* canvas ); - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelBlinkenlight( world, parent, id, typestr ); - } }; // CAMERA MODEL ---------------------------------------------------- @@ -2423,11 +2434,8 @@ StgPerspectiveCamera _camera; public: - StgModelCamera( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ); + StgModel* parent ); ~StgModelCamera(); @@ -2443,16 +2451,6 @@ ///Imiate laser scan float* laser(); - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelCamera( world, parent, id, typestr ); - } }; // POSITION MODEL -------------------------------------------------------- @@ -2487,12 +2485,10 @@ stg_velocity_t integration_error; ///< errors to apply in simple odometry model public: + static const char* typestr; // constructor StgModelPosition( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr); - + StgModel* parent ); // destructor ~StgModelPosition(); @@ -2522,17 +2518,6 @@ stg_pose_t est_pose; ///< position estimate in local coordinates stg_pose_t est_pose_error; ///< estimated error in position estimate stg_pose_t est_origin; ///< global origin of the local coordinate system - - // static wrapper for the constructor - all models must implement - // this method and add an entry in typetable.cc - static StgModel* Create( StgWorld* world, - StgModel* parent, - stg_id_t id, - char* typestr ) - { - return (StgModel*)new StgModelPosition( world, parent, id, typestr ); - } - }; Modified: code/stage/trunk/libstage/test.cc =================================================================== --- code/stage/trunk/libstage/test.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/test.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -35,15 +35,17 @@ Init( &argc, &argv); StgWorldGui world( 400,400, "Test" ); + world.Start(); - StgModel mod( &world, NULL, 0, "model" ); + stg_geom_t geom; + bzero( &geom, sizeof(geom) ); - - // returned pose must be the same as the set pose - stg_pose_t pose; - - world.Start(); - + { + StgModel mod( &world, NULL ); + + // returned pose must be the same as the set pose + stg_pose_t pose; + for( stg_meters_t x=0; x<5; x+=0.1 ) { pose = new_pose( x, 0, 0, 0 ); @@ -87,8 +89,6 @@ mod.SetPose( new_pose( 0,0,0,0 )); - stg_geom_t geom; - bzero( &geom, sizeof(geom) ); for( stg_meters_t x=0.01; x<5; x+=0.1 ) { @@ -126,28 +126,59 @@ mod.SetGeom( geom ); + } // mod goes out of scope + -#define POP 100 + #define POP 100 StgModel* m[POP]; for( int i=0; i<POP; i++ ) { - m[i] = new StgModel( &world, NULL, 0, "model" ); + m[i] = new StgModel( &world, NULL ); + + //m[i]->Say( "Hello" ); m[i]->SetGeom( geom ); - //m[i]->SetPose( random_pose( -10,10, -10,10 ) ); - m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); + m[i]->SetPose( random_pose( -10,10, -10,10 ) ); + //m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); m[i]->SetColor( lrand48() | 0xFF000000 ); interact( &world ); } + + geom.size.x = 0.2; + geom.size.y = 0.2; + geom.size.z = 0.2; + for( int i=0; i<POP; i++ ) + { + StgModel* top = new StgModel( &world, m[i] ); + top->SetGeom( geom ); + //top->SetPose( new_pose( 0,0,0,0 ) ); + //m[i]->SetPose( random_pose( -10,10, -10,10 ) ); + //m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); + top->SetColor( lrand48() | 0xFF000000 ); + + interact( &world ); + } + + for( int i=0; i<POP; i++ ) + { +// m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); + //m[i]->SetColor( 0xFF00FF00 ); + + + stg_velocity_t v = {0,0,0,1}; + + m[i]->SetVelocity( v ); + + interact( &world ); + } // for( int i=0; i<POP; i++ ) -// { -// m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); -// m[i]->SetColor( 0xFF00FF00 ); -// interact( &world ); -// } +// { +// delete m[i]; +// interact( &world ); +// } + - StgWorldGui::Run(); } Modified: code/stage/trunk/libstage/typetable.cc =================================================================== --- code/stage/trunk/libstage/typetable.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/typetable.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -1,31 +1,52 @@ #include "stage_internal.hh" -// ****************************** -// Register new model types here -// Each entry maps a worldfile keyword onto a model constructor wrapper -static stg_typetable_entry_t typearray[] = { - { "model", StgModel::Create }, - { "laser", StgModelLaser::Create }, - { "position", StgModelPosition::Create }, - { "ranger", StgModelRanger::Create }, - { "fiducial", StgModelFiducial::Create }, - { "blobfinder", StgModelBlobfinder::Create }, - { "blinkenlight", StgModelBlinkenlight::Create }, - { "camera", StgModelCamera::Create }, - { NULL, NULL } // this must be the last entry -}; +// define constructor wrapping functions for use in the type table only -// ****************************** -// generate a hash table from the typetable array -GHashTable* Stg::stg_create_typetable( void ) +static StgModel* CreateModel( StgWorld* world, StgModel* parent ) +{ return new StgModel( world, parent ); } + +static StgModel* CreateModelBlinkenlight( StgWorld* world, StgModel* parent ) +{ return new StgModelBlinkenlight( world, parent ); } + +static StgModel* CreateModelPosition( StgWorld* world, StgModel* parent ) +{ return new StgModelPosition( world, parent ); } + +static StgModel* CreateModelLaser( StgWorld* world, StgModel* parent ) +{ return new StgModelLaser( world, parent ); } + +static StgModel* CreateModelRanger( StgWorld* world, StgModel* parent ) +{ return new StgModelRanger( world, parent ); } + +static StgModel* CreateModelCamera( StgWorld* world, StgModel* parent ) +{ return new StgModelCamera( world, parent ); } + +static StgModel* CreateModelFiducial( StgWorld* world, StgModel* parent ) +{ return new StgModelFiducial( world, parent ); } + +static StgModel* CreateModelBlobfinder( StgWorld* world, StgModel* parent ) +{ return new StgModelBlobfinder( world, parent ); } + + +void Stg::RegisterModels() { - GHashTable* table = g_hash_table_new( g_str_hash, g_str_equal ); + RegisterModel( MODEL_TYPE_PLAIN, "model", CreateModel ); + RegisterModel( MODEL_TYPE_LASER, "laser", CreateModelLaser ); + RegisterModel( MODEL_TYPE_FIDUCIAL, "fiducial", CreateModelFiducial ); + RegisterModel( MODEL_TYPE_RANGER, "ranger", CreateModelRanger ); + RegisterModel( MODEL_TYPE_CAMERA, "camera", CreateModelCamera ); + RegisterModel( MODEL_TYPE_POSITION, "position", CreateModelPosition ); + RegisterModel( MODEL_TYPE_BLOBFINDER, "blobfinder", CreateModelBlobfinder ); + RegisterModel( MODEL_TYPE_BLINKENLIGHT, "blinkenlight", CreateModelBlinkenlight); - for( stg_typetable_entry_t* ent = typearray; - ent->token; - ent++ ) - g_hash_table_insert( table, (void*)(ent->token), (void*)(ent->creator_fn) ); +#if DEBUG // human-readable view of the table + puts( "Stg::Typetable" ); + for( int i=0; i<MODEL_TYPE_COUNT; i++ ) + printf( " %d %s %p\n", + i, + typetable[i].token, + typetable[i].creator ); + puts(""); +#endif +} - return table; -} Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/libstage/world.cc 2008-06-16 22:42:23 UTC (rev 6593) @@ -58,10 +58,6 @@ unsigned int StgWorld::next_id = 0; bool StgWorld::quit_all = false; -const double STG_DEFAULT_WORLD_PPM = 50; // 2cm pixels -const stg_msec_t STG_DEFAULT_WORLD_INTERVAL_REAL = 100; ///< real time between updates -const stg_msec_t STG_DEFAULT_WORLD_INTERVAL_SIM = 100; ///< duration of sim timestep - static guint PointIntHash( stg_point_int_t* pt ) { return( pt->x + (pt->y<<16 )); @@ -88,20 +84,12 @@ delete sr; } -StgWorld::StgWorld( void ) -{ - Initialize( "MyWorld", - STG_DEFAULT_WORLD_INTERVAL_SIM, - STG_DEFAULT_WORLD_INTERVAL_REAL, - STG_DEFAULT_WORLD_PPM ); -} - StgWorld::StgWorld( const char* token, - stg_msec_t interval_sim, - stg_msec_t interval_real, - double ppm ) + stg_msec_t interval_sim, + stg_msec_t interval_real, + double ppm ) { - Initialize( token, interval_sim, interval_real, ppm ); + Initialize( token, interval_sim, interval_real, ppm ); } void StgWorld::Initialize( const char* token, @@ -115,7 +103,7 @@ exit(-1); } - this->id = StgWorld::next_id++; + // this->id = StgWorld::next_id++; this->ray_list = NULL; this->quit_time = 0; @@ -129,7 +117,7 @@ this->graphics = false; // subclasses that provide GUIs should // change this - this->models_by_id = g_hash_table_new( g_direct_hash, g_direct_equal ); + //this->models_by_id = g_hash_table_new( g_direct_hash, g_direct_equal ); this->models_by_name = g_hash_table_new( g_str_hash, g_str_equal ); this->sim_time = 0; this->interval_sim = (stg_usec_t)thousand * interval_sim; @@ -167,7 +155,7 @@ if( wf ) delete wf; //if( bgrid ) delete bgrid; - g_hash_table_destroy( models_by_id ); + //g_hash_table_destroy( models_by_id ); g_hash_table_destroy( models_by_name ); g_free( token ); @@ -176,7 +164,7 @@ void StgWorld::RemoveModel( StgModel* mod ) { - g_hash_table_remove( models_by_id, mod ); + //g_hash_table_remove( models_by_id, mod ); g_hash_table_remove( models_by_name, mod ); } @@ -248,6 +236,8 @@ void StgWorld::Load( const char* worldfile_path ) { + GHashTable* entitytable = g_hash_table_new( g_direct_hash, g_direct_equal ); + printf( " [Loading %s]", worldfile_path ); fflush(stdout); @@ -277,7 +267,7 @@ if( wf->PropertyExists( entity, "resolution" ) ) this->ppm = - 1.0 / wf->ReadFloat( entity, "resolution", STG_DEFAULT_WORLD_PPM ); + 1.0 / wf->ReadFloat( entity, "resolution", 1.0 / this->ppm ); this->paused = wf->ReadInt( entity, "paused", this->paused ); @@ -299,18 +289,33 @@ entity, parent_entity ); StgModel *mod, *parent; + + parent = (StgModel*)g_hash_table_lookup( entitytable, + (gpointer)parent_entity ); + + // find the creator function pointer in the hash table. use the + // vanilla model if the type is NULL. + stg_creator_t creator; + + //printf( "creating model of type %s\n", typestr ); - parent = GetModel( parent_entity ); - - // find the creator function pointer in the hash table - stg_creator_t creator = (stg_creator_t) - g_hash_table_lookup( Stg::Typetable(), typestr ); - - // if we found a creator function, call it + if( typestr ) // look up the string in the typetable + for( int i=0; i<MODEL_TYPE_COUNT; i++ ) + if( strcmp( typestr, typetable[i].token ) == 0 ) + { + creator = typetable[i].creator; + break; + } + + //creator = (stg_creator_t)g_hash_table_lookup( Stg::Typetable(), typestr ); + //else + //creator = NULL; + + // if we found a creator function, call it if( creator ) { //printf( "creator fn: %p\n", creator ); - mod = (*creator)( this, parent, entity, typestr ); + mod = (*creator)( this, parent ); } else { @@ -319,20 +324,29 @@ exit( 1 ); } + //printf( "created model %s\n", mod->Token() ); + // configure the model with properties from the world file + mod->SetWorldfile( wf, entity ); mod->Load(); + + // record the model we created for this worlfile entry + g_hash_table_insert( entitytable, (gpointer)entity, mod ); } // warn about unused WF linesa wf->WarnUnused(); // run through the loaded models and initialise them - g_hash_table_foreach( models_by_id, (GHFunc)init_models, NULL ); + g_hash_table_foreach( entitytable, (GHFunc)init_models, NULL ); + + // now we're done with the worldfile entry lookup + g_hash_table_destroy( entitytable ); stg_usec_t load_end_time = RealTimeNow(); - printf( "[Load time %.3fsec]", (load_end_time - load_start_time) / 1000000.0 ); - + printf( "[Load time %.3fsec]", + (load_end_time - load_start_time) / 1000000.0 ); } void StgWorld::UnLoad() @@ -344,9 +358,9 @@ g_list_free( children ); children = NULL; - g_hash_table_remove_all( child_types ); // small memory leak + //g_hash_table_remove_all( child_types ); // small memory leak - g_hash_table_remove_all( models_by_id ); + //g_hash_table_remove_all( models_by_id ); g_hash_table_remove_all( models_by_name ); @@ -474,7 +488,7 @@ //PRINT_DEBUG3( "World %s adding model %d %s to hash tables ", // token, mod->id, mod->Token() ); - g_hash_table_insert( this->models_by_id, (gpointer)mod->Id(), mod ); + //g_hash_table_insert( this->models_by_id, (gpointer)mod->Id(), mod ); AddModelName( mod ); } @@ -495,11 +509,11 @@ return mod; } -StgModel* StgWorld::GetModel( const stg_id_t id ) -{ - PRINT_DEBUG1( "looking up model id %d in models_by_id", id ); - return (StgModel*)g_hash_table_lookup( this->models_by_id, (gpointer)id ); -} +// StgModel* StgWorld::GetModel( const stg_id_t id ) +// { +// PRINT_DEBUG1( "looking up model id %d in models_by_id", id ); +// return (StgModel*)g_hash_table_lookup( this->models_by_id, (gpointer)id ); +// } void StgWorld::RecordRay( double x1, double y1, double x2, double y2 ) Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-16 21:51:08 UTC (rev 6592) +++ code/stage/trunk/worlds/fasr.world 2008-06-16 22:42:23 UTC (rev 6593) @@ -15,7 +15,7 @@ resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 10 # real-time interval between simulation updates in milliseconds +interval_real 0 # real-time interval between simulation updates in milliseconds paused 1 # configure the GUI window This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-16 20:24:30
|
Revision: 6614 http://playerstage.svn.sourceforge.net/playerstage/?rev=6614&view=rev Author: rtv Date: 2008-06-16 20:24:37 -0700 (Mon, 16 Jun 2008) Log Message: ----------- improving external API. mainly running and updating worlds. also increased speed a bit Modified Paths: -------------- code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/main.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/model_load.cc code/stage/trunk/libstage/stage.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/test.cc code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldgui.cc code/stage/trunk/worlds/fasr.world Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/canvas.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -13,11 +13,11 @@ void StgCanvas::TimerCallback( StgCanvas* c ) { - c->redraw(); - - Fl::repeat_timeout(((double)c->interval/1000), - (Fl_Timeout_Handler)StgCanvas::TimerCallback, - c); + c->redraw(); + + Fl::repeat_timeout(((double)c->interval/1000), + (Fl_Timeout_Handler)StgCanvas::TimerCallback, + c); } @@ -47,10 +47,10 @@ showflags = STG_SHOW_CLOCK | STG_SHOW_BLOCKS | STG_SHOW_GRID | STG_SHOW_DATA; - // start the timer that causes regular redraws - Fl::add_timeout( ((double)interval/1000), - (Fl_Timeout_Handler)StgCanvas::TimerCallback, - this); + // // start the timer that causes regular redraws + Fl::add_timeout( ((double)interval/1000), + (Fl_Timeout_Handler)StgCanvas::TimerCallback, + this); } StgCanvas::~StgCanvas() @@ -133,7 +133,7 @@ //printf("Clicked rByte: 0x%X, gByte: 0x%X, bByte: 0x%X, aByte: 0x%X\n", rByte, gByte, bByte, aByte); //printf("-->model Id = 0x%X\n", modelId); - StgModel* mod = (StgModel*)g_hash_table_lookup( StgModel::modelsbyid, (void*)modelId ); + StgModel* mod = StgModel::LookupId( modelId ); //printf("%p %s %d %x\n", mod, mod ? mod->Token() : "(none)", id, id ); @@ -208,6 +208,7 @@ camera.scale( Fl::event_dy(), Fl::event_x(), w(), Fl::event_y(), h() ); } invalidate(); + redraw(); } return 1; @@ -226,6 +227,7 @@ } invalidate(); + redraw(); } else if( Fl::event_state( FL_ALT ) ) { @@ -319,6 +321,8 @@ } startx = Fl::event_x(); starty = Fl::event_y(); + + redraw(); return 1; // end case FL_DRAG case FL_RELEASE: // mouse button released @@ -347,9 +351,9 @@ world->TogglePause(); break; case ' ': // space bar - camera.resetAngle(); - invalidate(); + //invalidate(); + redraw(); break; case FL_Left: camera.move( -10, 0 ); break; case FL_Right: camera.move( 10, 0 );; break; @@ -565,7 +569,7 @@ // if( loaded_texture == true && use_perspective_camera == true ) // return; - if (!valid() || world->dirty ) + if (!valid() ) { valid(1); FixViewport(w(), h()); Modified: code/stage/trunk/libstage/main.cc =================================================================== --- code/stage/trunk/libstage/main.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/main.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -42,12 +42,16 @@ puts("");// end the first start-up line + + // XX TODO + // initialize libstage Stg::Init( &argc, &argv ); // arguments at index optindex and later are not options, so they // must be world file names + bool loaded_world_file = false; while( optindex < argc ) { @@ -56,19 +60,18 @@ const char* worldfilename = argv[optindex]; StgWorldGui* world = new StgWorldGui( 400, 300, worldfilename ); world->Load( worldfilename ); - world->Start(); loaded_world_file = true; } optindex++; } - if( loaded_world_file == false ) { - // replace this with a loading dialog/window - StgWorldGui* world = new StgWorldGui( 400, 300 ); - } +// if( loaded_world_file == false ) { +// // replace this with a loading dialog/window +// StgWorldGui* world = new StgWorldGui( 400, 300 ); +// } - - - StgWorldGui::Run(); // run all the simulations + + while(true) + StgWorld::UpdateAll(); } Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/model.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -258,6 +258,8 @@ if( callbacks ) g_hash_table_destroy( callbacks ); + g_hash_table_remove( StgModel::modelsbyid, (void*)id ); + world->RemoveModel( this ); } Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/model_laser.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -17,23 +17,21 @@ #include "stage_internal.hh" // DEFAULT PARAMETERS FOR LASER MODEL -static const bool DEFAULT_LASER_FILLED = true; -static const stg_watts_t DEFAULT_LASER_WATTS = 17.5; // laser power consumption -static const stg_meters_t DEFAULT_LASER_SIZEX = 0.15; -static const stg_meters_t DEFAULT_LASER_SIZEY = 0.15; -static const stg_meters_t DEFAULT_LASER_SIZEZ = 0.2; -static const stg_meters_t DEFAULT_LASER_MINRANGE = 0.0; -static const stg_meters_t DEFAULT_LASER_MAXRANGE = 8.0; -static const stg_radians_t DEFAULT_LASER_FOV = M_PI; -static const unsigned int DEFAULT_LASER_SAMPLES = 180; -static const stg_msec_t DEFAULT_LASER_INTERVAL_MS = 100; -static const unsigned int DEFAULT_LASER_RESOLUTION = 1; +const bool StgModelLaser::DEFAULT_FILLED = true; +const stg_watts_t StgModelLaser::DEFAULT_WATTS = 17.5; +const stg_size_t StgModelLaser::DEFAULT_SIZE = {0.15, 0.15, 0.2 }; +const stg_meters_t StgModelLaser::DEFAULT_MINRANGE = 0.0; +const stg_meters_t StgModelLaser::DEFAULT_MAXRANGE = 8.0; +const stg_radians_t StgModelLaser::DEFAULT_FOV = M_PI; +const unsigned int StgModelLaser::DEFAULT_SAMPLES = 180; +const stg_msec_t StgModelLaser::DEFAULT_INTERVAL_MS = 100; +const unsigned int StgModelLaser::DEFAULT_RESOLUTION = 1; -static const char LASER_GEOM_COLOR[] = "blue"; -//static const char LASER_BRIGHT_COLOR[] = "blue"; -//static const char LASER_CFG_COLOR[] = "light steel blue"; -//static const char LASER_COLOR[] = "steel blue"; -//static const char LASER_FILL_COLOR[] = "powder blue"; +const char StgModelLaser::DEFAULT_GEOM_COLOR[] = "blue"; +//const char BRIGHT_COLOR[] = "blue"; +//const char CFG_COLOR[] = "light steel blue"; +//const char COLOR[] = "steel blue"; +//const char FILL_COLOR[] = "powder blue"; /** @ingroup model @@ -83,24 +81,22 @@ id, typestr ); // sensible laser defaults - interval = 1e3 * DEFAULT_LASER_INTERVAL_MS; + interval = 1e3 * StgModelLaser::DEFAULT_INTERVAL_MS; laser_return = LaserVisible; stg_geom_t geom; memset( &geom, 0, sizeof(geom)); - geom.size.x = DEFAULT_LASER_SIZEX; - geom.size.y = DEFAULT_LASER_SIZEY; - geom.size.z = DEFAULT_LASER_SIZEZ; + geom.size = StgModelLaser::DEFAULT_SIZE; SetGeom( geom ); // set default color - SetColor( stg_lookup_color(LASER_GEOM_COLOR)); + SetColor( stg_lookup_color(DEFAULT_GEOM_COLOR)); - range_min = DEFAULT_LASER_MINRANGE; - range_max = DEFAULT_LASER_MAXRANGE; - fov = DEFAULT_LASER_FOV; - sample_count = DEFAULT_LASER_SAMPLES; - resolution = DEFAULT_LASER_RESOLUTION; + range_min = DEFAULT_MINRANGE; + range_max = DEFAULT_MAXRANGE; + fov = DEFAULT_FOV; + sample_count = DEFAULT_SAMPLES; + resolution = DEFAULT_RESOLUTION; // don't allocate sample buffer memory until Update() is called samples = NULL; @@ -237,7 +233,7 @@ PRINT_DEBUG( "laser startup" ); // start consuming power - SetWatts( DEFAULT_LASER_WATTS ); + SetWatts( StgModelLaser::DEFAULT_WATTS ); } void StgModelLaser::Shutdown( void ) Modified: code/stage/trunk/libstage/model_load.cc =================================================================== --- code/stage/trunk/libstage/model_load.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/model_load.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -33,7 +33,7 @@ { //printf( "changed %s to %s\n", this->token, token ); this->token = strdup( name ); - world->AddModelName( this ); // add this name to the world's table + world->AddModel( this ); // add this name to the world's table } else PRINT_ERR1( "Name blank for model %s. Check your worldfile\n", this->token ); Modified: code/stage/trunk/libstage/stage.cc =================================================================== --- code/stage/trunk/libstage/stage.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/stage.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -23,6 +23,7 @@ stg_typetable_entry_t Stg::typetable[MODEL_TYPE_COUNT]; + void Stg::Init( int* argc, char** argv[] ) { PRINT_DEBUG( "Stg::Init()" ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/stage.hh 2008-06-17 03:24:37 UTC (rev 6614) @@ -84,13 +84,18 @@ /** The Stage library uses its own namespace */ namespace Stg { + // foreward declare + class StgCanvas; + class Worldfile; + class StgWorld; + class StgModel; + /** Initialize the Stage library */ void Init( int* argc, char** argv[] ); /** returns true iff Stg::Init() has been called. */ bool InitDone(); - - + /** Create unique identifying numbers for each type of model, and a count of the number of types. */ typedef enum { @@ -106,9 +111,6 @@ // types } stg_model_type_t; - // foreward declare - class StgCanvas; - class Worldfile; /// Copyright string const char COPYRIGHT[] = @@ -971,8 +973,15 @@ friend class StgTime; friend class StgCanvas; +public: + static void UpdateAll(); + private: + static GList* world_list; + /** Update all existing worlds */ + + static bool quit_all; // quit all worlds ASAP static unsigned int next_id; //< initialized to zero, used tob //allocate unique sequential world ids @@ -1010,8 +1019,9 @@ GList* velocity_list; ///< a list of models that have non-zero velocity, for efficient updating stg_usec_t sim_time; ///< the current sim time in this world in ms - stg_usec_t wall_last_update; ///< the real time of the last update in ms + //stg_usec_t wall_last_update; ///< the real time of the last update in ms + long unsigned int updates; ///< the number of simulated time steps executed so far bool dirty; ///< iff true, a gui redraw would be required @@ -1026,7 +1036,6 @@ bool paused; ///< the world only updates when this is false GList* update_list; //< the descendants that need Update() called - void AddModelName( StgModel* mod ); void StartUpdatingModel( StgModel* mod ); void StopUpdatingModel( StgModel* mod ); @@ -1055,9 +1064,10 @@ void RemoveBlock( int x, int y, StgBlock* block ); -protected: +public: stg_usec_t interval_real; ///< real-time interval between updates - set this to zero for 'as fast as possible +protected: GHashTable* superregions; static void UpdateCb( StgWorld* world); @@ -1099,8 +1109,8 @@ stg_usec_t SimTimeNow(void){ return sim_time;} ; stg_usec_t RealTimeNow(void); stg_usec_t RealTimeSinceStart(void); - void PauseUntilNextUpdateTime(void); - void IdleUntilNextUpdateTime( int (*idler)(void) ); + //void PauseUntilNextUpdateTime(void); + // void IdleUntilNextUpdateTime( int (*idler)(void) ); void AddBlock( StgBlock* block ); void RemoveBlock( StgBlock* block ); @@ -1130,7 +1140,7 @@ /** Returns a pointer to the model identified by ID, or NULL if nonexistent */ - StgModel* GetModel( const stg_id_t id ); + //StgModel* GetModel( const stg_id_t id ); /** Returns a pointer to the model identified by name, or NULL if nonexistent */ @@ -1176,7 +1186,15 @@ static uint32_t count; static GHashTable* modelsbyid; + public: + + /** Look up a model pointer by a unique model ID */ + static StgModel* LookupId( uint32_t id ) + { + return (StgModel*)g_hash_table_lookup( modelsbyid, (void*)id ); + } + /** unique process-wide identifier for this model */ uint32_t id; @@ -1804,8 +1822,6 @@ // FLTK Gui includes #include <FL/Fl.H> -//#include <FL/Fl_Box.H> -//#include <FL/Fl_Double_Window.H> #include <FL/Fl_Gl_Window.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Menu_Button.H> @@ -2003,15 +2019,13 @@ StgCanvas* canvas; Fl_Menu_Bar* mbar; + stg_usec_t real_time_of_last_update; + public: StgWorldGui(int W,int H,const char*L=0); ~StgWorldGui(); - /** Start the simulation and GUI. Does not return */ - static void Run(); - void Start(); - void Stop(); - void Cycle(); + virtual bool Update(); virtual void Load( const char* filename ); virtual void UnLoad(); @@ -2169,6 +2183,18 @@ class StgModelLaser : public StgModel { private: + // DEFAULT PARAMETERS FOR LASER MODEL + static const bool DEFAULT_FILLED; + static const stg_watts_t DEFAULT_WATTS; + static const stg_size_t DEFAULT_SIZE; + static const stg_meters_t DEFAULT_MINRANGE; + static const stg_meters_t DEFAULT_MAXRANGE; + static const stg_radians_t DEFAULT_FOV; + static const unsigned int DEFAULT_SAMPLES; + static const stg_msec_t DEFAULT_INTERVAL_MS; + static const unsigned int DEFAULT_RESOLUTION; + static const char DEFAULT_GEOM_COLOR[]; + int dl_debug_laser; stg_laser_sample_t* samples; Modified: code/stage/trunk/libstage/test.cc =================================================================== --- code/stage/trunk/libstage/test.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/test.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -8,8 +8,10 @@ void interact( StgWorldGui* wg ) { - for( int i=0; i<100; i++ ) - wg->Cycle(); + //for( int i=0; i<100; i++ ) + // wg->Cycle(); + + wg->Update(); } void test( char* str, double a, double b ) @@ -180,5 +182,6 @@ // } - StgWorldGui::Run(); + while(true) + world.Update(); } Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/world.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -57,6 +57,7 @@ // static data members unsigned int StgWorld::next_id = 0; bool StgWorld::quit_all = false; +GList* StgWorld::world_list = NULL; static guint PointIntHash( stg_point_int_t* pt ) { @@ -84,6 +85,14 @@ delete sr; } +void StgWorld::UpdateAll() +{ + assert( StgWorld::world_list ); + + for( GList* it = StgWorld::world_list; it; it=it->next ) + ((StgWorld*)it->data)->Update(); +} + StgWorld::StgWorld( const char* token, stg_msec_t interval_sim, stg_msec_t interval_real, @@ -102,8 +111,8 @@ PRINT_WARN( "Stg::Init() must be called before a StgWorld is created." ); exit(-1); } - - // this->id = StgWorld::next_id++; + StgWorld::world_list = g_list_append( StgWorld::world_list, this ); + this->ray_list = NULL; this->quit_time = 0; @@ -159,6 +168,8 @@ g_hash_table_destroy( models_by_name ); g_free( token ); + + world_list = g_list_remove( world_list, this ); } @@ -399,54 +410,6 @@ return timenow - real_time_start; } -void StgWorld::PauseUntilNextUpdateTime( void ) -{ - // sleep until it's time to update - stg_usec_t timenow = RealTimeSinceStart(); - - /* printf( "\ntimesincestart %llu interval_real %llu interval_sim %llu real_time_next_update %llu\n", - timenow, - interval_real, - interval_sim, - real_time_next_update ); - */ - - if( timenow < real_time_next_update ) - { - usleep( real_time_next_update - timenow ); - } - - interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - - real_time_now = timenow; - real_time_next_update += interval_real; -} - -void StgWorld::IdleUntilNextUpdateTime( int (*idler)(void) ) -{ - // sleep until it's time to update - stg_usec_t timenow; - - /* printf( "\ntimesincestart %llu interval_real %llu interval_sim %llu real_time_next_update %llu\n", - timenow, - interval_real, - interval_sim, - real_time_next_update ); - */ - - while( (timenow = RealTimeSinceStart()) < real_time_next_update ) - { - (*idler)(); - usleep( 1000 ); - } - - interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - - real_time_now = timenow; - real_time_next_update += interval_real; -} - - #define DEBUG 1 bool StgWorld::Update() @@ -474,27 +437,13 @@ stg_usec_t timenow = RealTimeSinceStart(); interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - - //interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - real_time_now = timenow; - //real_time_next_update += interval_real; return true; } void StgWorld::AddModel( StgModel* mod ) { - //PRINT_DEBUG3( "World %s adding model %d %s to hash tables ", - // token, mod->id, mod->Token() ); - - //g_hash_table_insert( this->models_by_id, (gpointer)mod->Id(), mod ); - AddModelName( mod ); -} - - -void StgWorld::AddModelName( StgModel* mod ) -{ g_hash_table_insert( this->models_by_name, (gpointer)mod->Token(), mod ); } @@ -509,13 +458,6 @@ return mod; } -// StgModel* StgWorld::GetModel( const stg_id_t id ) -// { -// PRINT_DEBUG1( "looking up model id %d in models_by_id", id ); -// return (StgModel*)g_hash_table_lookup( this->models_by_id, (gpointer)id ); -// } - - void StgWorld::RecordRay( double x1, double y1, double x2, double y2 ) { float* drawpts = new float[4]; Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-17 03:24:37 UTC (rev 6614) @@ -511,50 +511,38 @@ return StgWorld::Save( filename ); } -void StgWorld::UpdateCb( StgWorld* world ) -{ - world->Update(); - // need to reinstantiatethe timeout each time - Fl::repeat_timeout( world->interval_real/1e6, - (Fl_Timeout_Handler)UpdateCb, world ); -} - -static void idle_callback( StgWorld* world ) +bool StgWorldGui::Update() { - world->Update(); -} + if( real_time_of_last_update == 0 ) + real_time_of_last_update = RealTimeNow(); + + bool val = StgWorld::Update(); + + stg_usec_t interval; + stg_usec_t timenow; + + do { // we loop over updating the GUI, sleeping if there's any spare + // time + Fl::check(); -void StgWorldGui::Start() -{ - // if a non-zero interval was requested, call Update() after that - // interval - if( interval_real > 0 ) - Fl::add_timeout( interval_real/1e6, (Fl_Timeout_Handler)UpdateCb, this ); - else // otherwise call Update() whenever there's no GUI work to do - Fl::add_idle( (Fl_Timeout_Handler)idle_callback, this ); + timenow = RealTimeNow(); + interval = timenow - real_time_of_last_update; // guaranteed to be >= 0 + + double sleeptime = (double)interval_real - (double)interval; + + if( sleeptime > 0 ) + usleep( MIN(sleeptime,100000) ); // check the GUI at 10Hz min + + } while( interval < interval_real ); + + + real_time_of_last_update = timenow; + + return val; } -void StgWorldGui::Stop() -{ - Fl::remove_timeout( (Fl_Timeout_Handler)UpdateCb, this ); - Fl::remove_idle( (Fl_Timeout_Handler)idle_callback, this ); -} - - -void StgWorldGui::Run() -{ - Fl::run(); -} - -void StgWorldGui::Cycle() -{ - if( Fl::ready() ) - Fl::check(); -} - - void StgWorldGui::DrawTree( bool drawall ) { g_hash_table_foreach( superregions, (GHFunc)SuperRegion::Draw_cb, NULL ); Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-17 03:08:57 UTC (rev 6613) +++ code/stage/trunk/worlds/fasr.world 2008-06-17 03:24:37 UTC (rev 6614) @@ -15,7 +15,7 @@ resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 0 # real-time interval between simulation updates in milliseconds +interval_real 20 # real-time interval between simulation updates in milliseconds paused 1 # configure the GUI window @@ -26,7 +26,7 @@ rotate [ 0.000 0.000 ] scale 33.306 show_data 0 - interval 100 + #interval 10 ) # load an environment bitmap This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-17 00:40:10
|
Revision: 6617 http://playerstage.svn.sourceforge.net/playerstage/?rev=6617&view=rev Author: rtv Date: 2008-06-17 00:40:18 -0700 (Tue, 17 Jun 2008) Log Message: ----------- cleaning up API some more - moved real time stuff out of world and into worldgui where it belongs Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/docsrc/stage.dox code/stage/trunk/docsrc/stage.txt code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.cc code/stage/trunk/libstage/worldgui.cc code/stage/trunk/libstageplugin/CMakeLists.txt code/stage/trunk/libstageplugin/p_driver.cc code/stage/trunk/libstageplugin/p_driver.h code/stage/trunk/libstageplugin/p_graphics3d.cc code/stage/trunk/libstageplugin/p_laser.cc code/stage/trunk/libstageplugin/p_position.cc code/stage/trunk/libstageplugin/p_sonar.cc code/stage/trunk/worlds/fasr.world code/stage/trunk/worlds/simple.world Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/CMakeLists.txt 2008-06-17 07:40:18 UTC (rev 6617) @@ -8,13 +8,8 @@ SET( APIVERSION ${V_MAJOR}.${V_MINOR} ) # minimum version of Player to build the plugin -SET( MIN_PLAYER 99.0.0 ) # change once plugin is fixed +SET( MIN_PLAYER 2.2.0 ) # change once plugin is fixed -#SET(CMAKE_BUILD_TYPE debug) -#SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3") -#SET(CMAKE_C_FLAGS_DISTRIBUTION "-O3") - - cmake_minimum_required( VERSION 2.4 FATAL_ERROR ) IF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6) @@ -35,23 +30,9 @@ pkg_search_module( GLIB REQUIRED glib-2.0 ) find_package( OpenGL REQUIRED ) -# Look for player v${MIN_PLAYER} or higher and set flags -# built-ins don't work properly, so use pkg-config directly -FIND_PROGRAM (PKGCONFIG NAMES pkg-config) -IF (PKGCONFIG) - EXECUTE_PROCESS (COMMAND pkg-config --atleast-version=${MIN_PLAYER} playercore --silence-errors - RESULT_VARIABLE PLAYER_FOUND) - IF (PLAYER_FOUND EQUAL 0) - # found the correct version - pkg_search_module( PLAYER playercore ) - ADD_SUBDIRECTORY( libstageplugin ) - ELSE (PLAYER_FOUND EQUAL 0) - MESSAGE(STATUS "Player >=v${MIN_PLAYER} not found, skipping Player plugin") - ENDIF (PLAYER_FOUND EQUAL 0) -ELSE (PKGCONFIG) - MESSAGE (STATUS "pkg-config not found, skipping Player plugin") -ENDIF (PKGCONFIG) +pkg_search_module( PLAYER playercore ) + # find FLTK and set flags FIND_PROGRAM (FLTKCONFIG NAMES fltk-config) IF (FLTKCONFIG) @@ -99,6 +80,11 @@ ADD_SUBDIRECTORY(libstage) ADD_SUBDIRECTORY(examples) +if( PLAYER_FOUND ) +ADD_SUBDIRECTORY(libstageplugin) +endif( PLAYER_FOUND ) + + INSTALL(FILES rgb.txt stagelogo.png DESTINATION share/stage ) Modified: code/stage/trunk/docsrc/stage.dox =================================================================== --- code/stage/trunk/docsrc/stage.dox 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/docsrc/stage.dox 2008-06-17 07:40:18 UTC (rev 6617) @@ -159,7 +159,7 @@ # member inherits the documentation from any documented member that it # re-implements. -INHERIT_DOCS = NO +INHERIT_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first @@ -219,7 +219,7 @@ # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = YES +EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. @@ -569,13 +569,13 @@ # then for each documented function all documented # functions referencing it will be listed. -REFERENCED_BY_RELATION = YES +REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. -REFERENCES_RELATION = YES +REFERENCES_RELATION = NO # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen Modified: code/stage/trunk/docsrc/stage.txt =================================================================== --- code/stage/trunk/docsrc/stage.txt 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/docsrc/stage.txt 2008-06-17 07:40:18 UTC (rev 6617) @@ -85,6 +85,8 @@ <li>Reed Hedges <tt>(hedges@...)</tt> <li>Andrew Howard <tt>(ahoward@...)</tt> <li>Pooya Karimian <tt>(pooyak@...)</tt> +<li>Jeremy Asher <tt>(jra11@...)</tt> +<li>Alex Couture-Beil <tt>(asc17@...)</tt> </ul> Many patches and bug reports have been contributed by users around the Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-06-17 07:40:18 UTC (rev 6617) @@ -1,5 +1,8 @@ add_library( stage SHARED + world.cc + worldgui.cc + worldfile.cc stage.cc typetable.cc stage.hh # get headers into IDE projects @@ -23,9 +26,6 @@ model_props.cc model_ranger.cc resource.cc - world.cc - worldfile.cc - worldgui.cc texture_manager.cc ) Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstage/canvas.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -21,7 +21,7 @@ } - StgCanvas::StgCanvas( StgWorld* world, int x, int y, int w, int h) + StgCanvas::StgCanvas( StgWorldGui* world, int x, int y, int w, int h) : Fl_Gl_Window(x,y,w,h) { end(); @@ -88,7 +88,7 @@ // render all top-level, draggable models in a color that is their // id - for( GList* it=world->children; it; it=it->next ) + for( GList* it= world->StgWorld::children; it; it=it->next ) { StgModel* mod = (StgModel*)it->data; @@ -444,7 +444,7 @@ glDisable( GL_DEPTH_TEST ); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - for( GList* it=world->children; it; it=it->next ) + for( GList* it=world->StgWorld::children; it; it=it->next ) { ((StgModel*)it->data)->DrawTrailFootprint(); } @@ -455,7 +455,7 @@ { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL ); - for( GList* it=world->children; it; it=it->next ) + for( GList* it=world->StgWorld::children; it; it=it->next ) { ((StgModel*)it->data)->DrawTrailBlocks(); } @@ -464,7 +464,7 @@ if( showflags & STG_SHOW_ARROWS ) { glEnable( GL_DEPTH_TEST ); - for( GList* it=world->children; it; it=it->next ) + for( GList* it=world->StgWorld::children; it; it=it->next ) { ((StgModel*)it->data)->DrawTrailArrows(); } @@ -472,7 +472,7 @@ if( showflags & STG_SHOW_BLOCKS ) { - for( GList* it=world->children; it; it=it->next ) + for( GList* it=world->StgWorld::children; it; it=it->next ) { StgModel* mod = ((StgModel*)it->data); @@ -500,7 +500,7 @@ //mod->Draw( showflags ); // draw the stuff that changes every update // draw everything else - for( GList* it=world->children; it; it=it->next ) + for( GList* it=world->StgWorld::children; it; it=it->next ) ((StgModel*)it->data)->Draw( showflags, this ); } Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstage/stage.hh 2008-06-17 07:40:18 UTC (rev 6617) @@ -988,7 +988,7 @@ static int AddBlockPixel( int x, int y, int z, stg_render_info_t* rinfo ) ; //< used as a callback by StgModel - stg_usec_t real_time_next_update; + //stg_usec_t real_time_next_update; stg_usec_t real_time_start; bool quit; // quit this world ASAP @@ -996,11 +996,10 @@ // convert a distance in meters to a distance in world occupancy grid pixels int32_t MetersToPixels( stg_meters_t x ){ return (int32_t)floor(x * ppm) ; }; - void Initialize( const char* token, - stg_msec_t interval_sim, - stg_msec_t interval_real, - double ppm ); - + void Initialize( const char* token, + stg_msec_t interval_sim, + double ppm ); + virtual void PushColor( stg_color_t col ) { /* do nothing */ }; virtual void PushColor( double r, double g, double b, double a ) { /* do nothing */ }; virtual void PopColor(){ /* do nothing */ }; @@ -1018,23 +1017,14 @@ GHashTable* models_by_name; ///< the models that make up the world, indexed by name GList* velocity_list; ///< a list of models that have non-zero velocity, for efficient updating - stg_usec_t sim_time; ///< the current sim time in this world in ms - //stg_usec_t wall_last_update; ///< the real time of the last update in ms - long unsigned int updates; ///< the number of simulated time steps executed so far - bool dirty; ///< iff true, a gui redraw would be required - stg_usec_t interval_sim; ///< temporal resolution: milliseconds that elapse between simulated time steps - stg_usec_t interval_log[INTERVAL_LOG_LEN]; - int total_subs; ///< the total number of subscriptions to all models double ppm; ///< the resolution of the world model in pixels per meter - bool paused; ///< the world only updates when this is false - GList* update_list; //< the descendants that need Update() called void StartUpdatingModel( StgModel* mod ); @@ -1063,14 +1053,13 @@ void RemoveBlock( int x, int y, StgBlock* block ); - -public: - stg_usec_t interval_real; ///< real-time interval between updates - set this to zero for 'as fast as possible - protected: GHashTable* superregions; + stg_usec_t interval_sim; ///< temporal resolution: milliseconds that elapse between simulated time steps static void UpdateCb( StgWorld* world); + + stg_usec_t sim_time; ///< the current sim time in this world in ms GList* ray_list; // store rays traced for debugging purposes @@ -1091,15 +1080,14 @@ GList* GetRayList(){ return ray_list; }; void ClearRays(); + long unsigned int updates; ///< the number of simulated time steps executed so far public: static const int DEFAULT_PPM = 50; // default resolution in pixels per meter - static const stg_msec_t DEFAULT_INTERVAL_REAL = 100; ///< real time between updates static const stg_msec_t DEFAULT_INTERVAL_SIM = 100; ///< duration of sim timestep StgWorld( const char* token = "MyWorld", stg_msec_t interval_sim = DEFAULT_INTERVAL_SIM, - stg_msec_t interval_real = DEFAULT_INTERVAL_REAL, double ppm = DEFAULT_PPM ); virtual ~StgWorld(); @@ -1125,9 +1113,6 @@ virtual bool Save( const char* filename ); virtual bool Update(void); - void Start(){ paused = false; }; - void Stop(){ paused = true; }; - void TogglePause(){ paused = !paused; }; bool TestQuit(){ return( quit || quit_all ); } void Quit(){ quit = true; } void QuitAll(){ quit_all = true; } @@ -1146,11 +1131,6 @@ nonexistent */ StgModel* GetModel( const char* name ); - - /** Get human readable string that describes the current simulation - time. */ - void ClockString( char* str, size_t maxlen ); - /** Return the 3D bounding box of the world, in meters */ stg_bounds3d_t GetExtent(){ return extent; }; @@ -1969,11 +1949,12 @@ void DrawGlobalGrid(); public: - StgCanvas( StgWorld* world, int x, int y, int W,int H); + + StgCanvas( StgWorldGui* world, int x, int y, int W,int H); ~StgCanvas(); bool graphics; - StgWorld* world; + StgWorldGui* world; void FixViewport(int W,int H); //robot_camera = true @@ -2005,48 +1986,62 @@ }; - - /** Extends StgWorld to implements an FLTK / OpenGL graphical user interface. */ class StgWorldGui : public StgWorld, public Fl_Window { - friend class StgCanvas; - - private: - int wf_section; - StgCanvas* canvas; - Fl_Menu_Bar* mbar; - + friend class StgCanvas; + friend class StgModelCamera; + +private: + bool paused; ///< the world only updates when this is false + //int wf_section; + StgCanvas* canvas; + Fl_Menu_Bar* mbar; + stg_usec_t interval_log[INTERVAL_LOG_LEN]; + stg_usec_t real_time_of_last_update; + stg_usec_t interval_real; ///< real-time interval between updates - set this to zero for 'as fast as possible - public: - StgWorldGui(int W,int H,const char*L=0); - ~StgWorldGui(); +public: + static const stg_msec_t DEFAULT_INTERVAL_REAL = 100; ///< real time between updates + StgWorldGui(int W,int H,const char*L=0); + ~StgWorldGui(); + virtual bool Update(); - - virtual void Load( const char* filename ); - virtual void UnLoad(); - virtual bool Save( const char* filename ); + virtual void Load( const char* filename ); + virtual void UnLoad(); + virtual bool Save( const char* filename ); + + + void Start(){ paused = false; }; + void Stop(){ paused = true; }; + void TogglePause(){ paused = !paused; }; + + /** Get human readable string that describes the current simulation + time. */ + void ClockString( char* str, size_t maxlen ); + /** Set the minimum real time interval between world updates, in microeconds. */ void SetRealTimeInterval( stg_usec_t usec ) { interval_real = usec; } - - // static callback functions - static void LoadCallback( Fl_Widget* wid, StgWorldGui* world ); - static void SaveCallback( Fl_Widget* wid, StgWorldGui* world ); - static void SaveAsCallback( Fl_Widget* wid, StgWorldGui* world ); - static void QuitCallback( Fl_Widget* wid, StgWorldGui* world ); - static void About_cb( Fl_Widget* wid, StgWorldGui* world ); - static void HelpAboutCallback( Fl_Widget* wid ); - static void view_toggle_cb( Fl_Menu_Bar* menubar, StgCanvas* canvas ); - static void WindowCallback( Fl_Widget* wid, StgWorldGui* world ); - + + // static callback functions +protected: + static void LoadCallback( Fl_Widget* wid, StgWorldGui* world ); + static void SaveCallback( Fl_Widget* wid, StgWorldGui* world ); + static void SaveAsCallback( Fl_Widget* wid, StgWorldGui* world ); + static void QuitCallback( Fl_Widget* wid, StgWorldGui* world ); + static void About_cb( Fl_Widget* wid, StgWorldGui* world ); + static void HelpAboutCallback( Fl_Widget* wid ); + static void view_toggle_cb( Fl_Menu_Bar* menubar, StgCanvas* canvas ); + static void WindowCallback( Fl_Widget* wid, StgWorldGui* world ); + bool SaveAsDialog(); bool CloseWindowQuery(); Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstage/world.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -95,15 +95,13 @@ StgWorld::StgWorld( const char* token, stg_msec_t interval_sim, - stg_msec_t interval_real, double ppm ) { - Initialize( token, interval_sim, interval_real, ppm ); + Initialize( token, interval_sim, ppm ); } void StgWorld::Initialize( const char* token, stg_msec_t interval_sim, - stg_msec_t interval_real, double ppm ) { if( ! Stg::InitDone() ) @@ -130,11 +128,10 @@ this->models_by_name = g_hash_table_new( g_str_hash, g_str_equal ); this->sim_time = 0; this->interval_sim = (stg_usec_t)thousand * interval_sim; - this->interval_real = (stg_usec_t)thousand * interval_real; this->ppm = ppm; // this is the raytrace resolution this->real_time_start = RealTimeNow(); - this->real_time_next_update = 0; + //this->real_time_next_update = 0; this->update_list = NULL; this->velocity_list = NULL; @@ -143,7 +140,6 @@ (GEqualFunc)PointIntEqual ); this->total_subs = 0; - this->paused = false; this->destroy = false; // store a global table of all blocks, so they can be rendered all @@ -152,8 +148,6 @@ bzero( &this->extent, sizeof(this->extent)); - for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ ) - this->interval_log[i] = this->interval_real; this->real_time_now = 0; } @@ -179,53 +173,7 @@ g_hash_table_remove( models_by_name, mod ); } -void StgWorld::ClockString( char* str, size_t maxlen ) -{ - const uint32_t usec_per_hour = 360000000; - const uint32_t usec_per_minute = 60000000; - const uint32_t usec_per_second = 1000000; - const uint32_t usec_per_msec = 1000; - uint32_t hours = sim_time / usec_per_hour; - uint32_t minutes = (sim_time % usec_per_hour) / usec_per_minute; - uint32_t seconds = (sim_time % usec_per_minute) / usec_per_second; - uint32_t msec = (sim_time % usec_per_second) / usec_per_msec; - - // find the average length of the last few realtime intervals; - stg_usec_t average_real_interval = 0; - for( uint32_t i=0; i<INTERVAL_LOG_LEN; i++ ) - average_real_interval += interval_log[i]; - average_real_interval /= INTERVAL_LOG_LEN; - - double localratio = (double)interval_sim / (double)average_real_interval; - -#ifdef DEBUG - if( hours > 0 ) - snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.6f]\tsubs: %d %s", - hours, minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.6f]\tsubs: %d %s", - minutes, seconds, msec, - localratio, - total_subs, - paused ? "--PAUSED--" : "" ); -#else - if( hours > 0 ) - snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.2f] %s", - hours, minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); - else - snprintf( str, maxlen, "%02um%02u.%03us\t[%.2f] %s", - minutes, seconds, msec, - localratio, - paused ? "--PAUSED--" : "" ); -#endif -} - // wrapper to startup all models from the hash table void init_models( gpointer dummy1, StgModel* mod, gpointer dummy2 ) { @@ -266,9 +214,6 @@ this->token = (char*) wf->ReadString( entity, "name", token ); - this->interval_real = (stg_usec_t)thousand * - wf->ReadInt( entity, "interval_real", this->interval_real/thousand ); - this->interval_sim = (stg_usec_t)thousand * wf->ReadInt( entity, "interval_sim", this->interval_sim/thousand ); @@ -280,9 +225,6 @@ this->ppm = 1.0 / wf->ReadFloat( entity, "resolution", 1.0 / this->ppm ); - this->paused = - wf->ReadInt( entity, "paused", this->paused ); - //_stg_disable_gui = wf->ReadInt( entity, "gui_disable", _stg_disable_gui ); // Iterate through entitys and create client-side models @@ -414,32 +356,24 @@ bool StgWorld::Update() { - PRINT_DEBUG( "StgWorld::Update()" ); + PRINT_DEBUG( "StgWorld::Update()" ); + + // update any models that are due to be updated + for( GList* it=this->update_list; it; it=it->next ) + ((StgModel*)it->data)->UpdateIfDue(); + + // update any models with non-zero velocity + for( GList* it=this->velocity_list; it; it=it->next ) + ((StgModel*)it->data)->UpdatePose(); - if( paused ) - return false; - - // update any models that are due to be updated - for( GList* it=this->update_list; it; it=it->next ) - ((StgModel*)it->data)->UpdateIfDue(); - - // update any models with non-zero velocity - for( GList* it=this->velocity_list; it; it=it->next ) - ((StgModel*)it->data)->UpdatePose(); - - this->sim_time += this->interval_sim; - this->updates++; - - // if we've run long enough, set the quit flag - if( (quit_time > 0) && (sim_time >= quit_time) ) - quit = true; - - stg_usec_t timenow = RealTimeSinceStart(); - - interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_now; - real_time_now = timenow; - - return true; + this->sim_time += this->interval_sim; + this->updates++; + + // if we've run long enough, set the quit flag + if( (quit_time > 0) && (sim_time >= quit_time) ) + quit = true; + + return true; } void StgWorld::AddModel( StgModel* mod ) Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -134,7 +134,13 @@ //size_range( 100,100 ); // set minimum window size graphics = true; + paused = false; + interval_real = (stg_usec_t)thousand * DEFAULT_INTERVAL_REAL; + + for( unsigned int i=0; i<INTERVAL_LOG_LEN; i++ ) + this->interval_log[i] = this->interval_real; + // build the menus mbar = new Fl_Menu_Bar(0,0, W, 30);// 640, 30); mbar->textsize(12); @@ -191,16 +197,73 @@ delete canvas; } + +void StgWorldGui::ClockString( char* str, size_t maxlen ) +{ + const uint32_t usec_per_hour = 360000000; + const uint32_t usec_per_minute = 60000000; + const uint32_t usec_per_second = 1000000; + const uint32_t usec_per_msec = 1000; + + uint32_t hours = sim_time / usec_per_hour; + uint32_t minutes = (sim_time % usec_per_hour) / usec_per_minute; + uint32_t seconds = (sim_time % usec_per_minute) / usec_per_second; + uint32_t msec = (sim_time % usec_per_second) / usec_per_msec; + + // find the average length of the last few realtime intervals; + stg_usec_t average_real_interval = 0; + for( uint32_t i=0; i<INTERVAL_LOG_LEN; i++ ) + average_real_interval += interval_log[i]; + average_real_interval /= INTERVAL_LOG_LEN; + + double localratio = (double)interval_sim / (double)average_real_interval; + +#ifdef DEBUG + if( hours > 0 ) + snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.6f]\tsubs: %d %s", + hours, minutes, seconds, msec, + localratio, + total_subs, + paused ? "--PAUSED--" : "" ); + else + snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.6f]\tsubs: %d %s", + minutes, seconds, msec, + localratio, + total_subs, + paused ? "--PAUSED--" : "" ); +#else + if( hours > 0 ) + snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.2f] %s", + hours, minutes, seconds, msec, + localratio, + paused ? "--PAUSED--" : "" ); + else + snprintf( str, maxlen, "%02um%02u.%03us\t[%.2f] %s", + minutes, seconds, msec, + localratio, + paused ? "--PAUSED--" : "" ); +#endif +} + + void StgWorldGui::Load( const char* filename ) { PRINT_DEBUG1( "%s.Load()", token ); StgWorld::Load( filename ); - wf_section = wf->LookupEntity( "window" ); - if( wf_section < 1) // no section defined - return; +// wf_section = wf->LookupEntity( "window" ); +// if( wf_section < 1) // no section defined +// return; + + int wf_section = 0; // root section + this->paused = + wf->ReadInt( wf_section, "paused", this->paused ); + + this->interval_real = (stg_usec_t)thousand * + wf->ReadInt( wf_section, "interval_real", this->interval_real/thousand ); + int width = (int)wf->ReadTupleFloat(wf_section, "size", 0, w() ); int height = (int)wf->ReadTupleFloat(wf_section, "size", 1, h() ); // on OS X this behaves badly - prevents the Window manager resizing @@ -486,6 +549,8 @@ { PRINT_DEBUG1( "%s.Save()", token ); + int wf_section = 0; + wf->WriteTupleFloat( wf_section, "size", 0, w() ); wf->WriteTupleFloat( wf_section, "size", 1, h() ); @@ -516,10 +581,9 @@ { if( real_time_of_last_update == 0 ) real_time_of_last_update = RealTimeNow(); + + bool val = paused ? true : StgWorld::Update(); - bool val = StgWorld::Update(); - - stg_usec_t interval; stg_usec_t timenow; @@ -540,6 +604,12 @@ real_time_of_last_update = timenow; + //stg_usec_t timenow = RealTimeSinceStart(); + + interval_log[updates%INTERVAL_LOG_LEN] = interval_real;//timenow - real_time_now; + // real_time_now = timenow; + + return val; } Modified: code/stage/trunk/libstageplugin/CMakeLists.txt =================================================================== --- code/stage/trunk/libstageplugin/CMakeLists.txt 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/CMakeLists.txt 2008-06-17 07:40:18 UTC (rev 6617) @@ -1,6 +1,7 @@ link_directories( ${PLAYER_LIBDIR} ) include_directories( ${PLAYER_INCLUDE_DIRS}) +message( PLAYER INCLUDE ${PLAYER_INCLUDE_DIRS} ) add_library( stageplugin MODULE p_driver.cc Modified: code/stage/trunk/libstageplugin/p_driver.cc =================================================================== --- code/stage/trunk/libstageplugin/p_driver.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_driver.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -225,10 +225,10 @@ } InterfaceModel::InterfaceModel( player_devaddr_t addr, - StgDriver* driver, - ConfigFile* cf, - int section, - char* typestr ) + StgDriver* driver, + ConfigFile* cf, + int section, + stg_model_type_t type ) : Interface( addr, driver, cf, section ) { char* model_name = (char*)cf->ReadString(section, "model", NULL ); @@ -246,7 +246,7 @@ // find a model of the right type this->mod = driver->LocateModel( model_name, &addr, - typestr ); + type ); if( !this->mod ) { @@ -407,30 +407,30 @@ StgModel* StgDriver::LocateModel( char* basename, player_devaddr_t* addr, - char* typestr ) + stg_model_type_t type ) { - printf( "attempting to find a model under model \"%s\" of type [%s]\n", - basename, typestr ); + printf( "attempting to find a model under model \"%s\" of type [%d]\n", + basename, type ); StgModel* base_model = world->GetModel( basename ); if( base_model == NULL ) { PRINT_ERR1( " Error! can't find a Stage model named \"%s\"", - basename ); + basename ); return NULL; } - if( typestr == NULL ) // if we don't care what type the model is + if( type == MODEL_TYPE_PLAIN ) // if we don't care what type the model is return base_model; - + // printf( "found base model %s\n", base_model->Token() ); - + // we find the first model in the tree that is the right // type (i.e. has the right initialization function) and has not // been used before //return( model_match( base_model, addr, typestr, this->devices ) ); - return( base_model->GetUnsubscribedModelOfType( typestr ) ); + return( base_model->GetUnsubscribedModelOfType( type ) ); } //////////////////////////////////////////////////////////////////////////////// @@ -511,7 +511,7 @@ // Shutdown the device int StgDriver::Shutdown() { - puts("Shutting stage driver down"); + //puts("Shutting stage driver down"); // Stop and join the driver thread // this->StopThread(); // todo - the thread only runs in the sim instance @@ -523,7 +523,7 @@ // stg_model_unsubscribe( device->mod ); // } - puts("stage driver has been shutdown"); + puts("Stage driver has been shutdown"); return(0); } Modified: code/stage/trunk/libstageplugin/p_driver.h =================================================================== --- code/stage/trunk/libstageplugin/p_driver.h 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_driver.h 2008-06-17 07:40:18 UTC (rev 6617) @@ -45,7 +45,7 @@ StgModel* LocateModel( char* basename, player_devaddr_t* addr, - char* typestr); + stg_model_type_t type ); protected: @@ -100,7 +100,7 @@ StgDriver* driver, ConfigFile* cf, int section, - char* typestr ); + stg_model_type_t type ); StgModel* mod; Modified: code/stage/trunk/libstageplugin/p_graphics3d.cc =================================================================== --- code/stage/trunk/libstageplugin/p_graphics3d.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_graphics3d.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -58,7 +58,7 @@ StgDriver* driver, ConfigFile* cf, int section ) - : InterfaceModel( addr, driver, cf, section, NULL ) + : InterfaceModel( addr, driver, cf, section, MODEL_TYPE_PLAIN ) { // data members commands = NULL; Modified: code/stage/trunk/libstageplugin/p_laser.cc =================================================================== --- code/stage/trunk/libstageplugin/p_laser.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_laser.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -44,7 +44,7 @@ StgDriver* driver, ConfigFile* cf, int section ) - : InterfaceModel( addr, driver, cf, section, "laser" ) + : InterfaceModel( addr, driver, cf, section, MODEL_TYPE_LASER ) { this->scan_id = 0; } Modified: code/stage/trunk/libstageplugin/p_position.cc =================================================================== --- code/stage/trunk/libstageplugin/p_position.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_position.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -51,7 +51,7 @@ ConfigFile* cf, int section ) - : InterfaceModel( addr, driver, cf, section, "position" ) + : InterfaceModel( addr, driver, cf, section, MODEL_TYPE_POSITION ) { //puts( "InterfacePosition constructor" ); } Modified: code/stage/trunk/libstageplugin/p_sonar.cc =================================================================== --- code/stage/trunk/libstageplugin/p_sonar.cc 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/libstageplugin/p_sonar.cc 2008-06-17 07:40:18 UTC (rev 6617) @@ -46,7 +46,7 @@ StgDriver* driver, ConfigFile* cf, int section ) - : InterfaceModel( id, driver, cf, section, "ranger" ) + : InterfaceModel( id, driver, cf, section, MODEL_TYPE_RANGER ) { //this->data_len = sizeof(player_sonar_data_t); //this->cmd_len = 0; Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/worlds/fasr.world 2008-06-17 07:40:18 UTC (rev 6617) @@ -19,16 +19,13 @@ paused 1 # configure the GUI window -window -( - #size [ 698.000 628.000 ] - center [6.990 -4.040] - rotate [ 0.000 0.000 ] - scale 33.306 - show_data 0 - #interval 10 -) +size [ 698.000 628.000 ] +center [6.990 -4.040] +rotate [ 0.000 0.000 ] +scale 33.306 +show_data 0 + # load an environment bitmap floorplan ( Modified: code/stage/trunk/worlds/simple.world =================================================================== --- code/stage/trunk/worlds/simple.world 2008-06-17 03:43:58 UTC (rev 6616) +++ code/stage/trunk/worlds/simple.world 2008-06-17 07:40:18 UTC (rev 6617) @@ -20,23 +20,21 @@ paused 0 # configure the GUI window -window +size [ 745.000 448.000 ] +center [-7.010 5.960] +rotate [ 0.920 -0.430 ] +scale 28.806 + + +# load an environment bitmap +floorplan ( - size [ 745.000 448.000 ] - center [-7.010 5.960] - rotate [ 0.920 -0.430 ] - scale 28.806 + name "cave" + size3 [16 16 1.5] + pose [0.000 0.000 0.000] + bitmap "bitmaps/cave.png" ) -# load an environment bitmap -#floorplan -#( -# name "cave" -# size3 [16 16 0.5] -# pose [0.000 0.000 0.000] -# bitmap "bitmaps/cave.png" -#) - define autorob fancypioneer2dx ( color "red" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jeremy_asher@us...> - 2008-06-17 13:32:38
|
Revision: 6626 http://playerstage.svn.sourceforge.net/playerstage/?rev=6626&view=rev Author: jeremy_asher Date: 2008-06-17 13:32:31 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Fixed Player version checking Modified Paths: -------------- code/stage/trunk/CMakeLists.txt code/stage/trunk/libstageplugin/CMakeLists.txt Modified: code/stage/trunk/CMakeLists.txt =================================================================== --- code/stage/trunk/CMakeLists.txt 2008-06-17 19:25:03 UTC (rev 6625) +++ code/stage/trunk/CMakeLists.txt 2008-06-17 20:32:31 UTC (rev 6626) @@ -8,7 +8,7 @@ SET( APIVERSION ${V_MAJOR}.${V_MINOR} ) # minimum version of Player to build the plugin -SET( MIN_PLAYER 2.2.0 ) # change once plugin is fixed +SET( MIN_PLAYER 2.1.0 ) cmake_minimum_required( VERSION 2.4 FATAL_ERROR ) @@ -30,7 +30,25 @@ pkg_search_module( GLIB REQUIRED glib-2.0 ) find_package( OpenGL REQUIRED ) -pkg_search_module( PLAYER playercore ) +# Look for player v${MIN_PLAYER} or higher and set flags +# built-ins don't work properly, so use pkg-config directly +FIND_PROGRAM (PKGCONFIG NAMES pkg-config) +IF (PKGCONFIG) + EXECUTE_PROCESS (COMMAND pkg-config --atleast-version=${MIN_PLAYER} playercore --silence-errors + RESULT_VARIABLE PLAYER_NOT_FOUND) + IF (PLAYER_NOT_FOUND EQUAL 0) + # found the correct version + pkg_search_module( PLAYER playercore ) + MESSAGE(STATUS " Player headers found in ${PLAYER_INCLUDE_DIRS}") + MESSAGE(STATUS " Player libs found in ${PLAYER_LIBRARY_DIRS}") + SET (PLAYER_FOUND TRUE) + ELSE (PLAYER_NOT_FOUND EQUAL 0) + MESSAGE(STATUS "Player >=v${MIN_PLAYER} not found, skipping Player plugin") + SET (PLAYER_FOUND FALSE) + ENDIF (PLAYER_NOT_FOUND EQUAL 0) +ELSE (PKGCONFIG) + MESSAGE (STATUS "pkg-config not found, skipping Player plugin") +ENDIF (PKGCONFIG) # find FLTK and set flags @@ -79,12 +97,11 @@ # work through these subdirs ADD_SUBDIRECTORY(libstage) ADD_SUBDIRECTORY(examples) +IF ( PLAYER_FOUND ) + ADD_SUBDIRECTORY(libstageplugin) +ENDIF ( PLAYER_FOUND ) -if( PLAYER_FOUND ) -ADD_SUBDIRECTORY(libstageplugin) -endif( PLAYER_FOUND ) - INSTALL(FILES rgb.txt stagelogo.png DESTINATION share/stage ) Modified: code/stage/trunk/libstageplugin/CMakeLists.txt =================================================================== --- code/stage/trunk/libstageplugin/CMakeLists.txt 2008-06-17 19:25:03 UTC (rev 6625) +++ code/stage/trunk/libstageplugin/CMakeLists.txt 2008-06-17 20:32:31 UTC (rev 6626) @@ -1,7 +1,6 @@ link_directories( ${PLAYER_LIBDIR} ) include_directories( ${PLAYER_INCLUDE_DIRS}) -message( PLAYER INCLUDE ${PLAYER_INCLUDE_DIRS} ) add_library( stageplugin MODULE p_driver.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rtv@us...> - 2008-06-17 19:44:24
|
Revision: 6637 http://playerstage.svn.sourceforge.net/playerstage/?rev=6637&view=rev Author: rtv Date: 2008-06-17 19:44:30 -0700 (Tue, 17 Jun 2008) Log Message: ----------- replaced world grid with checkered texture Modified Paths: -------------- code/stage/trunk/docsrc/stage.dox code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model_laser.cc code/stage/trunk/libstage/test.cc code/stage/trunk/libstage/worldgui.cc code/stage/trunk/worlds/fasr.world Added Paths: ----------- code/stage/trunk/worlds/bitmaps/cave_compact.png Modified: code/stage/trunk/docsrc/stage.dox =================================================================== --- code/stage/trunk/docsrc/stage.dox 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/docsrc/stage.dox 2008-06-18 02:44:30 UTC (rev 6637) @@ -229,7 +229,7 @@ # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. @@ -257,7 +257,7 @@ # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = YES +HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/libstage/canvas.cc 2008-06-18 02:44:30 UTC (rev 6637) @@ -11,6 +11,12 @@ using namespace Stg; +static const int checkImageWidth = 2; +static const int checkImageHeight = 2; +static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; +static GLuint texName; +static bool canvas_init_done = false; + void StgCanvas::TimerCallback( StgCanvas* c ) { c->redraw(); @@ -25,6 +31,7 @@ : Fl_Gl_Window(x,y,w,h) { end(); + //show(); // must do this so that the GL context is created before configuring GL // but that line causes a segfault in Linux/X11! TODO: test in OS X @@ -375,13 +382,87 @@ { glLoadIdentity(); glViewport(0,0,W,H); + + if( ! canvas_init_done ) // do a bit of texture setup + { + canvas_init_done = true; + int i, j, c; + for (i = 0; i < checkImageHeight; i++) + for (j = 0; j < checkImageWidth; j++) + { + int even = (i+j)%2; + checkImage[i][j][0] = (GLubyte) 255 - 10*even; + checkImage[i][j][1] = (GLubyte) 255 - 10*even; + checkImage[i][j][2] = (GLubyte) 255;// - 5*even; + checkImage[i][j][3] = 255; + } + + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &texName); + glBindTexture(GL_TEXTURE_2D, texName); + glEnable(GL_TEXTURE_2D); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, + 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + } } + void StgCanvas::DrawGlobalGrid() { - PushColor( 0,0,0,0.2 ); - gl_draw_grid( world->GetExtent() ); + + + stg_bounds3d_t bounds = world->GetExtent(); + + char str[16]; + PushColor( 0,0,0,0.15 ); + for( double i = floor(bounds.x.min); i < bounds.x.max; i++) + { + snprintf( str, 16, "%d", (int)i ); + gl_draw_string( i, 0, 0.00, str ); + } + + for( double i = floor(bounds.y.min); i < bounds.y.max; i++) + { + snprintf( str, 16, "%d", (int)i ); + gl_draw_string( 0, i, 0.00, str ); + } PopColor(); + + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(2.0, 2.0); + glDisable(GL_BLEND); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, texName); + + glBegin(GL_QUADS); + + glTexCoord2f( bounds.x.min/2.0, bounds.y.min/2.0 ); + glVertex3f( bounds.x.min, bounds.y.min, 0 ); + glTexCoord2f( bounds.x.max/2.0, bounds.y.min/2.0); + glVertex3f( bounds.x.max, bounds.y.min, 0 ); + glTexCoord2f( bounds.x.max/2.0, bounds.y.max/2.0 ); + glVertex3f( bounds.x.max, bounds.y.max, 0 ); + glTexCoord2f( bounds.x.min/2.0, bounds.y.max/2.0 ); + glVertex3f( bounds.x.min, bounds.y.max, 0 ); + + glEnd(); + + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + + glDisable(GL_POLYGON_OFFSET_FILL ); } void StgCanvas::renderFrame( bool robot_camera ) @@ -393,42 +474,28 @@ if( ! (showflags & STG_SHOW_TRAILS) || robot_camera == true ) glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glPushMatrix(); + if( showflags & STG_SHOW_GRID && robot_camera == false ) + DrawGlobalGrid(); - // draw the world size rectangle in white, using the polygon offset - // so it doesn't z-fight with the models - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(2.0, 2.0); - - glScalef( 1.0/world->Resolution(), 1.0/world->Resolution(), 0 ); - ((StgWorldGui*)world)->DrawFloor(); - - glDisable(GL_POLYGON_OFFSET_FILL); - if( (showflags & STG_SHOW_QUADTREE) || (showflags & STG_SHOW_OCCUPANCY) && robot_camera == false ) { - glDisable( GL_LINE_SMOOTH ); - glLineWidth( 1 ); - glPolygonMode( GL_FRONT, GL_LINE ); - colorstack.Push(1,0,0); - - if( showflags & STG_SHOW_OCCUPANCY ) - ((StgWorldGui*)world)->DrawTree( false ); - - if( showflags & STG_SHOW_QUADTREE ) - ((StgWorldGui*)world)->DrawTree( true ); - - colorstack.Pop(); - - glEnable( GL_LINE_SMOOTH ); + glPushMatrix(); + glScalef( 1.0/world->Resolution(), 1.0/world->Resolution(), 0 ); + + glLineWidth( 1 ); + glPolygonMode( GL_FRONT, GL_LINE ); + colorstack.Push(1,0,0); + + if( showflags & STG_SHOW_OCCUPANCY ) + ((StgWorldGui*)world)->DrawTree( false ); + + if( showflags & STG_SHOW_QUADTREE ) + ((StgWorldGui*)world)->DrawTree( true ); + + colorstack.Pop(); + glPopMatrix(); } - - glPopMatrix(); - - if( showflags & STG_SHOW_GRID && robot_camera == false ) - DrawGlobalGrid(); - + for( GList* it=selected_models; it; it=it->next ) ((StgModel*)it->data)->DrawSelected(); Modified: code/stage/trunk/libstage/model_laser.cc =================================================================== --- code/stage/trunk/libstage/model_laser.cc 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/libstage/model_laser.cc 2008-06-18 02:44:30 UTC (rev 6637) @@ -79,9 +79,9 @@ { PRINT_DEBUG2( "Constructing StgModelLaser %d (%s)\n", id, typestr ); - + // sensible laser defaults - interval = 1e3 * StgModelLaser::DEFAULT_INTERVAL_MS; + interval = StgModelLaser::DEFAULT_INTERVAL_MS * thousand; laser_return = LaserVisible; stg_geom_t geom; @@ -168,23 +168,23 @@ samples = g_renew( stg_laser_sample_t, samples, sample_count ); - stg_pose_t rayorg; + stg_pose_t rayorg = geom.pose; bzero( &rayorg, sizeof(rayorg)); - rayorg.z = geom.size.z/2; + rayorg.z += geom.size.z/2; for( unsigned int t=0; t<sample_count; t += resolution ) { stg_raytrace_sample_t sample; - rayorg.a = pose.a + bearing; + rayorg.a = bearing; Raytrace( rayorg, - range_max, - laser_raytrace_match, - NULL, - &sample, - true ); // z testing enabled - + range_max, + laser_raytrace_match, + NULL, + &sample, + true ); // z testing enabled + samples[t].range = sample.range; // if we hit a model and it reflects brightly, we set Modified: code/stage/trunk/libstage/test.cc =================================================================== --- code/stage/trunk/libstage/test.cc 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/libstage/test.cc 2008-06-18 02:44:30 UTC (rev 6637) @@ -38,7 +38,7 @@ StgWorldGui world( 400,400, "Test" ); - world.SetRealTimeInterval( 20000 ); + world.SetRealTimeInterval( 10000 ); world.Start(); @@ -46,6 +46,7 @@ stg_geom_t geom; bzero( &geom, sizeof(geom) ); + if( 0 ) { StgModel mod( &world, NULL ); @@ -135,49 +136,76 @@ } // mod goes out of scope - #define POP 100 - + #define POP 10 + stg_velocity_t v = {0,0,0,0}; + StgModel* m[POP]; for( int i=0; i<POP; i++ ) { - m[i] = new StgModel( &world, NULL ); + m[i] = new StgModelLaser( &world, NULL ); //m[i]->Say( "Hello" ); - m[i]->SetGeom( geom ); - m[i]->SetPose( random_pose( -10,10, -10,10 ) ); - //m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); + m[i]->Subscribe(); + //m[i]->SetGeom( geom ); + + //m[i]->SetPose( random_pose( -5,5, -5,5 ) ); + m[i]->PlaceInFreeSpace( 0, 10, 0, 10 ); m[i]->SetColor( lrand48() | 0xFF000000 ); - interact( &world ); + + v.x = drand48() / 10.0; + v.y = drand48() / 10.0; + v.z = drand48() / 10.0; + v.a = drand48() / 3.0; + + m[i]->SetVelocity( v ); } - - geom.size.x = 0.2; - geom.size.y = 0.2; - geom.size.z = 0.2; - for( int i=0; i<POP; i++ ) - { - StgModel* top = new StgModel( &world, m[i] ); - top->SetGeom( geom ); - //top->SetPose( new_pose( 0,0,0,0 ) ); - //m[i]->SetPose( random_pose( -10,10, -10,10 ) ); - //m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); - top->SetColor( lrand48() | 0xFF000000 ); + + // stg_pose_t o = { 1, 2, 0, 0 }; +// stg_pose_t p = {0,0,0,0}; + +// m[0]->SetPose( o ); + +// stg_pose_t q = m[0]->LocalToGlobal( p ); + +// stg_print_pose( &o ); +// stg_print_pose( &q ); + +// assert( fabs( q.x - o.x ) < 0.0001 ); +// assert( fabs( q.y - o.y ) < 0.0001 ); +// assert( fabs( q.z - o.z ) < 0.0001 ); +// assert( fabs( q.a - o.a ) < 0.0001 ); + +// m[1]->SetPose( new_pose( 0,0,0,0 )); + + // geom.size.x = 0.2; + //geom.size.y = 0.2; + //geom.size.z = 0.2; + +// for( int i=0; i<POP; i++ ) +// { +// StgModel* top = new StgModel( &world, m[i] ); +// top->SetGeom( geom ); +// //top->SetPose( new_pose( 0,0,0,0 ) ); +// //m[i]->SetPose( random_pose( -10,10, -10,10 ) ); +// //m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); +// top->SetColor( lrand48() | 0xFF000000 ); - //interact( &world ); - } +// //interact( &world ); +// } - for( int i=0; i<POP; i++ ) - { -// m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); - //m[i]->SetColor( 0xFF00FF00 ); + // for( int i=0; i<POP; i++ ) +// { +// // m[i]->PlaceInFreeSpace( -10, 10, -10, 10 ); +// //m[i]->SetColor( 0xFF00FF00 ); - stg_velocity_t v = {0,0,0,1}; +// stg_velocity_t v = {0,0,0,0.1}; - m[i]->SetVelocity( v ); +// m[i]->SetVelocity( v ); - //interact( &world ); - } +// //interact( &world ); +// } // for( int i=0; i<POP; i++ ) // { Modified: code/stage/trunk/libstage/worldgui.cc =================================================================== --- code/stage/trunk/libstage/worldgui.cc 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/libstage/worldgui.cc 2008-06-18 02:44:30 UTC (rev 6637) @@ -257,47 +257,52 @@ fileMan.newWorld( filename ); StgWorld::Load( filename ); - -// wf_section = wf->LookupEntity( "window" ); -// if( wf_section < 1) // no section defined -// return; - int wf_section = 0; // root section + int world_section = 0; // use the top-level section for some parms + // that traditionally live there this->paused = - wf->ReadInt( wf_section, "paused", this->paused ); + wf->ReadInt( world_section, "paused", this->paused ); this->interval_real = (stg_usec_t)thousand * - wf->ReadInt( wf_section, "interval_real", (int)(this->interval_real/thousand) ); + wf->ReadInt( world_section, "interval_real", (int)(this->interval_real/thousand) ); - int width = (int)wf->ReadTupleFloat(wf_section, "size", 0, w() ); - int height = (int)wf->ReadTupleFloat(wf_section, "size", 1, h() ); + + // use the window section for the rest + int window_section = wf->LookupEntity( "window" ); + + if( window_section < 1) // no section defined + return; + + + int width = (int)wf->ReadTupleFloat(window_section, "size", 0, w() ); + int height = (int)wf->ReadTupleFloat(window_section, "size", 1, h() ); // on OS X this behaves badly - prevents the Window manager resizing //larger than this size. size( width,height ); - float x = wf->ReadTupleFloat(wf_section, "center", 0, 0 ); - float y = wf->ReadTupleFloat(wf_section, "center", 1, 0 ); + float x = wf->ReadTupleFloat(window_section, "center", 0, 0 ); + float y = wf->ReadTupleFloat(window_section, "center", 1, 0 ); canvas->camera.setPose( x, y ); - canvas->camera.setPitch( wf->ReadTupleFloat( wf_section, "rotate", 0, 0 ) ); - canvas->camera.setYaw( wf->ReadTupleFloat( wf_section, "rotate", 1, 0 ) ); - canvas->camera.setScale( wf->ReadFloat(wf_section, "scale", canvas->camera.getScale() ) ); - canvas->interval = wf->ReadInt(wf_section, "interval", canvas->interval ); + canvas->camera.setPitch( wf->ReadTupleFloat( window_section, "rotate", 0, 0 ) ); + canvas->camera.setYaw( wf->ReadTupleFloat( window_section, "rotate", 1, 0 ) ); + canvas->camera.setScale( wf->ReadFloat(window_section, "scale", canvas->camera.getScale() ) ); + canvas->interval = wf->ReadInt(window_section, "interval", canvas->interval ); // set the canvas visibilty flags uint32_t flags = canvas->GetShowFlags(); - uint32_t grid = wf->ReadInt(wf_section, "show_grid", flags & STG_SHOW_GRID ) ? STG_SHOW_GRID : 0; - uint32_t data = wf->ReadInt(wf_section, "show_data", flags & STG_SHOW_DATA ) ? STG_SHOW_DATA : 0; - uint32_t follow = wf->ReadInt(wf_section, "show_follow", flags & STG_SHOW_FOLLOW ) ? STG_SHOW_FOLLOW : 0; - uint32_t blocks = wf->ReadInt(wf_section, "show_blocks", flags & STG_SHOW_BLOCKS ) ? STG_SHOW_BLOCKS : 0; - uint32_t quadtree = wf->ReadInt(wf_section, "show_tree", flags & STG_SHOW_QUADTREE ) ? STG_SHOW_QUADTREE : 0; - uint32_t clock = wf->ReadInt(wf_section, "show_clock", flags & STG_SHOW_CLOCK ) ? STG_SHOW_CLOCK : 0; - uint32_t trails = wf->ReadInt(wf_section, "show_trails", flags & STG_SHOW_TRAILS ) ? STG_SHOW_TRAILS : 0; - uint32_t trailsrising = wf->ReadInt(wf_section, "show_trails_rising", flags & STG_SHOW_TRAILRISE ) ? STG_SHOW_TRAILRISE : 0; - uint32_t arrows = wf->ReadInt(wf_section, "show_arrows", flags & STG_SHOW_ARROWS ) ? STG_SHOW_ARROWS : 0; - uint32_t footprints = wf->ReadInt(wf_section, "show_footprints", flags & STG_SHOW_FOOTPRINT ) ? STG_SHOW_FOOTPRINT : 0; - uint32_t status = wf->ReadInt(wf_section, "show_status", flags & STG_SHOW_STATUS ) ? STG_SHOW_STATUS : 0; + uint32_t grid = wf->ReadInt(window_section, "show_grid", flags & STG_SHOW_GRID ) ? STG_SHOW_GRID : 0; + uint32_t data = wf->ReadInt(window_section, "show_data", flags & STG_SHOW_DATA ) ? STG_SHOW_DATA : 0; + uint32_t follow = wf->ReadInt(window_section, "show_follow", flags & STG_SHOW_FOLLOW ) ? STG_SHOW_FOLLOW : 0; + uint32_t blocks = wf->ReadInt(window_section, "show_blocks", flags & STG_SHOW_BLOCKS ) ? STG_SHOW_BLOCKS : 0; + uint32_t quadtree = wf->ReadInt(window_section, "show_tree", flags & STG_SHOW_QUADTREE ) ? STG_SHOW_QUADTREE : 0; + uint32_t clock = wf->ReadInt(window_section, "show_clock", flags & STG_SHOW_CLOCK ) ? STG_SHOW_CLOCK : 0; + uint32_t trails = wf->ReadInt(window_section, "show_trails", flags & STG_SHOW_TRAILS ) ? STG_SHOW_TRAILS : 0; + uint32_t trailsrising = wf->ReadInt(window_section, "show_trails_rising", flags & STG_SHOW_TRAILRISE ) ? STG_SHOW_TRAILRISE : 0; + uint32_t arrows = wf->ReadInt(window_section, "show_arrows", flags & STG_SHOW_ARROWS ) ? STG_SHOW_ARROWS : 0; + uint32_t footprints = wf->ReadInt(window_section, "show_footprints", flags & STG_SHOW_FOOTPRINT ) ? STG_SHOW_FOOTPRINT : 0; + uint32_t status = wf->ReadInt(window_section, "show_status", flags & STG_SHOW_STATUS ) ? STG_SHOW_STATUS : 0; canvas->SetShowFlags( grid | data | follow | blocks | quadtree | clock | trails | arrows | footprints | trailsrising | status ); @@ -560,31 +565,35 @@ { PRINT_DEBUG1( "%s.Save()", token ); - int wf_section = 0; - - wf->WriteTupleFloat( wf_section, "size", 0, w() ); - wf->WriteTupleFloat( wf_section, "size", 1, h() ); - - wf->WriteFloat( wf_section, "scale", canvas->camera.getScale() ); + StgWorld::Save( filename ); - wf->WriteTupleFloat( wf_section, "center", 0, canvas->camera.getX() ); - wf->WriteTupleFloat( wf_section, "center", 1, canvas->camera.getY() ); - - wf->WriteTupleFloat( wf_section, "rotate", 0, canvas->camera.getPitch() ); - wf->WriteTupleFloat( wf_section, "rotate", 1, canvas->camera.getYaw() ); + // use the window section for the rest + int window_section = wf->LookupEntity( "window" ); - uint32_t flags = canvas->GetShowFlags(); - wf->WriteInt( wf_section, "show_blocks", flags & STG_SHOW_BLOCKS ); - wf->WriteInt( wf_section, "show_grid", flags & STG_SHOW_GRID ); - wf->WriteInt( wf_section, "show_follow", flags & STG_SHOW_FOLLOW ); - wf->WriteInt( wf_section, "show_data", flags & STG_SHOW_DATA ); - wf->WriteInt( wf_section, "show_occupancy", flags & STG_SHOW_OCCUPANCY ); - wf->WriteInt( wf_section, "show_tree", flags & STG_SHOW_QUADTREE ); - wf->WriteInt( wf_section, "show_clock", flags & STG_SHOW_CLOCK ); + if( window_section > 0 ) // section defined + { + wf->WriteTupleFloat( window_section, "size", 0, w() ); + wf->WriteTupleFloat( window_section, "size", 1, h() ); + + wf->WriteFloat( window_section, "scale", canvas->camera.getScale() ); + + wf->WriteTupleFloat( window_section, "center", 0, canvas->camera.getX() ); + wf->WriteTupleFloat( window_section, "center", 1, canvas->camera.getY() ); + + wf->WriteTupleFloat( window_section, "rotate", 0, canvas->camera.getPitch() ); + wf->WriteTupleFloat( window_section, "rotate", 1, canvas->camera.getYaw() ); + + uint32_t flags = canvas->GetShowFlags(); + wf->WriteInt( window_section, "show_blocks", flags & STG_SHOW_BLOCKS ); + wf->WriteInt( window_section, "show_grid", flags & STG_SHOW_GRID ); + wf->WriteInt( window_section, "show_follow", flags & STG_SHOW_FOLLOW ); + wf->WriteInt( window_section, "show_data", flags & STG_SHOW_DATA ); + wf->WriteInt( window_section, "show_occupancy", flags & STG_SHOW_OCCUPANCY ); + wf->WriteInt( window_section, "show_tree", flags & STG_SHOW_QUADTREE ); + wf->WriteInt( window_section, "show_clock", flags & STG_SHOW_CLOCK ); - // TODO - per model visualizations save - - return StgWorld::Save( filename ); + // TODO - per model visualizations save + } } @@ -595,7 +604,6 @@ bool val = paused ? true : StgWorld::Update(); - stg_usec_t interval; stg_usec_t timenow; @@ -614,11 +622,10 @@ } while( interval < interval_real ); + interval_log[updates%INTERVAL_LOG_LEN] = timenow - real_time_of_last_update; + real_time_of_last_update = timenow; - - interval_log[updates%INTERVAL_LOG_LEN] = interval_real;//timenow - real_time_now; - return val; } Added: code/stage/trunk/worlds/bitmaps/cave_compact.png =================================================================== (Binary files differ) Property changes on: code/stage/trunk/worlds/bitmaps/cave_compact.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: code/stage/trunk/worlds/fasr.world =================================================================== --- code/stage/trunk/worlds/fasr.world 2008-06-18 02:18:00 UTC (rev 6636) +++ code/stage/trunk/worlds/fasr.world 2008-06-18 02:44:30 UTC (rev 6637) @@ -1,5 +1,5 @@ # FASR demo world -# Authors: Richard Vaughan +# Authors: Richard Vaughanwo # $Id: fasr.world,v 1.4 2008-04-01 23:57:41 rtv Exp $ # defines Pioneer-like robots @@ -15,17 +15,19 @@ resolution 0.02 interval_sim 100 # simulation timestep in milliseconds -interval_real 20 # real-time interval between simulation updates in milliseconds +interval_real 0 # real-time interval between simulation updates in milliseconds paused 1 # configure the GUI window -size [ 698.000 628.000 ] -center [6.990 -4.040] -rotate [ 0.000 0.000 ] -scale 33.306 -show_data 0 +window +( + # size [ 698.000 628.000 ] + center [6.990 -4.040] + rotate [ 0.000 0.000 ] + scale 33.306 + show_data 0 +) - # load an environment bitmap floorplan ( @@ -55,11 +57,10 @@ ( color "red" - sicklaser( pose [ 0.040 0.000 0.000 ] samples 32 range_max 5 laser_return 2 ) + sicklaser( pose [ 0.040 0.000 0.000 ] samples 30 range_max 5 laser_return 2 ) + ctrl "fasr" - ctrl "fasr" - - say "Autolab" + # say "Autolab" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |