Permalink
Browse files

replaced some c-strings with std::strings

  • Loading branch information...
rtv
rtv committed Sep 26, 2009
1 parent f41586a commit 996c281279c4396bc3c3de0d81fc0cc41e5b807b
View
@@ -31,7 +31,6 @@ SET (PROJECT_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake CACHE PATH "Location of CMake
# Determine the operating system in detail
INCLUDE (${PROJECT_CMAKE_DIR}/internal/FindOS.cmake)
-
# Enable -Wall by default unless on Win or Solaris
IF (NOT PROJECT_OS_WIN AND NOT PROJECT_OS_SOLARIS)
# Using -Wall on Windows causes MSVC to produce thousands of warnings in its
View
@@ -9,8 +9,9 @@ become more portable.
Dependencies
------------
-Building Stage requires the following libraries:
+Building Stage requires the following tools and libraries:
+- pkg-config
- FLTK 1.1.x
- OpenGL
- libpng
View
@@ -1,3 +1,25 @@
+Version 3.2.0
+-------------
+
+This minor release fixes many bugs, has some performance improvements
+and some significant internal and API changes, including:
+
+* introduced an internal event queue, so that there is no longer any
+ atomic world update interval. Each model can have its update
+ interval specified individually
+* worldfile syntax checking improved: poses and sizes are checked for
+ correct vector length
+* pkg-config file for libstage now contains correct dependencies,
+ making it much easier to build things using libstage
+* controllers can now take an argument string from the worldfile and
+ command line
+* better powerpack model
+* cleaned up namespace quite a bit - controllers and simulators using
+ libstage may need some simple tweaks, but the design is cleaner and
+ more consistent.
+
+Richard Vaughan (rtv) vaughan@sfu.ca - 2009.9.12
+
Version 3.1.0
-------------
@@ -1,14 +1,13 @@
SET( PLUGINS
- # convoy
fasr
- # fasr2
lasernoise
sink
source
wander
+ wander_pioneer
pioneer_flocking
-# rasterize
+ rasterize
)
# need plaer's wavefront planning library for this one
View
@@ -493,7 +493,7 @@ class Robot
};
// Stage calls this when the model starts up
-extern "C" int Init( Model* mod, char* str )
+extern "C" int Init( Model* mod, CtrlArgs* args )
{
#if 1
// example using the model rasterizer
@@ -46,13 +46,13 @@ extern "C" int Init( Model* mod )
robot->position = (ModelPosition*)mod;
// subscribe to the ranger, which we use for navigating
- robot->ranger = (ModelRanger*)mod->GetModel( "ranger:0" );
+ robot->ranger = (ModelRanger*)mod->GetUnusedModelOfType( "ranger" );
assert( robot->ranger );
// ask Stage to call into our ranger update function
robot->ranger->AddUpdateCallback( (stg_model_callback_t)RangerUpdate, robot );
- robot->fiducial = (ModelFiducial*)mod->GetModel( "fiducial:0" ) ;
+ robot->fiducial = (ModelFiducial*)mod->GetUnusedModelOfType( "fiducial" ) ;
assert( robot->fiducial );
robot->fiducial->AddUpdateCallback( (stg_model_callback_t)FiducialUpdate, robot );
View
@@ -35,13 +35,12 @@ extern "C" int Init( Model* mod, CtrlArgs* args )
robot->randcount = 0;
robot->pos = (ModelPosition*)mod;
- robot->laser = (ModelLaser*)mod->GetModel( "laser:0" );
+ robot->laser = (ModelLaser*)mod->GetChild( "laser:0" );
robot->laser->AddUpdateCallback( (stg_model_callback_t)LaserUpdate, robot );
robot->laser->Subscribe(); // starts the laser updates
robot->pos->Subscribe(); // starts the position updates
-
-
+
return 0; //ok
}
@@ -47,12 +47,12 @@ extern "C" int Init( Model* mod )
robot->position = (ModelPosition*)mod;
assert( robot->ranger );
- robot->ranger = (ModelRanger*)mod->GetModel( "ranger:0" );
+ robot->ranger = (ModelRanger*)mod->GetUnusedModelOfType( "ranger" );
assert( robot->ranger );
// ask Stage to call into our ranger update function whenever the ranger is updated
robot->ranger->AddUpdateCallback( (stg_model_callback_t)RangerUpdate, robot );
- robot->fiducial = (ModelFiducial*)mod->GetModel( "fiducial:0" ) ;
+ robot->fiducial = (ModelFiducial*)mod->GetUnusedModelOfType( "fiducial" ) ;
assert( robot->fiducial );
// ask Stage to call into our fiducial update function whenever the fiducial is updated
robot->fiducial->AddUpdateCallback( (stg_model_callback_t)FiducialUpdate, robot );
View
@@ -4,7 +4,6 @@ MESSAGE( STATUS "Configuring libstage" )
include_directories(${PROJECT_BINARY_DIR})
set( stageSrcs
- ancestor.cc
block.cc
blockgroup.cc
camera.cc
@@ -18,31 +17,32 @@ set( stageSrcs
model_blinkenlight.cc
model_blobfinder.cc
model_callbacks.cc
- model_draw.cc
model_camera.cc
+ model_draw.cc
model_fiducial.cc
model_getset.cc
model_gripper.cc
model_laser.cc
+ model_lightindicator.cc
model_load.cc
model_position.cc
model_props.cc
model_ranger.cc
- model_lightindicator.cc
option.cc
powerpack.cc
region.cc
stage.cc
stage.hh
texture_manager.cc
typetable.cc
- vis_strip.cc
world.cc
worldfile.cc
- worldgui.cc
canvas.cc
options_dlg.cc
options_dlg.hh
+ vis_strip.cc
+ worldgui.cc
+ ancestor.cc
)
set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" )
View
@@ -1,11 +1,13 @@
+#include <sstream> // for converting values to strings
+
#include "stage.hh"
using namespace Stg;
-//using names
+
Ancestor::Ancestor() :
children(),
debug( false ),
- token( NULL ),
+ token(),
access_mutex(),
child_type_counts()
{
@@ -29,31 +31,23 @@ void Ancestor::AddChild( Model* mod )
}
// poke a name into the child
- static char* buf = new char[TOKEN_MAX]; // allocated once
+ std::ostringstream name;
// printf( "adding child of type %d token %s\n", mod->type, mod->Token() );
- std::string typestr = mod->type;
-
- if( token ) // if this object has a name, use it
- snprintf( buf, TOKEN_MAX, "%s.%s:%d",
- token,
- typestr.c_str(),
- child_type_counts[mod->type] );
- else
- snprintf( buf, TOKEN_MAX, "%s:%d",
- typestr.c_str(),
- child_type_counts[mod->type] );
-
- //printf( "%s generated a name for my child %s\n", token, buf );
-
- mod->SetToken( buf );
-
+ // if this object has a name, use it
+ if( token.size() )
+ name << this->token << '.';
+
+ name << mod->type << ':' << child_type_counts[mod->type];
+
+ // printf( "%s generated a name for my child %s\n", Token(), name.str().c_str() );
+
+ mod->SetToken( name.str() );
+
children.push_back( mod );
-
- child_type_counts[mod->type]++;
-
- //delete[] buf; // no need to free the statically allocated buffer
+
+ child_type_counts[mod->type]++;
}
void Ancestor::RemoveChild( Model* mod )
View
@@ -43,7 +43,7 @@ Block::Block( Model* mod,
mpts(),
pt_count(0),
pts(),
- color(0),
+ color(),
inherit_color(true),
rendered_cells( new CellPtrVec ),
candidate_cells( new CellPtrVec )
@@ -408,39 +408,6 @@ void Block::DrawFootPrint()
glEnd();
}
-void Block::Draw( Model* mod )
-{
- // draw filled color polygons
- Color col = inherit_color ? mod->color : color;
-
- col.Print( "block color" );
-
- mod->PushColor( col );
- 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
- mod->PushColor( Color( col.r/2.0, col.g/2.0, col.b/2.0, col.a ));
-
- glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
- glDepthMask(GL_FALSE);
- DrawTop();
- DrawSides();
- glDepthMask(GL_TRUE);
- glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-
- if( glow > 0.0 )
- {
-
- }
-
- mod->PopColor();
- mod->PopColor();
-}
-
void Block::DrawSolid()
{
DrawSides();
@@ -468,8 +435,8 @@ void Block::Load( Worldfile* wf, int entity )
local_z.min = wf->ReadTupleLength( entity, "z", 0, 0.0 );
local_z.max = wf->ReadTupleLength( entity, "z", 1, 1.0 );
- const char* colorstr = wf->ReadString( entity, "color", NULL );
- if( colorstr )
+ const std::string& colorstr = wf->ReadString( entity, "color", "" );
+ if( colorstr != "" )
{
color = Color( colorstr );
inherit_color = false;
View
@@ -248,19 +248,19 @@ void BlockGroup::LoadBlock( Model* mod, Worldfile* wf, int entity )
AppendBlock( new Block( mod, wf, entity ));
}
-void BlockGroup::LoadBitmap( Model* mod, const char* bitmapfile, Worldfile* wf )
+void BlockGroup::LoadBitmap( Model* mod, const std::string& bitmapfile, Worldfile* wf )
{
PRINT_DEBUG1( "attempting to load bitmap \"%s\n", bitmapfile );
char full[_POSIX_PATH_MAX];
if( bitmapfile[0] == '/' )
- strcpy( full, bitmapfile );
+ strncpy( full, bitmapfile.c_str(), _POSIX_PATH_MAX );
else
{
char *tmp = strdup(wf->filename.c_str());
snprintf( full, _POSIX_PATH_MAX,
- "%s/%s", dirname(tmp), bitmapfile );
+ "%s/%s", dirname(tmp), bitmapfile.c_str() );
free(tmp);
}
View
@@ -66,7 +66,7 @@ Canvas::Canvas( WorldGui* world,
starty( -1 ),
selected_models(),
last_selection( NULL ),
- interval( 20 ), // msec between redraws
+ interval( 40 ), // msec between redraws
// initialize Option objects
// showBlinken( "Blinkenlights", "show_blinkenlights", "", true, world ),
showBBoxes( "Debug/Bounding boxes", "show_boundingboxes", "^b", false, world ),
View
@@ -21,13 +21,10 @@ bool Color::operator!=( const Color& other )
fabs(a-other.a) > epsilon );
}
-Color::Color( const char *name) :
+Color::Color( const std::string& name) :
r(1), g(0), b(0), a(1)
{
- if( name == NULL ) // no string?
- return; // red
-
- if( strcmp( name, "" ) == 0 ) // empty string?
+ if( name == "" ) // empty string?
return; // red
static FILE *file = NULL;
Oops, something went wrong.

0 comments on commit 996c281

Please sign in to comment.