Revision: 7472
http://playerstage.svn.sourceforge.net/playerstage/?rev=7472&view=rev
Author: rtv
Date: 2009-03-13 07:28:32 +0000 (Fri, 13 Mar 2009)
Log Message:
-----------
first webstage demo
Modified Paths:
--------------
code/stage/trunk/CMakeLists.txt
code/stage/trunk/libstage/CMakeLists.txt
code/stage/trunk/libstage/main.cc
code/stage/trunk/worlds/fasr.world
Added Paths:
-----------
code/stage/trunk/webstage/
code/stage/trunk/webstage/CMakeLists.txt
code/stage/trunk/webstage/webstage.cc
code/stage/trunk/webstage/world.fed
Modified: code/stage/trunk/CMakeLists.txt
===================================================================
--- code/stage/trunk/CMakeLists.txt 2009-03-13 06:23:03 UTC (rev 7471)
+++ code/stage/trunk/CMakeLists.txt 2009-03-13 07:28:32 UTC (rev 7472)
@@ -14,8 +14,10 @@
OPTION (BUILD_LSPTEST "Build Player plugin tests" OFF)
OPTION (CPACK_CFG "[release building] generate CPack configuration files" OFF)
-OPTION (BUILD_GUI "WARNING: turning this off breaks the build right now. Build
FLTK-based GUI. If OFF, build a gui-less Stage useful e.g. for headless compute
clusters." ON )
+# todo
+# OPTION (BUILD_GUI "Build FLTK-based GUI. If OFF, build a gui-less Stage
useful e.g. for headless compute clusters." ON )
+
cmake_minimum_required( VERSION 2.4 FATAL_ERROR )
IF (CMAKE_MAJOR_VERSION EQUAL 2 AND NOT CMAKE_MINOR_VERSION LESS 6)
@@ -79,7 +81,7 @@
MESSAGE( STATUS "BUILD_GUI is ${BUILD_GUI}" )
-IF( BUILD_GUI )
+#IF( BUILD_GUI )
## the FLTK package script is not useful - it finds an X11-based FLTK on OS X.
## so we can't do this stuff
@@ -131,7 +133,7 @@
SET (FLTK_FOUND TRUE)
-ENDIF( BUILD_GUI )
+# ENDIF( BUILD_GUI )
#MESSAGE( ${INDENT} "Checking for OpenGL" )
find_package( OpenGL REQUIRED )
@@ -154,6 +156,14 @@
MESSAGE( ${INDENT} "Player not detected. If Player is installed but not
detected, check your PKG_CONFIG_PATH." )
ENDIF( PLAYER_FOUND )
+pkg_search_module( WEBSIM websim )
+IF( WEBSIM_FOUND )
+ MESSAGE( STATUS ${INDENT} "WebSim version ${WEBSIM_VERSION} detected at
${WEBSIM_PREFIX}" )
+ MESSAGE( STATUS " WEBSIM_CFLAGS = ${WEBSIM_CFLAGS}" )
+ MESSAGE( STATUS " WEBSIM_LDFLAGS = ${WEBSIM_LDFLAGS}" )
+ELSE( WEBSIM_FOUND )
+ MESSAGE( ${INDENT} "WebSim not detected." )
+ENDIF( WEBSIM_FOUND )
## this should not be necessary now that we do the FLTK config
## carefully above. I'll leave the code here in case of trouble
@@ -174,6 +184,7 @@
${GLIB_INCLUDE_DIRS}
${LIBPNG_INCLUDE_DIRS}
${CMAKE_INCLUDE_PATH}
+ ${WEBSIM_INCLUDE_DIRS}
)
@@ -181,6 +192,7 @@
link_directories(${GLIB_LIBRARY_DIRS}
${GLIB_LIBRARY_DIRS}
${LIBPNG_LIBRARY_DIRS}
+ ${WEBSIM_LIBRARY_DIRS}
)
# work through these subdirs
@@ -189,6 +201,10 @@
ADD_SUBDIRECTORY(assets)
ADD_SUBDIRECTORY(worlds)
+if( WEBSIM_FOUND )
+ADD_SUBDIRECTORY(webstage)
+endif( WEBSIM_FOUND )
+
IF ( BUILD_PLAYER_PLUGIN AND PLAYER_FOUND )
ADD_SUBDIRECTORY(libstageplugin)
ENDIF ( BUILD_PLAYER_PLUGIN AND PLAYER_FOUND )
Modified: code/stage/trunk/libstage/CMakeLists.txt
===================================================================
--- code/stage/trunk/libstage/CMakeLists.txt 2009-03-13 06:23:03 UTC (rev
7471)
+++ code/stage/trunk/libstage/CMakeLists.txt 2009-03-13 07:28:32 UTC (rev
7472)
@@ -7,7 +7,6 @@
block.cc
blockgroup.cc
camera.cc
- canvas.cc
file_manager.cc
file_manager.hh
gl.cc
@@ -27,8 +26,6 @@
model_props.cc
model_ranger.cc
option.cc
- options_dlg.cc
- options_dlg.hh
powerpack.cc
region.cc
resource.cc
@@ -39,12 +36,21 @@
waypoint.cc
world.cc
worldfile.cc
- worldgui.cc
+ worldgui.cc
+ canvas.cc
+ options_dlg.cc
+ options_dlg.hh
)
# TODO
# puck.cc
+# todo - build without FLTK - tricky since we use its image loading, etc.
+#if( BUILD_GUI )
+# list( APPEND stageSrcs
+# # gui-only sources go here
+# )
+#endif( BUILD_GUI )
add_library(stage SHARED ${stageSrcs})
Modified: code/stage/trunk/libstage/main.cc
===================================================================
--- code/stage/trunk/libstage/main.cc 2009-03-13 06:23:03 UTC (rev 7471)
+++ code/stage/trunk/libstage/main.cc 2009-03-13 07:28:32 UTC (rev 7472)
@@ -12,8 +12,10 @@
/* options descriptor */
static struct option longopts[] = {
- { "gui", no_argument, NULL, 'g' },
- // { "fast", no_argument, NULL, 'f' },
+ { "gui", optional_argument, NULL, 'g' },
+ { "port", required_argument, NULL, 'p' },
+ { "host", required_argument, NULL, 'h' },
+ { "federation", required_argument, NULL, 'f' },
{ NULL, 0, NULL, 0 }
};
@@ -27,17 +29,19 @@
int ch=0, optindex=0;
bool usegui = true;
- while ((ch = getopt_long(argc, argv, "gf", longopts, &optindex)) != -1)
+ while ((ch = getopt_long(argc, argv, "gfp:h:f:", longopts, &optindex)) != -1)
{
switch( ch )
{
case 0: // long option given
- printf( "option %s given", longopts[optindex].name );
+ printf( "option %s given\n", longopts[optindex].name );
break;
case 'g':
usegui = false;
printf( "[GUI disabled]" );
break;
+ case 'p':
+ printf( "PORT %d\n", atoi(optarg) );
case '?':
break;
default:
@@ -47,7 +51,8 @@
puts("");// end the first start-up line
-
+ exit(0);
+
// arguments at index [optindex] and later are not options, so they
// must be world file names
Added: code/stage/trunk/webstage/CMakeLists.txt
===================================================================
--- code/stage/trunk/webstage/CMakeLists.txt (rev 0)
+++ code/stage/trunk/webstage/CMakeLists.txt 2009-03-13 07:28:32 UTC (rev
7472)
@@ -0,0 +1,10 @@
+MESSAGE( STATUS "Configuring webstage" )
+
+add_executable( webstage webstage.cc )
+
+target_link_libraries( webstage ${WEBSIM_LIBRARIES} stage )
+
+INSTALL(TARGETS webstage
+ RUNTIME DESTINATION bin
+)
+
Property changes on: code/stage/trunk/webstage/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: code/stage/trunk/webstage/webstage.cc
===================================================================
--- code/stage/trunk/webstage/webstage.cc (rev 0)
+++ code/stage/trunk/webstage/webstage.cc 2009-03-13 07:28:32 UTC (rev
7472)
@@ -0,0 +1,219 @@
+#include <getopt.h>
+#include <websim.hh>
+#include <stage.hh>
+using namespace Stg;
+#include "config.h"
+
+/* options descriptor */
+static struct option longopts[] = {
+ { "gui", no_argument, NULL, 'g' },
+ { "port", required_argument, NULL, 'p' },
+ { "host", required_argument, NULL, 'h' },
+ { "federation", required_argument, NULL, 'f' },
+ { NULL, 0, NULL, 0 }
+};
+
+class WebStage : public websim::WebSim
+{
+ Stg::World* world;
+
+public:
+ WebStage( Stg::World* world,
+ const std::string& fedfile,
+ const std::string& host, int port ) :
+ websim::WebSim( fedfile, host, port ),
+ world(world)
+ {
+ }
+
+ virtual ~WebStage()
+ {}
+
+ void Push( std::string name )
+ {
+ Stg::Model* mod = world->GetModel( name.c_str() );
+ if( mod )
+ {
+ websim::Pose p;
+ websim::Velocity v;
+ websim::Acceleration a;
+
+ Stg::Pose sp = mod->GetPose();
+ p.x = sp.x;
+ p.y = sp.y;
+ p.z = sp.z;
+ p.a = sp.a;
+
+ Stg::Velocity sv = mod->GetVelocity();
+ v.x = sv.x;
+ v.y = sv.y;
+ v.z = sv.z;
+ v.a = sv.a;
+
+ SetPuppetPVA( name, p, v, a );
+ }
+ else
+ printf( "Warning: attempt to push PVA for unrecognized model
\"%s\"\n",
+ name.c_str() );
+ }
+
+ // Interface to be implemented by simulators
+ virtual bool CreateModel(const std::string& name,
+ const
std::string& type,
+
std::string& error)
+ {
+ printf( "create model name:%s type:%s\n", name.c_str(), type.c_str()
);
+ return true;
+ }
+
+ virtual bool DeleteModel(const std::string& name,
+
std::string& error)
+ {
+ printf( "deletee model name:%s \n", name.c_str() );
+ return true;
+ }
+
+ virtual bool SetModelPVA(const std::string& name,
+ const
websim::Pose& p,
+ const
websim::Velocity& v,
+ const
websim::Acceleration& a,
+
std::string& error)
+ {
+ printf( "set model PVA name:%s\n", name.c_str() );
+
+ Model* mod = world->GetModel( name.c_str() );
+ if( mod )
+ {
+ mod->SetPose( Stg::Pose( p.x, p.y, p.z, p.a ));
+ mod->SetVelocity( Stg::Velocity( v.x, v.y, v.z, v.a ));
+ // stage doesn't model acceleration
+ }
+ else
+ printf( "Warning: attempt to set PVA for unrecognized model
\"%s\"\n",
+ name.c_str() );
+
+ return true;
+ }
+
+ virtual bool GetModelPVA(const std::string& name,
+
websim::Pose& p,
+
websim::Velocity& v,
+
websim::Acceleration& a,
+
std::string& error)
+ {
+ printf( "get model name:%s\n", name.c_str() );
+
+ Model* mod = world->GetModel( name.c_str() );
+ if( mod )
+ {
+ Stg::Pose sp = mod->GetPose();
+ p.x = sp.x;
+ p.y = sp.y;
+ p.z = sp.z;
+ p.a = sp.a;
+
+ Stg::Velocity sv = mod->GetVelocity();
+ v.x = sv.x;
+ v.y = sv.y;
+ v.z = sv.z;
+ v.a = sv.a;
+ }
+ else
+ printf( "Warning: attempt to set PVA for unrecognized model
\"%s\"\n",
+ name.c_str() );
+
+ return true;
+ }
+};
+
+
+int main( int argc, char** argv )
+{
+ // initialize libstage - call this first
+ Stg::Init( &argc, &argv );
+
+ printf( "WebStage built on %s %s\n", PROJECT, VERSION );
+
+ std::string fedfilename = "";
+ std::string host = "localhost";
+ unsigned short port = 8000;
+
+ int ch=0, optindex=0;
+ bool usegui = true;
+
+ while ((ch = getopt_long(argc, argv, "gh:p:f:", longopts, &optindex)) != -1)
+ {
+ switch( ch )
+ {
+ case 0: // long option given
+ printf( "option %s given", longopts[optindex].name );
+ break;
+ case 'g':
+ usegui = false;
+ printf( "[GUI disabled]" );
+ break;
+ case 'p':
+ port = atoi(optarg);
+ break;
+ case 'h':
+ host = optarg;
+ break;
+ case 'f':
+ fedfilename = optarg;
+ break;
+ case '?':
+ break;
+ default:
+ printf("unhandled option %c\n", ch );
+ }
+ }
+
+ puts("");// end the first start-up line
+
+ const char* worldfilename = argv[optind];
+
+ printf( "[webstage] %s:%u fed %s world %s\n",
+ host.c_str(),
+ port,
+ fedfilename.c_str(),
+ worldfilename );
+
+ //websim::Pose p( 0,0,0,0,0,0 );
+ // websim::Velocity v( 0,0,0,0,0,0 );
+ // websim::Acceleration a( 0,0,0,0,0,0 );
+
+ World* world = ( usegui ?
+ new WorldGui( 400, 300,
worldfilename ) :
+ new World( worldfilename ) );
+ world->Load( worldfilename );
+
+ WebStage mws( world, fedfilename, host, port );
+
+ if( usegui == true )
+ {
+ //don't close the window once time has finished
+ while( true )
+ {
+ World::UpdateAll();
+ // TODO - push changes
+
+ mws.Push( "monkey" );
+ mws.Push( "punky" );
+ mws.Push( "chunky" );
+
+ mws.Update();
+ }
+ }
+ else
+ {
+ //close program once time has completed
+ bool quit = false;
+ while( quit == false )
+ {
+ quit = World::UpdateAll();
+ // TODO - push changes
+ // mws.SetPuppetPVA( "monkey", p, v, a );
+ mws.Update();
+ }
+ }
+}
Added: code/stage/trunk/webstage/world.fed
===================================================================
--- code/stage/trunk/webstage/world.fed (rev 0)
+++ code/stage/trunk/webstage/world.fed 2009-03-13 07:28:32 UTC (rev 7472)
@@ -0,0 +1,12 @@
+
+[federation]
+localhost:8000=master
+localhost:8001=slave
+
+[master]
+monkey=slave:pioneer2dx
+chunky=slave:pioneer2dx
+punky=slave:pioneer2dx
+
+
+
Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world 2009-03-13 06:23:03 UTC (rev 7471)
+++ code/stage/trunk/worlds/fasr.world 2009-03-13 07:28:32 UTC (rev 7472)
@@ -169,3 +169,8 @@
#autorob( pose [3.875 6.533 0 134.717] )
#autorob( pose [3.944 4.674 0 -103.060] )
#autorob( pose [4.634 6.897 0 -103.060] )
+
+
+autorob( name "monkey" pose [5.418 7.478 0 -163.478] joules 300000 )
+autorob( name "chunky" pose [6.418 7.478 0 -163.478] joules 300000 )
+autorob( name "punky" pose [7.418 7.478 0 -163.478] joules 300000 )
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit