Update of /cvsroot/playerstage/code/stage/libstage
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19428/libstage
Modified Files:
Tag: opengl
Makefile.manual blockgrid.cc model.cc model_laser.cc
model_load.cc model_position.cc stage.hh stest.cc typetable.cc
world.cc worldgtk.cc
Log Message:
raytracing is now really nice and fast. still chasing bugs. implemented
configurable window redraw frequency
Index: stest.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stest.cc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** stest.cc 30 Oct 2007 07:30:01 -0000 1.1.2.10
--- stest.cc 31 Oct 2007 03:55:11 -0000 1.1.2.11
***************
*** 26,29 ****
--- 26,31 ----
int obs = FALSE;
+ int POPSIZE = 50;
+
int main( int argc, char* argv[] )
{
***************
*** 45,95 ****
//StgModel mod2( &world, NULL, 0, "model" );
! stg_pose_t pz;
! pz.x = 5;
! pz.y = 0;
! pz.z = 0;
! pz.a = 4;//M_PI/2.0;
//mod.SetPose( &pz );
! pz.y = 3;
// mod2.SetPose( &pz );
//for( int i=0; i<10; i++ )
//mod.AddBlockRect( i/2, 0, 0.3, 0.3 );
!
//char* robotname = argv[2];
!
! // // generate the name of the laser attached to the robot
//char lasername[64];
//snprintf( lasername, 63, "%s.laser:0", robotname );
- // // generate the name of the sonar attached to the robot
- // char rangername[64];
- // snprintf( rangername, 63, "%s.ranger:0", robotname );
-
- //StgModelPosition* position = (StgModelPosition*)world.GetModel(
"MyWorld:0.model:1" );
- //assert(position);
! char namebuf[256];
! StgModelLaser* lasers[200];
! for( int i=1; i<10; i++ )
{
! sprintf( namebuf, "MyWorld:0.model:%d.laser:0", i );
lasers[i] = (StgModelLaser*)world.GetModel( namebuf );
assert(lasers[i]);
lasers[i]->Subscribe();
}
!
// StgModelRanger* ranger = (StgModelRanger*)world.GetModel( rangername );
// assert(ranger);
// // subscribe to the laser - starts it collecting data
- // position->Subscribe();
! // ranger->Subscribe();
! //position->Print( "Subscribed to model" );
! //laser->Print( "Subscribed to model" );
//ranger->Print( "Subscribed to model" );
--- 47,109 ----
//StgModel mod2( &world, NULL, 0, "model" );
! //stg_pose_t pz;
! // pz.x = 5;
! //pz.y = 0;
! //pz.z = 0;
! //pz.a = 4;//M_PI/2.0;
//mod.SetPose( &pz );
! //pz.y = 3;
// mod2.SetPose( &pz );
//for( int i=0; i<10; i++ )
//mod.AddBlockRect( i/2, 0, 0.3, 0.3 );
!
//char* robotname = argv[2];
!
! // // generate the name of the laser attached to the robot
//char lasername[64];
//snprintf( lasername, 63, "%s.laser:0", robotname );
+
+ // // generate the name of the sonar attached to the robot
+ // char rangername[64];
+ // snprintf( rangername, 63, "%s.ranger:0", robotname );
+
+ char namebuf[256];
+
! //StgModelPosition* position = (StgModelPosition*)world.GetModel(
"MyWorld:0.position:0" );
! //assert(position);
!
! //StgModelLaser* laser =
(StgModelLaser*)world.GetModel("MyWorld:0.position:0.laser:0" );
! //assert( laser );
!
! StgModelPosition* positions[POPSIZE];
! StgModelLaser* lasers[POPSIZE];
! for( int i=0; i<POPSIZE; i++ )
{
! sprintf( namebuf, "MyWorld:0.position:%d", i+1 );
! positions[i] = (StgModelPosition*)world.GetModel( namebuf );
! assert(positions[i]);
! positions[i]->Subscribe();
!
! sprintf( namebuf, "MyWorld:0.position:%d.laser:0", i+1 );
lasers[i] = (StgModelLaser*)world.GetModel( namebuf );
assert(lasers[i]);
lasers[i]->Subscribe();
}
!
// StgModelRanger* ranger = (StgModelRanger*)world.GetModel( rangername );
// assert(ranger);
// // subscribe to the laser - starts it collecting data
! //position->Subscribe();
! //laser->Subscribe();
! //position->Print( "Subscribed to model" );
! //laser->Print( "Subscribed to model" );
//ranger->Print( "Subscribed to model" );
***************
*** 104,189 ****
//stg_world_set_interval_real( world, 0 );
! while( world.RealTimeUpdate() )
! {
! // nothing
! }
!
! #ifdef GOBOO
//while( ! laser->DataIsFresh() )
//if( ! world.RealTimeUpdate() )
//break;
!
! // get some laser data
! size_t laser_sample_count = laser->sample_count;
! stg_laser_sample_t* laserdata = laser->samples;
! if( laserdata == NULL )
! continue;
! // THIS IS ADAPTED FROM PLAYER'S RANDOMWALK C++ EXAMPLE
! /* See if there is an obstacle in front */
! obs = FALSE;
! for( unsigned int i = 0; i < laser_sample_count; i++)
! {
! if(laserdata[i].range < minfrontdistance)
! obs = TRUE;
! }
! if(obs || avoidcount )
! {
! newspeed = 0;
!
! /* once we start avoiding, continue avoiding for 2 seconds */
! /* (we run at about 10Hz, so 20 loop iterations is about 2 sec) */
! if(!avoidcount)
{
! avoidcount = 15;
! randcount = 0;
! // find the minimum on the left and right
! double min_left = 1e9;
! double min_right = 1e9;
! for( unsigned int i=0; i<laser_sample_count; i++ )
! {
! if(i>(laser_sample_count/2) && laserdata[i].range < min_left)
! min_left = laserdata[i].range;
! else if(i<(laser_sample_count/2) && laserdata[i].range <
min_right)
! min_right = laserdata[i].range;
! }
! if( min_left < min_right)
! newturnrate = -turnrate;
! else
! newturnrate = turnrate;
! }
!
! avoidcount--;
! }
! else
! {
! avoidcount = 0;
! newspeed = speed;
! /* update turnrate every 3 seconds */
! if(!randcount)
{
! /* make random int tween -20 and 20 */
! randint = rand() % 41 - 20;
! newturnrate = DTOR(randint);
! randcount = 50;
}
- randcount--;
- }
! //position->Do( newspeed, 0, newturnrate );
}
! #endif
exit( 0 );
--- 118,208 ----
//stg_world_set_interval_real( world, 0 );
! // StgModelLaser* laser = lasers[1];
+ //while( world.RealTimeUpdate() )
+ while( world.Update() )
+ {
+ // nothing
//while( ! laser->DataIsFresh() )
//if( ! world.RealTimeUpdate() )
//break;
!
! for( int i=0; i<POPSIZE; i++ )
! {
! StgModelPosition* position = positions[i];
! StgModelLaser* laser = lasers[i];
!
! // get some laser data
! size_t laser_sample_count = laser->sample_count;
! stg_laser_sample_t* laserdata = laser->samples;
! if( laserdata == NULL )
! continue;
! // THIS IS ADAPTED FROM PLAYER'S RANDOMWALK C++ EXAMPLE
! /* See if there is an obstacle in front */
! obs = FALSE;
! for( unsigned int i = 0; i < laser_sample_count; i++)
! {
! if(laserdata[i].range < minfrontdistance)
! obs = TRUE;
! }
! if(obs || avoidcount )
{
! newspeed = 0;
!
! /* once we start avoiding, continue avoiding for 2 seconds */
! /* (we run at about 10Hz, so 20 loop iterations is about 2 sec) */
! if(!avoidcount)
! {
! avoidcount = 15;
! randcount = 0;
! // find the minimum on the left and right
! double min_left = 1e9;
! double min_right = 1e9;
! for( unsigned int i=0; i<laser_sample_count; i++ )
! {
! if(i>(laser_sample_count/2) && laserdata[i].range <
min_left)
! min_left = laserdata[i].range;
! else if(i<(laser_sample_count/2) && laserdata[i].range <
min_right)
! min_right = laserdata[i].range;
! }
! if( min_left < min_right)
! newturnrate = -turnrate;
! else
! newturnrate = turnrate;
! }
! avoidcount--;
! }
! else
{
! avoidcount = 0;
! newspeed = speed;
!
! /* update turnrate every 3 seconds */
! if(!randcount)
! {
! /* make random int tween -20 and 20 */
! randint = rand() % 41 - 20;
! newturnrate = DTOR(randint);
! randcount = 50;
! }
! randcount--;
}
! position->Do( newspeed, 0, newturnrate );
! }
}
! //#endif
exit( 0 );
Index: model_laser.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_laser.cc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** model_laser.cc 30 Oct 2007 01:22:44 -0000 1.1.2.7
--- model_laser.cc 31 Oct 2007 03:55:11 -0000 1.1.2.8
***************
*** 293,304 ****
printf( "\tRanges[ " );
! for( unsigned int i=0; i<sample_count; i++ )
! printf( "%.2f ", samples[i].range );
puts( " ]" );
printf( "\tReflectance[ " );
! for( unsigned int i=0; i<sample_count; i++ )
! printf( "%.2f ", samples[i].reflectance );
puts( " ]" );
}
--- 293,311 ----
printf( "\tRanges[ " );
! if( samples )
! for( unsigned int i=0; i<sample_count; i++ )
! printf( "%.2f ", samples[i].range );
! else
! printf( "<none until subscribed>" );
puts( " ]" );
printf( "\tReflectance[ " );
! if( samples )
! for( unsigned int i=0; i<sample_count; i++ )
! printf( "%.2f ", samples[i].reflectance );
! else
! printf( "<none until subscribed>" );
!
puts( " ]" );
}
Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model.cc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** model.cc 30 Oct 2007 04:20:45 -0000 1.1.2.9
--- model.cc 31 Oct 2007 03:55:11 -0000 1.1.2.10
***************
*** 116,120 ****
//#define DEBUG
-
#include "stage.hh"
--- 116,119 ----
***************
*** 918,923 ****
void StgModel::SetPose( stg_pose_t* pose )
{
! PRINT_DEBUG5( "%s.SetPose(%.2f %.2f %.2f %.2f)",
! this->token, pose->x, pose->y, pose->z, pose->a );
assert(pose);
--- 917,922 ----
void StgModel::SetPose( stg_pose_t* pose )
{
! //PRINT_DEBUG5( "%s.SetPose(%.2f %.2f %.2f %.2f)",
! // this->token, pose->x, pose->y, pose->z, pose->a );
assert(pose);
Index: blockgrid.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/blockgrid.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** blockgrid.cc 30 Oct 2007 07:30:01 -0000 1.1.2.3
--- blockgrid.cc 31 Oct 2007 03:55:11 -0000 1.1.2.4
***************
*** 1,5 ****
#include "stage.hh"
! static const uint32_t NBITS = 5;
static const uint32_t NSIZE = 1<<NBITS;
static const uint32_t NSQR = NSIZE*NSIZE;
--- 1,5 ----
#include "stage.hh"
! static const uint32_t NBITS = 6;
static const uint32_t NSIZE = 1<<NBITS;
static const uint32_t NSQR = NSIZE*NSIZE;
***************
*** 77,99 ****
}
-
- GSList* StgBlockGrid::GetList( uint32_t x, uint32_t y )
- {
- if( x < width && y < height )
- {
- uint32_t a = x>>NBITS;
- uint32_t b = y>>NBITS;
-
- stg_bigblock_t* bb = &map[ a + b*bwidth ];
-
- if( bb->lists )
- {
- uint32_t index = (x&MASK) + (y&MASK)*NSIZE;
- return bb->lists[index];
- }
- }
- return NULL;
- }
-
void StgBlockGrid::RemoveBlock( uint32_t x, uint32_t y, StgBlock* block )
{
--- 77,80 ----
***************
*** 113,116 ****
--- 94,98 ----
bb->lists[index] = g_slist_remove( bb->lists[index], block );
+ assert( bb->counter > 0 );
bb->counter--;
***************
*** 121,127 ****
bb->lists = NULL;
}
! assert( bb->counter >=0 );
}
}
--- 103,134 ----
bb->lists = NULL;
}
+ }
+ }
! // uint32_t StgBlockGrid::BigBlockOccupancy( uint32_t bbx, uint32_t bby )
! // {
! // //glRecti( bbx<<NBITS, bby<<NBITS,(bbx+1)<<NBITS,(bby+1)<<NBITS );
! // return map[ bbx + bby*bwidth].counter;
! // }
!
! GSList* StgBlockGrid::GetList( uint32_t x, uint32_t y )
! {
! if( x < width && y < height )
! {
! uint32_t a = x>>NBITS;
! uint32_t b = y>>NBITS;
!
! stg_bigblock_t* bb = &map[ a + b*bwidth ];
!
! if( bb->lists )
! {
! //glRecti( x,y,x+1,y+1 );
!
! assert( bb->counter > 0 );
! uint32_t index = (x&MASK) + (y&MASK)*NSIZE;
! return bb->lists[index];
! }
}
+ return NULL;
}
Index: world.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/world.cc,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** world.cc 30 Oct 2007 04:20:45 -0000 1.1.2.11
--- world.cc 31 Oct 2007 03:55:11 -0000 1.1.2.12
***************
*** 56,60 ****
#include <locale.h>
! #define DEBUG
#include "stage.hh"
--- 56,60 ----
#include <locale.h>
! //#define DEBUG
#include "stage.hh"
***************
*** 408,411 ****
--- 408,415 ----
}
+ void StgWorld::AddModelName( StgModel* mod )
+ {
+ g_hash_table_insert( this->models_by_name, (gpointer)mod->Token(), mod );
+ }
// void stg_world_print( StgWorld* world )
***************
*** 432,490 ****
StgModel* StgWorld::GetModel( const stg_id_t id )
{
! //printf( "looking up model name %s in models_by_name\n", name );
return (StgModel*)g_hash_table_lookup( this->models_by_id, (gpointer)id );
}
! // int raytest( int x, int y, int z,
! // void* arg1, void* arg2 )
// {
! // glRecti( x,y, x+1,y+1 );
// return FALSE;
// }
! typedef struct
! {
! StgWorld* world;
! StgModel* finder;
! StgModel* hit;
! int32_t x, y, z; // leave point
! stg_block_match_func_t func;
! const void* arg;
! } _raytrace_info_t;
! int raytest( int32_t x, int32_t y, int32_t z,
! _raytrace_info_t* rti )
! {
! //glRecti( x,y, x+1,y+1 );
! // for each block recorded at his location
! for( GSList* list = rti->world->bgrid->GetList( x, y );
! list;
! list = list->next )
! {
! StgBlock* block = (StgBlock*)list->data;
! assert( block );
! // 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->mod != rti->finder) &&
! (*rti->func)( block, rti->arg ) )//&&
! //z >= block->zmin &&
! // z < block->zmax )
! {
! // a hit!
! rti->hit = block->mod;
! rti->x = x;
! rti->y = y;
! rti->z = z;
! return TRUE;
! }
! }
! return FALSE;
! }
stg_meters_t StgWorld::Raytrace( StgModel* finder,
stg_pose_t* pose,
--- 436,542 ----
StgModel* StgWorld::GetModel( const stg_id_t id )
{
! //printf( "looking up model id %d in models_by_id\n", id );
return (StgModel*)g_hash_table_lookup( this->models_by_id, (gpointer)id );
}
+ //#define NBITS 6
! // int bigtest( int x, int y, int z,
! // void* arg1, void* arg2 )
// {
! // glRecti( x<<NBITS,y<<NBITS, (x+1)<<NBITS,(y+1)<<NBITS );
// return FALSE;
// }
! // typedef struct
! // {
! // StgWorld* world;
! // StgModel* finder;
! // StgModel* hit;
! // int32_t x, y, z; // leave point
! // stg_block_match_func_t func;
! // const void* arg;
! // } _raytrace_info_t;
! // int raytest( int32_t x, int32_t y, int32_t z,
! // _raytrace_info_t* rti )
! // {
! // //glRecti( x,y, x+1,y+1 );
! // // for each block recorded at his location
! // for( GSList* list = rti->world->bgrid->GetList( x, y );
! // list;
! // list = list->next )
! // {
! // StgBlock* block = (StgBlock*)list->data;
! // assert( block );
! // // 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->mod != rti->finder) &&
! // (*rti->func)( block, rti->arg ) )//&&
! // //z >= block->zmin &&
! // // z < block->zmax )
! // {
! // // a hit!
! // rti->hit = block->mod;
! // rti->x = x;
! // rti->y = y;
! // rti->z = z;
! // return TRUE;
! // }
! // }
! // return FALSE;
! // }
+ // stg_meters_t StgWorld::Raytrace( StgModel* finder,
+ // stg_pose_t* pose,
+ // stg_meters_t max_range,
+ // stg_block_match_func_t func,
+ // const void* arg,
+ // StgModel** hit_model )
+ // {
+ // // find the global integer bitmap address of the ray
+ // int32_t x = (int32_t)((pose->x+width/2.0)*ppm);
+ // int32_t y = (int32_t)((pose->y+height/2.0)*ppm);
+
+ // // and the x and y offsets of the ray
+ // int32_t dx = (int32_t)(ppm*max_range * cos(pose->a));
+ // int32_t dy = (int32_t)(ppm*max_range * sin(pose->a));
+
+ // glPushMatrix();
+ // glTranslatef( -width/2.0, -height/2.0, 0 );
+ // glScalef( 1.0/ppm, 1.0/ppm, 0 );
+
+ // _raytrace_info_t rinfo;
+ // rinfo.world = this;
+ // rinfo.finder = finder;
+ // rinfo.func = func;
+ // rinfo.arg = arg;
+ // rinfo.hit = NULL;
+
+ // if( stg_line_3d( x, y, 0,
+ // dx, dy, 0,
+ // (stg_line3d_func_t)raytest,
+ // &rinfo ) )
+ // {
+ // glPopMatrix();
+
+ // *hit_model = rinfo.hit;
+
+ // // how far away was that strike?
+ // return hypot( (rinfo.x-x)/ppm, (rinfo.y-y)/ppm );
+ // }
+
+
+ // glPopMatrix();
+ // // return the range from ray start to object strike
+
+ // // hit nothing, so return max range
+ // return max_range;
+ // }
+
stg_meters_t StgWorld::Raytrace( StgModel* finder,
stg_pose_t* pose,
***************
*** 497,530 ****
int32_t x = (int32_t)((pose->x+width/2.0)*ppm);
int32_t y = (int32_t)((pose->y+height/2.0)*ppm);
!
// and the x and y offsets of the ray
int32_t dx = (int32_t)(ppm*max_range * cos(pose->a));
int32_t dy = (int32_t)(ppm*max_range * sin(pose->a));
!
! //glPushMatrix();
! //glTranslatef( -width/2.0, -height/2.0, 0 );
! //glScalef( 1.0/ppm, 1.0/ppm, 0 );
!
! _raytrace_info_t rinfo;
! rinfo.world = this;
! rinfo.finder = finder;
! rinfo.func = func;
! rinfo.arg = arg;
! rinfo.hit = NULL;
!
! if( stg_line_3d( x, y, 0,
! dx, dy, 0,
! (stg_line3d_func_t)raytest,
! &rinfo ) )
! {
! //glPopMatrix();
! *hit_model = rinfo.hit;
! // how far away was that strike?
! return hypot( (rinfo.x-x)/ppm, (rinfo.y-y)/ppm );
}
!
!
//glPopMatrix();
// return the range from ray start to object strike
--- 549,621 ----
int32_t x = (int32_t)((pose->x+width/2.0)*ppm);
int32_t y = (int32_t)((pose->y+height/2.0)*ppm);
! int32_t z = 0;
!
! int32_t xstart = x;
! int32_t ystart = y;
!
// and the x and y offsets of the ray
int32_t dx = (int32_t)(ppm*max_range * cos(pose->a));
int32_t dy = (int32_t)(ppm*max_range * sin(pose->a));
! int32_t dz = 0;
! // glPushMatrix();
! // glTranslatef( -width/2.0, -height/2.0, 0 );
! // glScalef( 1.0/ppm, 1.0/ppm, 0 );
!
! // line 3d algorithm adapted from Cohen's code from Graphics Gems IV
! int n, sx, sy, sz, exy, exz, ezy, ax, ay, az, bx, by, bz;
! sx = SGN(dx); sy = SGN(dy); sz = SGN(dz);
! ax = abs(dx); ay = abs(dy); az = abs(dz);
! bx = 2*ax; by = 2*ay; bz = 2*az;
! exy = ay-ax; exz = az-ax; ezy = ay-az;
! n = ax+ay+az;
! while ( n-- )
! {
! for( GSList* list = bgrid->GetList( x, y );
! list;
! list = list->next )
! {
! StgBlock* block = (StgBlock*)list->data;
! assert( block );
!
! // 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->mod != finder) &&
! (*func)( block, arg ) &&
! pose->z >= block->zmin &&
! pose->z < block->zmax )
! {
! // a hit!
! //glPopMatrix();
!
! *hit_model = block->mod;
! // how far away was that strike?
! return hypot( (x-xstart)/ppm, (y-ystart)/ppm );
! }
! }
!
! if ( exy < 0 ) {
! if ( exz < 0 ) {
! x += sx;
! exy += by; exz += bz;
! }
! else {
! z += sz;
! exz -= bx; ezy += by;
! }
! }
! else {
! if ( ezy < 0 ) {
! z += sz;
! exz -= bx; ezy += by;
! }
! else {
! y += sy;
! exy -= bx; ezy -= bz;
! }
! }
}
!
//glPopMatrix();
// return the range from ray start to object strike
***************
*** 534,538 ****
}
-
void stg_model_save_cb( gpointer key, gpointer data, gpointer user )
{
--- 625,628 ----
Index: model_load.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_load.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** model_load.cc 22 Oct 2007 02:36:33 -0000 1.1.2.2
--- model_load.cc 31 Oct 2007 03:55:11 -0000 1.1.2.3
***************
*** 24,30 ****
--- 24,34 ----
//printf( "changed %s to %s\n", this->token, token );
this->token = strdup( name );
+ world->AddModelName( this ); // add this name to the world's table
}
else
PRINT_ERR1( "Name blank for model %s. Check your worldfile\n",
this->token );
+
+ // add this name to the table
+
}
Index: typetable.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/typetable.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** typetable.cc 4 Oct 2007 07:43:21 -0000 1.1.2.2
--- typetable.cc 31 Oct 2007 03:55:11 -0000 1.1.2.3
***************
*** 8,11 ****
--- 8,12 ----
{ "model", StgModel::Create },
{ "laser", StgModelLaser::Create },
+ { "position", StgModelPosition::Create },
{ NULL, NULL } // this must be the last entry
};
Index: model_position.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_position.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** model_position.cc 4 Oct 2007 01:17:02 -0000 1.1.2.1
--- model_position.cc 31 Oct 2007 03:55:11 -0000 1.1.2.2
***************
*** 12,16 ****
///////////////////////////////////////////////////////////////////////////
- //#define DEBUG
#include <sys/time.h>
--- 12,15 ----
***************
*** 19,25 ****
//#define DEBUG
!
! #include "model.hh"
! #include "gui.h"
/**
--- 18,22 ----
//#define DEBUG
! #include "stage.hh"
/**
***************
*** 102,113 ****
! StgModelPosition::StgModelPosition( stg_world_t* world,
StgModel* parent,
stg_id_t id,
! CWorldFile* wf )
! : StgModel( world, parent, id, wf )
{
PRINT_DEBUG2( "Constructing StgModelPosition %d (%s)\n",
! id, wf->GetEntityType( id ) );
// TODO - move this to stg_init()
--- 99,110 ----
! StgModelPosition::StgModelPosition( StgWorld* world,
StgModel* parent,
stg_id_t id,
! char* typestr )
! : StgModel( world, parent, id, typestr )
{
PRINT_DEBUG2( "Constructing StgModelPosition %d (%s)\n",
! id, typestr );
// TODO - move this to stg_init()
***************
*** 166,169 ****
--- 163,168 ----
char* keyword = NULL;
+ CWorldFile* wf = world->wf;
+
// load steering mode
if( wf->PropertyExists( this->id, "drive" ) )
***************
*** 446,450 ****
{
// integrate our velocities to get an 'odometry' position estimate.
! double dt = this->world->sim_interval_ms/1e3;
est_pose.a = NORMALIZE( est_pose.a + (vel.a * dt) * (1.0
+integration_error.a) );
--- 445,449 ----
{
// integrate our velocities to get an 'odometry' position estimate.
! double dt = this->world->interval_sim/1e3;
est_pose.a = NORMALIZE( est_pose.a + (vel.a * dt) * (1.0
+integration_error.a) );
Index: Makefile.manual
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/Makefile.manual,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** Makefile.manual 30 Oct 2007 01:01:48 -0000 1.1.2.4
--- Makefile.manual 31 Oct 2007 03:55:11 -0000 1.1.2.5
***************
*** 18,21 ****
--- 18,22 ----
model_laser.o \
model_load.o \
+ model_position.o \
model_props.o \
stage.o \
Index: stage.hh
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stage.hh,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** stage.hh 30 Oct 2007 07:30:01 -0000 1.1.2.11
--- stage.hh 31 Oct 2007 03:55:11 -0000 1.1.2.12
***************
*** 1168,1172 ****
typedef struct
{
! uint16_t counter;
GSList** lists;
} stg_bigblock_t;
--- 1168,1172 ----
typedef struct
{
! uint32_t counter;
GSList** lists;
} stg_bigblock_t;
***************
*** 1188,1191 ****
--- 1188,1195 ----
void RemoveBlock( StgBlock* block );
void Draw( bool drawall );
+
+ /** Returns the number of blocks occupying the big block, specified
+ in big block coordinates, NOT in small blocks.*/
+ uint32_t BigBlockOccupancy( uint32_t bbx, uint32_t bby );
};
***************
*** 1283,1287 ****
void AddModel( StgModel* mod );
void RemoveModel( StgModel* mod );
!
void StartUpdatingModel( StgModel* mod );
void StopUpdatingModel( StgModel* mod );
--- 1287,1292 ----
void AddModel( StgModel* mod );
void RemoveModel( StgModel* mod );
! void AddModelName( StgModel* mod );
!
void StartUpdatingModel( StgModel* mod );
void StopUpdatingModel( StgModel* mod );
***************
*** 1866,1869 ****
--- 1871,1877 ----
private:
+ stg_msec_t redraw_interval;
+ guint timer_handle;
+
bool follow_selection;
***************
*** 2103,2110 ****
stg_laser_sample_t* samples;
! size_t sample_count;
stg_meters_t range_min, range_max;
stg_radians_t fov;
! unsigned int resolution;
virtual void Startup( void );
--- 2111,2118 ----
stg_laser_sample_t* samples;
! uint32_t sample_count;
stg_meters_t range_min, range_max;
stg_radians_t fov;
! uint32_t resolution;
virtual void Startup( void );
***************
*** 2419,2423 ****
[x,y,a] defines a 2D position and heading goal to achieve. */
void Do( double x, double y, double a )
! { goal.x = x; goal.y = y; goal.a = a; }
};
--- 2427,2442 ----
[x,y,a] defines a 2D position and heading goal to achieve. */
void Do( double x, double y, double a )
! { goal.x = x; goal.y = y; goal.a = a; }
!
! // 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 );
! }
!
};
Index: worldgtk.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldgtk.cc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** worldgtk.cc 30 Oct 2007 04:20:45 -0000 1.1.2.8
--- worldgtk.cc 31 Oct 2007 03:55:11 -0000 1.1.2.9
***************
*** 663,666 ****
--- 663,669 ----
stheta = 0.0;
+ this->timer_handle = 0;
+ this->redraw_interval = 100; //msec
+
// CREATE THE MENUS
ui_manager = gtk_ui_manager_new ();
***************
*** 736,739 ****
--- 739,750 ----
+ gboolean timed_redraw( StgWorldGtk* world )
+ {
+ //puts( "TIMED REDRAW" );
+ world->RenderClock();
+ world->Draw();
+ return TRUE;
+ }
+
/***
*** The "realize" signal handler. All the OpenGL initialization
***************
*** 814,817 ****
--- 825,832 ----
gdk_gl_drawable_gl_end (gldrawable);
+
+
+ // start a timer to redraw the window periodically
+ timer_handle = g_timeout_add( redraw_interval, (GSourceFunc)timed_redraw,
this );
}
***************
*** 1369,1383 ****
return;
- // remember the section for subsequent gui_save()s
-
- /* win->redraw_interval = */
- /* wf_read_int( section, "redraw_interval", win->redraw_interval ); */
- /* // cancel our old timeout callback */
- /* g_source_remove( win->timeout_id ); */
- /* // and install a new one with the (possibly) new interval */
- /* win->timeout_id = g_timeout_add( win->redraw_interval, timeout, world );
*/
-
- /* printf( "** REDRAW interval %d ms\n", win->redraw_interval ); */
-
panx = wf->ReadTupleFloat(wf_section, "center", 0, panx );
pany = wf->ReadTupleFloat(wf_section, "center", 1, pany );
--- 1384,1387 ----
***************
*** 1413,1416 ****
--- 1417,1432 ----
height = (int)wf->ReadTupleFloat(wf_section, "size", 1, height );
gtk_window_resize( GTK_WINDOW(frame), width, height );
+
+ if( wf->PropertyExists( wf_section, "redraw_interval" ) )
+ {
+ redraw_interval =
+ wf->ReadInt(wf_section, "redraw_interval", redraw_interval );
+
+ if( timer_handle > 0 )
+ g_source_remove( timer_handle );
+
+ timer_handle =
+ g_timeout_add( redraw_interval, (GSourceFunc)timed_redraw, this );
+ }
}
***************
*** 1658,1661 ****
--- 1674,1678 ----
}
+
bool StgWorldGtk::RealTimeUpdate()
***************
*** 1663,1693 ****
//PRINT_DEBUG( "StageWorldGtk::RealTimeUpdate()" );
! if( !paused )
! StgWorld::Update(); // ignore return value
! // handle GUI events and possibly sleep until it's time to update
! stg_msec_t timenow = 0;
! while( 1 )
! {
! RenderClock();
!
! //if( dirty )
! Draw();
! while( gtk_events_pending() )
! gtk_main_iteration();
- timenow = RealTimeSinceStart();
-
- //PRINT_DEBUG3( "timenow %lu real_time_next_update %lu diff %lu",
- // timenow, real_time_next_update, real_time_next_update -
timenow );
! if( timenow < real_time_next_update )
! usleep( 20 * 1e3 ); // sleep 20ms
! else
! break;
! }
!
! real_time_next_update = timenow + interval_real;
return !( quit || quit_all );
--- 1680,1696 ----
//PRINT_DEBUG( "StageWorldGtk::RealTimeUpdate()" );
! //StgWorld::Update(); // ignore return value
! this->Update();
! // // handle GUI events and possibly sleep until it's time to update
! // stg_msec_t timenow = 0;
! // while( 1 )
! // {
! // while( gtk_events_pending() )
! // gtk_main_iteration();
! PauseUntilNextUpdateTime();
return !( quit || quit_all );
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit