Permalink
Browse files

stderr vs stdout and robot poses on updates_max

  • Loading branch information...
1 parent 0ab4349 commit 232d6d630fc36df318432c73892f4f836a1deb75 @rtv committed Apr 2, 2013
Showing with 16 additions and 11 deletions.
  1. +16 −11 universe.cc
View
@@ -139,47 +139,47 @@ void Uni::Init( int argc, char** argv )
{
case 'p':
population_size = atoi( optarg );
- if( ! quiet ) printf( "[Uni] population_size: %d\n", population_size );
+ if( ! quiet ) fprintf( stderr, "[Uni] population_size: %d\n", population_size );
population.resize( population_size );
break;
case 's':
worldsize = atof( optarg );
- if( ! quiet ) printf( "[Uni] worldsize: %.2f\n", worldsize );
+ if( ! quiet ) fprintf( stderr, "[Uni] worldsize: %.2f\n", worldsize );
break;
case 'f':
Robot::fov = dtor(atof( optarg )); // degrees to radians
- if( ! quiet ) printf( "[Uni] fov: %.2f\n", Robot::fov );
+ if( ! quiet ) fprintf( stderr, "[Uni] fov: %.2f\n", Robot::fov );
break;
case 'r':
Robot::range = atof( optarg );
- if( ! quiet ) printf( "[Uni] range: %.2f\n", Robot::range );
+ if( ! quiet ) fprintf( stderr, "[Uni] range: %.2f\n", Robot::range );
break;
case 'c':
Robot::pixel_count = atoi( optarg );
- if( ! quiet ) printf( "[Uni] pixel_count: %d\n", Robot::pixel_count );
+ if( ! quiet ) fprintf( stderr, "[Uni] pixel_count: %d\n", Robot::pixel_count );
break;
case 'u':
updates_max = atol( optarg );
- if( ! quiet ) printf( "[Uni] updates_max: %lu\n", (long unsigned)updates_max );
+ if( ! quiet ) fprintf( stderr, "[Uni] updates_max: %lu\n", (long unsigned)updates_max );
break;
case 'z':
sleep_msec = atoi( optarg );
- if( ! quiet ) printf( "[Uni] sleep_msec: %d\n", sleep_msec );
+ if( ! quiet ) fprintf( stderr, "[Uni] sleep_msec: %d\n", sleep_msec );
break;
#if GRAPHICS
case 'w': winsize = atoi( optarg );
- if( ! quiet ) printf( "[Uni] winsize: %d\n", winsize );
+ if( ! quiet ) fprintf( stderr, "[Uni] winsize: %d\n", winsize );
break;
case 'd': show_data= false;
- if( ! quiet ) puts( "[Uni] hide data" );
+ if( ! quiet ) fprintf( stderr, "[Uni] hide data\n" );
break;
case 'q': quiet = true;
@@ -333,7 +333,12 @@ void Uni::UpdateAll()
{
// if we've done enough updates, exit the program
if( updates_max > 0 && updates > updates_max )
- exit(1);
+ {
+ FOR_EACH( it, population )
+ printf( "%.2f,%.2f,%.2f\n", it->pose[0], it->pose[1], it->pose[2] );
+
+ exit(1);
+ }
if( ! paused )
{
@@ -360,7 +365,7 @@ void Uni::UpdateAll()
gettimeofday( &now, NULL );
double seconds = now.tv_sec + now.tv_usec/1e6;
double interval = seconds - lastseconds;
- printf( "[%d] FPS %.3f\r",(int)updates, period/interval );
+ fprintf( stderr, "[%d] FPS %.3f\r",(int)updates, period/interval );
fflush(stdout);
lastseconds = seconds;
}

0 comments on commit 232d6d6

Please sign in to comment.