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.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit