Revision: 7914
http://playerstage.svn.sourceforge.net/playerstage/?rev=7914&view=rev
Author: asadat
Date: 2009-06-27 00:01:32 +0000 (Sat, 27 Jun 2009)
Log Message:
-----------
added GetGeometryData() and xml response for getting clock
Modified Paths:
--------------
code/websim/src/req_sim.cc
code/websim/src/websim.cc
code/websim/src/websim.hh
Modified: code/websim/src/req_sim.cc
===================================================================
--- code/websim/src/req_sim.cc 2009-06-26 19:59:28 UTC (rev 7913)
+++ code/websim/src/req_sim.cc 2009-06-27 00:01:32 UTC (rev 7914)
@@ -62,14 +62,15 @@
struct evkeyvalq* kv,
std::string& response)
{
- /*
+
double x,y,z;
Pose center;
- GetModelExtent("sim", x, y, z, center, response);
- GetXMLModelExtent("sim", x, y, z, center, response);
- */
-
- response = "Warning: geometry not yet implemented";
+ if(GetModelGeometry("sim", x, y, z, center, response)){
+ this->GetGeometryData("sim", x, y, z, center, format, response,
NULL);
+ }else{
+ response = "Warning: geometry not yet implemented";
+ return false;
+ }
return true;
}
@@ -183,7 +184,11 @@
if( action == "get" )
{
- response = "Current time: " + GetTime().String() + " seconds.";
+ if(format == TEXT){
+ response = "Current time: " + GetTime().String() + " seconds.";
+ }else if(format == XML){
+ response = "<Time value=\""+GetTime().String()+"\" />";
+ }
return true;
}
Modified: code/websim/src/websim.cc
===================================================================
--- code/websim/src/websim.cc 2009-06-26 19:59:28 UTC (rev 7913)
+++ code/websim/src/websim.cc 2009-06-27 00:01:32 UTC (rev 7914)
@@ -305,13 +305,13 @@
return(GetModelTree(model, format, response, false));
- }else if(prop == "extent"){
+ }else if(prop == "geometry"){
double x,y,z;
Pose center;
- if(GetModelExtent(model, x, y, z, center, response))
+ if(GetModelGeometry(model, x, y, z, center, response))
{
- GetModelExtent(model, x, y, z, center, format, response, NULL);
+ GetGeometryData(model, x, y, z, center, format, response, NULL);
return true;
}else{
@@ -723,15 +723,19 @@
if(format == TEXT){
std::string res;
- char temp[128];
+ char temp[512];
+ puts("here1\n");
for(unsigned int i=0;i<f.size();i++){
- sprintf(temp,"(%.3f,%.3f,%d)\n", f.at(i).range, f.at(i).bearing,
f.at(i).id);
+ sprintf(temp,"((%.3f,%.3f,%.3f),(%.3f,%.3f,%.3f),%d)\n", f.at(i).pos.x,
f.at(i).pos.y, f.at(i).pos.z,
+ f.at(i).pos.r, f.at(i).pos.p, f.at(i).pos.a,
f.at(i).id);
+ puts("here2\n");
res.append(temp);
}
+ puts("here3\n");
- char buf[1024];
+ char buf[2048];
snprintf(buf, sizeof(buf),
"%s's state @%s: \n Fiducial:\n",
name.c_str(),
@@ -763,9 +767,10 @@
std::string res;
- char temp[128];
+ char temp[512];
for(unsigned int i=0;i<f.size();i++){
- sprintf(temp,"(%.3f,%.3f,%d)", f.at(i).range, f.at(i).bearing,
f.at(i).id);
+ sprintf(temp,"((%.3f,%.3f,%.3f),(%.3f,%.3f,%.3f),%d)", f.at(i).pos.x,
f.at(i).pos.y, f.at(i).pos.z,
+ f.at(i).pos.r, f.at(i).pos.p, f.at(i).pos.a,
f.at(i).id);
res.append(temp);
}
@@ -799,7 +804,7 @@
}
void
-WebSim::GetModelExtent(const std::string& name,
+WebSim::GetGeometryData(const std::string& name,
double& x,
double& y,
double& z,
@@ -811,10 +816,10 @@
if(format == TEXT){
char buf[1024];
if(name == "sim")
- snprintf(buf, sizeof(buf),"World Extent: (%.3f,%.3f,%.3f)\n
Origin (%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)",
+ snprintf(buf, sizeof(buf),"World Size: (%.3f,%.3f,%.3f)\n Origin
(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)",
x, y, z, center.x, center.y, center.z, center.r, center.p,
center.a);
else
- snprintf(buf, sizeof(buf),"%s's Extent: (%.3f,%.3f,%.3f)\n Origin
(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)",
+ snprintf(buf, sizeof(buf),"%s's Size: (%.3f,%.3f,%.3f)\n Origin
(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)",
name.c_str(), x, y, z, center.x, center.y, center.z, center.r,
center.p, center.a);
response = buf;
@@ -831,16 +836,16 @@
doc = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(NULL, BAD_CAST "root");
xmlDocSetRootElement(doc, root_node);
- node = xmlNewChild(root_node, NULL, BAD_CAST "ModelExtent", NULL);
+ node = xmlNewChild(root_node, NULL, BAD_CAST "ModelGeometry", NULL);
}else{
node = (xmlNodePtr)xmlnode;
- xmlNodeSetName(node, xmlCharStrdup("ModelExtent"));
+ xmlNodeSetName(node, xmlCharStrdup("ModelGeometry"));
//node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST "ModelExtent",
NULL);
//root_node = (xmlNodePtr)parent;
}
- xmlNewProp(node, BAD_CAST "Type", BAD_CAST "extent");
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "geometry");
tmp = ConvertInput(name.c_str(),MY_ENCODING);
xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
Modified: code/websim/src/websim.hh
===================================================================
--- code/websim/src/websim.hh 2009-06-26 19:59:28 UTC (rev 7913)
+++ code/websim/src/websim.hh 2009-06-27 00:01:32 UTC (rev 7914)
@@ -172,7 +172,7 @@
@returns TRUE if the method is successful.
*/
- virtual bool GetModelExtent(const std::string& name,
+ virtual bool GetModelGeometry(const std::string& name,
double&
bx,
double&
by,
double&
bz,
@@ -405,7 +405,7 @@
std::string& response,
void*
xmlnode );
- /** Puts the extent information of the model in the desired format:
text/xml. If the format parameter is TEXT, the output is
+ /** Puts the geometry information of the model in the desired format:
text/xml. If the format parameter is TEXT, the output is
in the response parameter. If the format is XML and xmlnode is NULL,
the xml content will be stored
in the response parameter. If the forma is XML and xmlnode is not NULL,
the data will be added to the
xml node as attributes.
@@ -419,7 +419,7 @@
@param response the string output
@param xmlnode the xml node output
*/
- void GetModelExtent(const std::string& name,
+ void GetGeometryData(const std::string& name,
double&
x,
double&
y,
double&
z,
@@ -633,10 +633,12 @@
class Fiducial
{
public:
+ Pose pos;
double range;
double bearing;
int id;
- Fiducial():range(0),bearing(0),id(-1){ }
+ Fiducial():range(0),bearing(0),id(-1){}
+
};
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit