Revision: 7862
http://playerstage.svn.sourceforge.net/playerstage/?rev=7862&view=rev
Author: asadat
Date: 2009-06-19 22:37:39 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
Modified Paths:
--------------
code/stage/trunk/webstage/CMakeLists.txt
code/stage/trunk/webstage/webstage.cc
Modified: code/stage/trunk/webstage/CMakeLists.txt
===================================================================
--- code/stage/trunk/webstage/CMakeLists.txt 2009-06-19 22:31:41 UTC (rev
7861)
+++ code/stage/trunk/webstage/CMakeLists.txt 2009-06-19 22:37:39 UTC (rev
7862)
@@ -1,5 +1,16 @@
MESSAGE( STATUS "Configuring webstage" )
+#include(FindPkgConfig)
+
+#pkg_search_module( LIBXML2 REQUIRED libxml-2.0)
+#IF( LIBXML2_FOUND )
+# MESSAGE( STATUS ${INDENT} "libxml version ${LIBXML2_VERSION} detected at
${LIBXML2_PREFIX}" )
+#ELSE( LIBXML2_FOUND )
+# MESSAGE( ${INDENT} "libxml2 not detected" )
+#ENDIF( LIBXML2_FOUND )
+
+#include_directories( ${LIBXML2_INCLUDE_DIRS} )
+
add_executable( webstage webstage.cc )
target_link_libraries( webstage ${WEBSIM_LIBRARIES} stage )
Modified: code/stage/trunk/webstage/webstage.cc
===================================================================
--- code/stage/trunk/webstage/webstage.cc 2009-06-19 22:31:41 UTC (rev
7861)
+++ code/stage/trunk/webstage/webstage.cc 2009-06-19 22:37:39 UTC (rev
7862)
@@ -4,6 +4,7 @@
using namespace Stg;
#include "config.h"
+
/* options descriptor */
static struct option longopts[] = {
{ "gui", no_argument, NULL, 'g' },
@@ -89,7 +90,38 @@
}
}
+ virtual bool GetModelChildren(const std::string& model,
+
std::vector<std::string>& children)
+ {
+ GList* c;
+ if(model == "")
+ {
+ c = world->GetChildren();
+ }
+ else
+ {
+ Stg::Model* mod = world->GetModel( model.c_str() );
+ if( mod ){
+
+ c = mod->GetChildren();
+
+ }else{
+ printf("Warning: Tried to get the children of unknown
model:%s \n", model.c_str());
+ return false;
+ }
+
+ }
+
+ for(;c;c = c->next){
+
+ children.push_back(std::string(((Model*)c->data)->Token()));
+ }
+
+ return true;
+
+ }
+
// Interface to be implemented by simulators
virtual bool CreateModel(const std::string& name,
const
std::string& type,
@@ -115,7 +147,167 @@
return true;
}
- virtual bool SetModelPVA(const std::string& name,
+ virtual bool GetModelData(const std::string& name,
+
+ std::string&
response,
+ websim::Format
format,
+ void*
xmlparent) {
+ std::string str;
+ websim::Time t = GetTime();
+
+ Model*mod = world->GetModel( name.c_str() );
+ if(mod){
+ stg_model_type_t type = mod->GetModelType();
+ if(type == MODEL_TYPE_POSITION){
+
+
+
+ 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;
+
+ WebSim::GetPVA(name, t, p, v, a, format, response,
xmlparent);
+
+
+
+ }else if(type == MODEL_TYPE_LASER){
+
+ uint32_t resolution;
+ double fov;
+ websim::Pose p;
+ std::vector<double> ranges;
+
+
+ ModelLaser* laser = (ModelLaser*)mod;
+ uint32_t sample_count=0;
+ std::vector<ModelLaser::Sample> scan =
laser->GetSamples();
+
+ ModelLaser::Config cfg = laser->GetConfig();
+ resolution = cfg.resolution;
+ fov = cfg.fov;
+
+ sample_count = scan.size();
+ for(unsigned int i=0;i<sample_count;i++)
+ ranges.push_back(scan[i].range);
+
+ WebSim::GetLaserData(name, t, resolution, fov, p,
ranges, format, response, xmlparent);
+
+
+ }else if(type == MODEL_TYPE_RANGER){
+
+ std::vector<websim::Pose> p;
+ std::vector<double> ranges;
+
+ ModelRanger* ranger = (ModelRanger*)mod;
+
+ if(ranger){
+ for(unsigned int
i=0;i<ranger->sensors.size();i++){
+ //char str[10];
+
//sprintf(str,"size:%d",ranger->sensors.size());
+ //puts(str);
+ //puts("in the ranger loop");
+ websim::Pose pos;
+ Pose rpos;
+ rpos = ranger->sensors[i].pose;
+ pos.x = rpos.x;
+ pos.y = rpos.y;
+ pos.z = rpos.z;
+ pos.a = rpos.a;
+ p.push_back(pos);
+
+
ranges.push_back(ranger->sensors[i].range);
+ }
+ }
+
+ WebSim::GetRangerData(name, t, p, ranges, format,
response, xmlparent);
+
+
+ }else if(type == MODEL_TYPE_FIDUCIAL){
+
+ ModelFiducial::Fiducial* fids;
+ unsigned int n=0;
+ std::vector<websim::Fiducial> f;
+
+ ModelFiducial* fiducial = (ModelFiducial*)mod;
+
+
+ fids = fiducial->GetFiducials(&n);
+
+
+ for(unsigned int i=0;i<n;i++){
+ websim::Fiducial fid;
+ fid.range = fids[i].range;
+ fid.bearing = fids[i].bearing;
+ fid.id = fids[i].id;
+
+ f.push_back(fid);
+ }
+
+
+ WebSim::GetFiducialData(name, t, f, format, response,
xmlparent);
+
+
+ }else{
+
+ //printf("Warning: Unkown model type\n");
+ return false;
+
+ }
+ }
+ else{
+ printf("Warning: tried to get the data of unkown model:%s .\n",
name.c_str());
+ return false;
+ }
+ return true;
+ }
+
+ bool GetModelType(const std::string& name,
+
+
std::string& type ){
+
+ Model*mod = world->GetModel( name.c_str() );
+ if(mod){
+ stg_model_type_t mtype = mod->GetModelType();
+
+ if(mtype == MODEL_TYPE_POSITION){
+ type = "Position";
+ }else if(mtype == MODEL_TYPE_LASER){
+ type = "Laser";
+
+ }else if(mtype == MODEL_TYPE_RANGER){
+ type = "Ranger";
+
+ }else if(mtype == MODEL_TYPE_FIDUCIAL){
+ type = "Fiducial";
+
+ }else{
+ type = "";
+
+ }
+
+ return true;
+ }
+
+
+ return false;
+
+ }
+
+
+
+ virtual bool SetModelPVA(const std::string& name,
const
websim::Pose& p,
const
websim::Velocity& v,
const
websim::Acceleration& a,
@@ -169,14 +361,15 @@
return true;
}
-
+/*
virtual bool GetLaserData(const std::string& name,
websim::Time& t,
uint32_t& resolution,
double& fov,
websim::Pose& p,
std::vector<double>& ranges,
- std::string& error){
+ std::string& error,
+ void* parent){
t = GetTime();
@@ -220,7 +413,8 @@
websim::Time& t,
std::vector<websim::Pose>& p,
std::vector<double>& ranges,
-
std::string& response){
+
std::string& response,
+
xmlNode* parent){
t = GetTime();
Model* mod = world->GetModel( name.c_str() );
@@ -260,7 +454,8 @@
return true;
-}
+}*/
+
virtual bool GetModelExtent(const std::string& name,
double&
x,
double&
y,
@@ -296,7 +491,7 @@
return false;
}
}
- GetModelTree();
+
return true;
}
@@ -316,7 +511,7 @@
return true;
}
-
+/*
virtual bool GetModelTree()
{
@@ -324,7 +519,7 @@
return true;
}
-
+ */
virtual bool GetSayStrings(std::vector<std::string>& sayings)
{
unsigned int n=0;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit