Revision: 7861
http://playerstage.svn.sourceforge.net/playerstage/?rev=7861&view=rev
Author: asadat
Date: 2009-06-19 22:31:41 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
GetModelData() is added to get the data of all sensor types
Modified Paths:
--------------
code/websim/src/websim.cc
code/websim/src/websim.hh
Modified: code/websim/src/websim.cc
===================================================================
--- code/websim/src/websim.cc 2009-06-19 07:12:55 UTC (rev 7860)
+++ code/websim/src/websim.cc 2009-06-19 22:31:41 UTC (rev 7861)
@@ -33,7 +33,8 @@
#include <stdlib.h>
#include <string.h>
#include <libxml/encoding.h>
-#include <libxml/xmlwriter.h>
+//#include <libxml/xmlwriter.h>
+//#include <libxml/tree.h>
#define MY_ENCODING "ISO-8859-1"
@@ -187,33 +188,86 @@
std::string& response)
{
- bool xmlresponse = false;
- std::string format;
+ Format format;
+ std::string f;
// specify the format of the response: Text or Xml
- if(GetValue(format,kv,"format")){
+ if(GetValue(f, kv, "format")){
- if(format == "xml")
- xmlresponse = true;
- else
- xmlresponse = false;
- }
+ if(f == "xml")
+ format = XML;
+ else
+ format = TEXT;
+ }else
+ format = TEXT;
// The special simulation model
if(model == "sim")
{
- return HandleSimRequest(prop, action, xmlresponse, kv, response);
+ return HandleSimRequest(prop, action, format, kv, response);
+ }else if(model == "viz"){
+ if(prop ==""){
+ puts("viz request");
+ //response = "<html><header></header><body><img
src=\"viz/1.png\" ></body></html>";
+
+ response = "<HTML><HEAD><TITLE>A Simple Program</TITLE></HEAD>";
+ response += "<BODY> <CENTER><APPLET
CODE=\"ScrollingSimple.class\" WIDTH=\"1500\" HEIGHT=\"1000\"
id=\"TheApplet\"></APPLET></CENTER>";
+ response += "<b>The returned data is:</b><br /><script
type=\"text/javascript\">
document.write(TheApplet.getResponseText());</script></BODY></HTML>";
+ }else{
+
+ puts("SendingFile:");
+ puts(prop.c_str());
+
+
+ }
+ return true;
+
+ }else if(model == ""){
+
+ std::vector<std::string> links;
+ char tmp[2048];
+ sprintf(tmp,"%s %s", WebSim::package.c_str(), WebSim::version.c_str());
+ response = "<html><head ><title>WebSim</title></head><body><h3>";
+ response.append(tmp);
+
+ response.append( "</h3><p>Welcome to WebSim, a web based interface to
robot simulation. Through this program, you can get the state of the robots and
their sensors using URIs. Here are some examples that might be useful: ");
+
+
+ sprintf(tmp,"</p><p><a
href=\"http://%s/sim/tree/get\">http://%s/sim/tree/get</a></p>",hostportname.c_str(),
hostportname.c_str());
+ links.push_back(std::string(tmp));
+
+
+ sprintf(tmp,"<p><a
href=\"http://%s/position:1/pva/get\">http://%s/position:1/pva/get</a></p>",
hostportname.c_str(), hostportname.c_str());
+ links.push_back(std::string(tmp));
+
+
+ sprintf(tmp, "<p><a
href=\"http://%s/position:1/laser:0/data/get\">http://%s/position:1/laser:0/data/get</a></p>",
hostportname.c_str(), hostportname.c_str());
+ links.push_back(std::string(tmp));
+
+
+ sprintf(tmp,"<p><a
href=\"http://%s/position:1/ranger:0/data/get\">http://%s/position:1/ranger:0:/data/get</a></p>",
hostportname.c_str(), hostportname.c_str());
+ links.push_back(std::string(tmp));
+
+
+ sprintf(tmp,"<p><a
href=\"http://%s/position:1/model:0/fiducial:0/data/get\">http://%s/position:1/model:0/fiducial:0/data/get</a></p>",hostportname.c_str(),
hostportname.c_str());
+ links.push_back(std::string(tmp));
+
+
+ response += links[0]+links[1]+links[2]+ links[3]+links[4]+
"</body></html>";
+
+
+ return true;
}
// Everything else must be an existing model
- else
+ else
{
- return HandleModelRequest(model, prop, action, xmlresponse, kv, response);
+ return HandleModelRequest(model, prop, action, format, kv, response);
}
}
bool
WebSim::HandleSimRequest(const std::string& prop,
const std::string& action,
- bool xmlresponse,
+ Format format,
struct evkeyvalq* kv,
std::string& response)
{
@@ -269,27 +323,27 @@
}
}
else if(prop == "extent")
- {
+ {/*
double x,y,z;
Pose center;
GetModelExtent("sim", x, y, z, center, response);
GetXMLModelExtent("sim", x, y, z, center, response);
-
+ */
+ return true;
}
- else if(prop == "robots")
+ else if(prop == "children")
{
- unsigned int n=0;
- GetNumberOfRobots(n);
- char tmp[256];
- sprintf(tmp, "Number of Robots: %d",n);
- response = tmp;
+ std::vector<std::string> children;
+ GetModelChildren("",children);
+
+ for(unsigned int i=0;i<children.size();i++)
+ response += "-" + children[i];
}
- else if(prop == "sayings")
+ else if(prop == "tree")
{
- std::vector<std::string> says;
- GetSayStrings(says);
- for(int i=0;i<says.size();i++)
- response += says.at(i) + "\n";
+ GetModelTree("", format, response, false);
+ return true;
+
}
else if(prop == "greet") // action is the name of the greeting server
{
@@ -303,95 +357,61 @@
response = "ERROR: Unknown property " + prop + " for sim";
return false;
}
+
+ return false;
}
bool
WebSim::HandleModelRequest(const std::string& model,
const std::string& prop,
const std::string& action,
- bool xmlresponse,
+ Format format,
struct evkeyvalq* kv,
std::string& response)
{
if(action == "get")
{
- if(prop == "pva")
- {
- Pose p;
- Velocity v;
- Acceleration a;
- Time t;
- if(GetModelPVA(model, t, p, v, a, response))
- {
+ if(prop == "data" || prop == ""){
+
+ return(GetModelData(model, response, format, NULL));
- if(xmlresponse)
- GetXMLPVA(model, t, p, v, a, response);
+ }else if(prop == "pva"){
+ Pose p;
+ Velocity v;
+ Acceleration a;
+ Time t;
+ if(GetModelPVA(model, t, p, v, a, response)){
+
+ GetPVA(model, t, p, v, a, format, response, NULL);
+ return true;
+ }
else
- GetTextPVA(model, t, p, v, a, response);
-
-
- return true;
- }
- else
- {
- response = "ERROR: Failed to get pose for model " + model;
- return false;
- }
- }else if(prop == "laser"){
- Time t;
- uint32_t res;
- double fov;
- Pose p;
- std::vector<double> ranges;
- if(GetLaserData(model, t, res, fov, p,ranges, response))
- {
- if(xmlresponse)
- GetXMLLaserData(model, t, res, fov, p, ranges,
response);
- else
- GetTextLaserData(model, t, res, fov, p, ranges,
response);
+ return false;
- return true;
-
- }
- else
- {
- response = "ERROR: Failed to get laser data for model " + model;
- return false;
- }
+ }else if(prop == "children"){
+ std::vector<std::string> children;
+ GetModelChildren(model,children);
+
+ for(unsigned int i=0;i<children.size();i++)
+ response += children[i] + "\n";
- }else if(prop=="ranger"){
+ return true;
- Time t;
- std::vector<double> ranges;
- std::vector<Pose> p;
+ }else if(prop == "tree"){
- if(GetRangerData(model, t, p, ranges, response))
- {
- if(xmlresponse)
- GetXMLRangerData(model, t, p, ranges, response);
- else
- GetTextRangerData(model, t, p, ranges, response);
-
- return true;
-
- }
- else
- {
- response = "ERROR: Failed to get ranger data for model " + model;
- return false;
- }
-
+ return(GetModelTree(model, format, response, true));
+
+
}else if(prop == "extent"){
double x,y,z;
Pose center;
if(GetModelExtent(model, x, y, z, center, response))
{
- if(xmlresponse)
- GetXMLModelExtent(model, x, y, z, center, response);
- else
- GetTextModelExtent(model, x, y, z, center, response);
+ GetModelExtent(model, x, y, z, center, format, response, NULL);
+ return true;
+
}else{
response = "ERROR: failed to get the extent of model " + model;
@@ -481,177 +501,107 @@
response = "ERROR: Unknown action " + action;
return false;
}
+
+ return false;
}
void
-WebSim::GetTextPVA(const std::string& name,
+WebSim::GetPVA(const std::string& name,
Time& t,
const
Pose& p,
const
Velocity& v,
const
Acceleration& a,
-
std::string& response)
+ Format
format,
+
std::string& response,
+ void*
xmlnode)
{
+ if(format == TEXT){
+ char buf[1024];
+ snprintf(buf, sizeof(buf),
+ "%s's state @%s: \n pose: (%.3f,%.3f,%.3f)
(%.3f,%.3f,%.3f)\n"
+ " vel : (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)\n"
+ " acc : (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)\n",
+ name.c_str(),
+ t.String().c_str(),
+ p.x, p.y, p.z, p.r, p.p, p.a,
+ v.x, v.y, v.z, v.r, v.p, v.a,
+ a.x, a.y, a.z, a.r, a.p, a.a);
+ response = buf;
- char buf[1024];
- snprintf(buf, sizeof(buf),
- "%s's state @%s: \n pose: (%.3f,%.3f,%.3f)
(%.3f,%.3f,%.3f)\n"
- " vel : (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)\n"
- " acc : (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)\n",
- name.c_str(),
- t.String().c_str(),
- p.x, p.y, p.z, p.r, p.p, p.a,
- v.x, v.y, v.z, v.r, v.p, v.a,
- a.x, a.y, a.z, a.r, a.p, a.a);
- response = buf;
+ }else if (format == XML){
-}
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node;
+ xmlChar *tmp;
+ char str[128];
+ if(xmlnode == NULL){
-void
-WebSim::GetXMLPVA(const std::string& name,
- Time& t,
- const
Pose& p,
- const
Velocity& v,
- const
Acceleration& a,
-
std::string& response)
-{
-
- xmlTextWriterPtr writer;
- xmlBufferPtr buf;
- xmlChar *tmp;
- char str[32];
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+ node = xmlNewChild(root_node, NULL, BAD_CAST "Model",
NULL);
+ }else{
+ node = (xmlNodePtr) xmlnode;
+ xmlNodeSetName(node, xmlCharStrdup("Model"));
+ //node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST
"PVA", NULL);
+ //root_node = (xmlNodePtr)parent;
+ }
- buf = xmlBufferCreate();
- writer = xmlNewTextWriterMemory(buf, 0);
+
+
+ sprintf(str,"%s",t.String().c_str());
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Time", BAD_CAST tmp);
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "pva");
- xmlTextWriterStartElement(writer, BAD_CAST "Data");
-
- sprintf(str,"%s",t.String().c_str());
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Time", BAD_CAST tmp);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Type", BAD_CAST "pva");
+ tmp = ConvertInput(name.c_str(),MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
+
+ sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",p.x, p.y, p.z, p.r,
p.p, p.a);
+ tmp = ConvertInput(str, MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Pose", BAD_CAST tmp);
- tmp = ConvertInput(name.c_str(),MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Model", BAD_CAST tmp);
+ sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",v.x, v.y, v.z, v.r,
v.p, v.a);
+ tmp = ConvertInput(str, MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Velocity", BAD_CAST tmp);
- xmlTextWriterStartElement(writer, BAD_CAST "Pose");
-
- sprintf(str,"%.3f",p.x);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "x", BAD_CAST tmp);
-
- sprintf(str,"%.3f",p.y);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "y", BAD_CAST tmp);
+ sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",a.x, a.y, a.z, a.r,
a.p, a.a);
+ tmp = ConvertInput(str, MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Acceleration", BAD_CAST tmp);
+
+ if(xmlnode == NULL){
+ xmlBufferPtr buf = xmlBufferCreate();
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc,node, 0, 1);
+ response = (const char*) buf->content;
+ puts(response.c_str());
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+ }
+ }
- sprintf(str,"%.3f",p.z);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "z", BAD_CAST tmp);
+}
- sprintf(str,"%.3f",p.r);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "r", BAD_CAST tmp);
- sprintf(str,"%.3f",p.p);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "p", BAD_CAST tmp);
-
- sprintf(str,"%.3f",p.a);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "a", BAD_CAST tmp);
-
- xmlTextWriterEndElement(writer);
-
-
-
- xmlTextWriterStartElement(writer, BAD_CAST "Velocity");
-
- sprintf(str,"%.3f",v.x);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "x", BAD_CAST tmp);
-
- sprintf(str,"%.3f",v.y);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "y", BAD_CAST tmp);
-
- sprintf(str,"%.3f",v.z);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "z", BAD_CAST tmp);
-
- sprintf(str,"%.3f",v.r);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "r", BAD_CAST tmp);
-
- sprintf(str,"%.3f",v.p);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "p", BAD_CAST tmp);
-
- sprintf(str,"%.3f",v.a);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "a", BAD_CAST tmp);
-
- xmlTextWriterEndElement(writer);
-
-
-
-
- xmlTextWriterStartElement(writer, BAD_CAST "Acceleration");
-
- sprintf(str,"%.3f",a.x);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "x", BAD_CAST tmp);
-
- sprintf(str,"%.3f",a.y);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "y", BAD_CAST tmp);
-
- sprintf(str,"%.3f",a.z);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "z", BAD_CAST tmp);
-
- sprintf(str,"%.3f",a.r);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "r", BAD_CAST tmp);
-
- sprintf(str,"%.3f",a.p);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "p", BAD_CAST tmp);
-
- sprintf(str,"%.3f",a.a);
- tmp = ConvertInput(str, MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "a", BAD_CAST tmp);
-
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter(writer);
-
-
- puts((const char*) buf->content);
-
- response = (const char*) buf->content;
-
- xmlBufferFree(buf);
-
-
-
-}
-
void
-WebSim::GetTextLaserData(const std::string& name,
+WebSim::GetLaserData(const std::string& name,
Time& t,
uint32_t&
resolution,
double& fov,
Pose& p,
std::vector<double>& ranges,
- std::string&
response)
+ Format format,
+ std::string&
response,
+ void* xmlnode)
{
+ if(format == TEXT){
+
std::string res;
char temp[128];
for(unsigned int i=0;i<ranges.size();i++){
@@ -673,87 +623,89 @@
fov,
p.x,p.y,p.z,p.r,p.p,p.a);
response = buf;
-}
-void
-WebSim::GetXMLLaserData(const std::string& name,
- Time& t,
- uint32_t&
resolution,
- double& fov,
- Pose& p,
-
std::vector<double>& ranges,
- std::string&
response)
-{
+ }else if(format == XML){
+
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node;
+ xmlChar *tmp;
+ char str[128];
-
- xmlTextWriterPtr writer;
- xmlBufferPtr buf;
- xmlChar *tmp;
- char str[128];
+ if(xmlnode == NULL){
+ puts("no parent\n");
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+ node = xmlNewChild(root_node, NULL, BAD_CAST "Model",
NULL);
+ }else{
+ node = (xmlNodePtr) xmlnode;
+ xmlNodeSetName(node, xmlCharStrdup("Model"));
+ //node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST
"Laser", NULL);
+ //root_node = (xmlNodePtr)parent;
+ }
-
- std::string res;
- char temp[128];
- for(unsigned int i=0;i<ranges.size();i++){
- sprintf(temp,"%.3f",ranges.at(i));
- res.append(temp);
- if(i+1 != ranges.size())
- res.append(",");
- }
+ std::string res;
+ char temp[128];
+ for(unsigned int i=0;i<ranges.size();i++){
+ sprintf(temp,"%.3f",ranges.at(i));
+ res.append(temp);
+ if(i+1 != ranges.size())
+ res.append(",");
+ }
- buf = xmlBufferCreate();
- writer = xmlNewTextWriterMemory(buf, 0);
-
+
+ xmlNewProp(node, BAD_CAST "Time", BAD_CAST t.String().c_str());
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "laser");
- xmlTextWriterStartElement(writer, BAD_CAST "Data");
-
-
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Time", BAD_CAST
t.String().c_str());
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Type", BAD_CAST "laser");
+ tmp = ConvertInput(name.c_str(),MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
+
+ sprintf(str,"%d",resolution);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Resolution", BAD_CAST tmp);
- tmp = ConvertInput(name.c_str(),MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Model", BAD_CAST tmp);
-
- xmlTextWriterStartElement(writer, BAD_CAST "Laser");
-
- sprintf(str,"%d",resolution);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Resolution", BAD_CAST tmp);
-
- sprintf(str,"%.3f",fov);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "FOV", BAD_CAST tmp);
-
- sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",p.x, p.y, p.z, p.r, p.p, p.a);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Pose", BAD_CAST tmp);
+ sprintf(str,"%.3f",fov);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "FOV", BAD_CAST tmp);
+
+ sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",p.x, p.y, p.z, p.r,
p.p, p.a);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Pose", BAD_CAST tmp);
- tmp = ConvertInput(res.c_str(), MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Samples", BAD_CAST tmp);
+ tmp = ConvertInput(res.c_str(), MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Samples", BAD_CAST tmp);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndElement(writer);
+ if(xmlnode == NULL){
+ xmlBufferPtr buf = xmlBufferCreate();
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc,node, 0, 1);
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter(writer);
-
+ response = (const char*) buf->content;
+ puts(response.c_str());
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+ }
- puts((const char*) buf->content);
+
+
- response = (const char*) buf->content;
-
- xmlBufferFree(buf);
-
-}
+ }
+}
+
void
-WebSim::GetTextRangerData(const std::string& name,
+WebSim::GetRangerData(const std::string& name,
Time& t,
std::vector<Pose>& p,
-
std::vector<double>& ranges,
std::string& response)
+
std::vector<double>& ranges,
+ Format
format,
+
std::string& response,
+ void*
xmlnode)
{
+ if(format == TEXT){
+
std::string res;
char temp[128];
for(unsigned int i=0;i<ranges.size();i++){
@@ -781,159 +733,345 @@
res.c_str(),
pstr.c_str());
response = buf;
-}
+
+ }else if(format == XML){
+
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node;
+ xmlChar *tmp;
+ char str[128];
-void
-WebSim::GetXMLRangerData(const std::string& name,
- Time& t,
-
std::vector<Pose>& p,
-
std::vector<double>& ranges,
std::string& response)
-{
+ if(xmlnode == NULL){
+ puts("no parent\n");
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+ node = xmlNewChild(root_node, NULL, BAD_CAST "Model",
NULL);
+ }else{
+ node = (xmlNodePtr)xmlnode;
+ xmlNodeSetName(node, xmlCharStrdup("Model"));
+ //node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST
"Ranger", NULL);
+ //root_node = (xmlNodePtr)parent;
+ }
- xmlTextWriterPtr writer;
- xmlBufferPtr buf;
- xmlChar *tmp;
- char str[32];
-
- std::string res;
- char temp[1024];
- for(unsigned int i=0;i<ranges.size();i++){
- sprintf(temp,"%.3f",ranges.at(i));
- res.append(temp);
- if(i+1 != ranges.size())
- res.append(",");
- }
+ std::string res;
+ char temp[1024];
+ for(unsigned int i=0;i<ranges.size();i++){
+ sprintf(temp,"%.3f",ranges.at(i));
+ res.append(temp);
+ if(i+1 != ranges.size())
+ res.append(",");
+ }
- std::string pstr;
- char ptmp[2048];
- for(unsigned int i=0;i<p.size();i++){
- Pose pos = p.at(i);
- sprintf(ptmp," (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)",
- pos.x,pos.y,pos.x,pos.r,pos.p,pos.a);
- pstr.append(ptmp);
- }
-
- buf = xmlBufferCreate();
- writer = xmlNewTextWriterMemory(buf, 0);
-
+ std::string pstr;
+ char ptmp[2048];
+ for(unsigned int i=0;i<p.size();i++){
+ Pose pos = p.at(i);
+ sprintf(ptmp," (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)",
+ pos.x,pos.y,pos.x,pos.r,pos.p,pos.a);
+ pstr.append(ptmp);
+ }
+
+ //xmlNodePtr node = xmlNewChild(root_node, NULL, BAD_CAST
"Ranger", NULL);
+
+
+ sprintf(str,"%s",t.String().c_str());
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Time", BAD_CAST tmp);
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "ranger");
- xmlTextWriterStartElement(writer, BAD_CAST "Data");
-
- sprintf(str,"%s",t.String().c_str());
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Time", BAD_CAST tmp);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Type", BAD_CAST "ranger");
+ tmp = ConvertInput(name.c_str(),MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
- tmp = ConvertInput(name.c_str(),MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Model", BAD_CAST tmp);
+ tmp = ConvertInput(res.c_str(), MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Samples", BAD_CAST tmp);
- xmlTextWriterStartElement(writer, BAD_CAST "Ranger");
-
-
- tmp = ConvertInput(res.c_str(), MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Samples", BAD_CAST tmp);
-
- tmp = ConvertInput(pstr.c_str(), MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Positions", BAD_CAST tmp);
+ tmp = ConvertInput(pstr.c_str(), MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Positions", BAD_CAST tmp);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndElement(writer);
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter(writer);
-
+ if(xmlnode == NULL){
+ xmlBufferPtr buf = xmlBufferCreate();
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc,node, 0, 1);
- puts((const char*) buf->content);
+ response = (const char*) buf->content;
+ puts(response.c_str());
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+ }
+
- response = (const char*) buf->content;
-
- xmlBufferFree(buf);
+ }
-
}
void
-WebSim::GetTextModelExtent(const std::string& name,
- double& x,
- double& y,
- double& z,
- Pose& center,
- std::string& response)
+WebSim::GetFiducialData(const std::string& name,
+ Time& t,
+
std::vector<Fiducial>& f,
+ Format
format,
+
std::string& response,
+ void*
xmlnode )
{
- char buf[1024];
- if(name == "sim")
- snprintf(buf, sizeof(buf),"World Extent: (%.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)",
- name.c_str(), x, y, z, center.x, center.y,
center.z, center.r, center.p, center.a);
- response = buf;
+
+ if(format == TEXT){
+
+ std::string res;
+ char temp[128];
+ 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);
+ res.append(temp);
+
+ }
+
+
+ char buf[1024];
+ snprintf(buf, sizeof(buf),
+ "%s's state @%s: \n Fiducial:\n",
+ name.c_str(),
+ t.String().c_str());
+
+ response = buf;
+ response.append(res);
+ }else if(format == XML){
+
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node;
+ xmlChar *tmp;
+ char str[128];
+
+ if(xmlnode == NULL){
+ puts("no parent\n");
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ root_node = xmlNewNode(NULL, BAD_CAST "root");
+ xmlDocSetRootElement(doc, root_node);
+ node = xmlNewChild(root_node, NULL, BAD_CAST "Model",
NULL);
+ }else{
+ node = (xmlNodePtr)xmlnode;
+ xmlNodeSetName(node, xmlCharStrdup("Model"));
+ //node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST
"Ranger", NULL);
+ //root_node = (xmlNodePtr)parent;
+ }
+
+
+ std::string res;
+ char temp[128];
+ 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);
+ res.append(temp);
+
+ }
+
+
+ sprintf(str,"%s",t.String().c_str());
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Time", BAD_CAST tmp);
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "fiducial");
+
+ tmp = ConvertInput(name.c_str(),MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
+
+ tmp = ConvertInput(res.c_str(), MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Targets", BAD_CAST tmp);
+
+ if(xmlnode == NULL){
+ xmlBufferPtr buf = xmlBufferCreate();
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc,node, 0, 1);
+
+ response = (const char*) buf->content;
+ puts(response.c_str());
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+ }
+
+
+ }
+
}
void
-WebSim::GetXMLModelExtent(const std::string& name,
+WebSim::GetModelExtent(const std::string& name,
double& x,
double& y,
double& z,
Pose& center,
- std::string& response)
+ Format format,
+ std::string& response,
+ void* xmlnode)
{
-
- xmlTextWriterPtr writer;
- xmlBufferPtr buf;
- xmlChar *tmp;
- char str[1024];
+ 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)",
+ 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)",
+ name.c_str(), x, y, z, center.x,
center.y, center.z, center.r, center.p, center.a);
- buf = xmlBufferCreate();
- writer = xmlNewTextWriterMemory(buf, 0);
+ response = buf;
+ }else if(format == XML){
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlNodePtr node;
+ xmlChar *tmp;
+ char str[128];
+
+ if(xmlnode == NULL){
+ puts("no parent\n");
+ 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);
+ }else{
+ node = (xmlNodePtr)xmlnode;
+ xmlNodeSetName(node, xmlCharStrdup("ModelExtent"));
+ //node = xmlNewChild((xmlNodePtr)parent, NULL, BAD_CAST
"ModelExtent", NULL);
+ //root_node = (xmlNodePtr)parent;
+ }
+
+
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST "extent");
- xmlTextWriterStartElement(writer, BAD_CAST "Data");
-
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Type", BAD_CAST "extent");
+ tmp = ConvertInput(name.c_str(),MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST tmp);
- tmp = ConvertInput(name.c_str(),MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Model", BAD_CAST tmp);
+ sprintf(str,"%.3f",x);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "X", BAD_CAST tmp);
- xmlTextWriterStartElement(writer, BAD_CAST "ModelExtent");
-
-
- sprintf(str,"%.3f",x);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "X", BAD_CAST tmp);
-
- sprintf(str,"%.3f",y);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Y", BAD_CAST tmp);
+ sprintf(str,"%.3f",y);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Y", BAD_CAST tmp);
- sprintf(str,"%.3f",z);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Z", BAD_CAST tmp);
+ sprintf(str,"%.3f",z);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Z", BAD_CAST tmp);
-
sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",center.x,center.y,center.z,center.r,center.p,center.a);
- tmp = ConvertInput(str,MY_ENCODING);
- xmlTextWriterWriteAttribute(writer, BAD_CAST "Origin", BAD_CAST tmp);
-
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterEndElement(writer);
+
sprintf(str,"%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",center.x,center.y,center.z,center.r,center.p,center.a);
+ tmp = ConvertInput(str,MY_ENCODING);
+ xmlNewProp(node, BAD_CAST "Origin", BAD_CAST tmp);
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter(writer);
-
- puts((const char*) buf->content);
+ if(xmlnode == NULL){
+ xmlBufferPtr buf = xmlBufferCreate();
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc,node, 0, 1);
- response = (const char*) buf->content;
-
- xmlBufferFree(buf);
+ response = (const char*) buf->content;
+ puts(response.c_str());
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+ }
+ }
+
+}
+bool
+WebSim::GetModelTree(const std::string& model,Format format, std::string&
response, bool everything){
+ if(format == XML){
+ xmlNodePtr root_node = NULL;
+ xmlDocPtr doc = NULL;
+ xmlBufferPtr buf;
+
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ buf = xmlBufferCreate();
+ root_node = xmlNewNode(NULL, BAD_CAST "ModelTree");
+ xmlDocSetRootElement(doc, root_node);
+
+ if(GetModelTreeXML(model, root_node, everything)){
+
+ xmlKeepBlanksDefault(0);
+ xmlNodeDump(buf, doc, root_node, 0, 1);
+ response = (const char*) buf->content;
+ }else{
+ response = "Error in generating model tree.\n";
+
+ }
+
+ xmlBufferFree(buf);
+ xmlFreeDoc(doc);
+
+ std::string out = "Model Tree:\n " + response + "\n";
+ puts(out.c_str());
+
+ return true;
+
+ }else if(format == TEXT){
+
+ std::string str,type;
+ GetModelType(model, type);
+ str+= model + "("+type+")"+ "\n";
+ std::vector<std::string> children;
+ GetModelChildren(model, children);
+ for(unsigned int i=0; i<children.size(); i++){
+
+ std::string sub;
+ GetModelTree(children[i], TEXT, sub, false);
+ str += sub + "\n";
+ }
+
+ response = str;
+ return false;
+ }
+
+ return false;
}
+
+bool
+WebSim::GetModelTreeXML(const std::string& model, void* xmlparent, bool
everything){
+
+ std::string res;
+ xmlNodePtr node;
+
+ if(!xmlparent){
+ printf("Invalid xmlNode pointer. \n");
+ return false;
+ }
+
+ if(model != ""){
+
+ node = xmlNewChild((xmlNodePtr)xmlparent, NULL,
BAD_CAST "Model", NULL);
+
+ bool flag = false;
+ std::string type;
+
+ if(everything){
+ std::string error;
+ flag = !GetModelData(model, error, XML, node);
+
+ }
+
+ if(!everything || flag){
+
+ GetModelType(model, type);
+ xmlNodeSetName(node, xmlCharStrdup("Model"));
+ xmlNewProp(node, BAD_CAST "Name", BAD_CAST
model.c_str());
+ xmlNewProp(node, BAD_CAST "Type", BAD_CAST
type.c_str());
+ }
+
+ }else
+ node = (xmlNodePtr) xmlparent;
+
+ std::vector<std::string> children;
+ GetModelChildren(model, children);
+ for(unsigned int i=0;i<children.size();i++)
+ GetModelTreeXML(children[i], node, everything);
+
+
+
+ return true;
+
+}
+
xmlChar *
ConvertInput(const char *in, const char *encoding)
{
@@ -1001,6 +1139,7 @@
int response_code;
std::string response_string;
std::string model, prop, action, response;
+ puts(req->uri);
if(!obj->ParseURI(model, prop, action, req->uri, response))
{
response_code = 400;
@@ -1017,6 +1156,8 @@
response_string = "OK";
}
+ //puts(response.c_str());
+
evbuffer_add_printf(eb, "%s\n", response.c_str());
evhttp_send_reply(req, response_code, response_string.c_str(), eb);
evbuffer_free(eb);
@@ -1031,27 +1172,71 @@
const std::string uri,
std::string& response)
{
+ //puts(uri.c_str());
// Remove the query args
std::vector<std::string> uri_parts;
StringSplit(uri, uri_parts, "?");
assert(uri_parts.size() > 0);
std::string bare_uri = uri_parts[0];
- // We require 3 path components: model/property/action
+
StringSplit(bare_uri, uri_parts, "/");
+
+ //puts("parts:");
+ /*for(int j=0;j<uri_parts.size();j++)
+ puts(uri_parts[j].c_str());
-
- // otherwise there should be 4 parts, with the first one empty
- if(uri_parts.size() != 4)
+ puts("Here I am!");*/
+ if(uri_parts.size() < 2)
{
- response = "Must be 3 slash-separated parts in the URI";
- return false;
+ // return true, then generate the welcome html
+ return false;
}
+
+ // example: http://localhost:8000/viz
+ if(uri_parts.size() ==2){
+
+ //puts("1 Here I am!");
+ model = uri_parts[1];
+ prop = "";
+ action = "";
+ //puts("1.1 Here I am!");
+ return true;
+ }
- model = uri_parts[1];
- prop = uri_parts[2];
- action = uri_parts[3];
+ // example: http://localhost:8000/viz/applet.class
+ if(uri_parts.size() ==3){
+
+ //puts("2 Here I am!");
+
+ model = uri_parts[1];
+ prop = uri_parts[2];
+ action = "";
+ return true;
+ }
+
+ //puts("3 here I am");
+ unsigned int size = uri_parts.size();
+ unsigned int modelendindex = 0;
+
+ if(uri_parts[size-1] == "get" || uri_parts[size-1]== "set"){
+ action = uri_parts[size-1];
+ modelendindex = size-3;
+ }
+ else{
+ action = "get";
+ modelendindex = size-2;
+ }
+
+ prop = uri_parts[modelendindex+1];
+
+ for(unsigned int i=1;i <= modelendindex;i++){
+ model += uri_parts[i];
+ if(i!=modelendindex)
+ model += ".";
+ }
+
return true;
}
Modified: code/websim/src/websim.hh
===================================================================
--- code/websim/src/websim.hh 2009-06-19 07:12:55 UTC (rev 7860)
+++ code/websim/src/websim.hh 2009-06-19 22:31:41 UTC (rev 7861)
@@ -41,14 +41,19 @@
// GLib-2.0
#include <glib.h>
+
+
namespace websim
{
+enum Format { TEXT=0, XML };
+
class Pose;
class Velocity;
class Acceleration;
class Time;
class Bounds;
+class Fiducial;
class WebSim
{
@@ -72,11 +77,59 @@
std::string& response) = 0;
virtual bool DeleteModel(const std::string& name,
std::string& response) = 0;
+
+ /** Gets the type of the model from simulation.
+
+ @param name The name of the model
+ @param tyep the type of the model
+
+ @returns TRUE if the method is successful.
+ */
+ virtual bool GetModelType(const std::string& name, std::string& type) = 0;
+
+ /** Gets the data of the model. If the format is XML and a valid xmlNode is
passed,
+ the data will be added to the xmlNode, otherwise the text/xml will be
put in
+ the response parameter.
+
+ @param name The name of the model
+ @param response the output string containing data in text/xml format
+ @param format specifies the format of response (text or xml)
+ @param xmlnode the xmlNode pointer of this model
+
+ @returns TRUE if the method is successful.
+ */
+ virtual bool GetModelData(const std::string& name,
+
std::string& response,
+ Format
format,
+ void*
xmlnode ) = 0;
+
+ /** Gets the PVA of the model.
+
+ @param name The name of the model
+ @param p position
+ @param v velocity
+ @param a acceleration
+ @param response the error message
+
+ @returns TRUE if the method is successful and FALSE otherwise.
+ */
virtual bool SetModelPVA(const std::string& name,
const
Pose& p,
const
Velocity& v,
const
Acceleration& a,
std::string& response) = 0;
+
+
+ /** Gets PVA of the model.
+
+ @param name The name of the model
+ @param t the time of simulation returned by the method
+ @param p position
+ @param v velocity
+ @param a acceleration
+
+ @returns TRUE if the method is successful anf FALSE otherwise.
+ */
virtual bool GetModelPVA(const std::string& name,
Time& t,
Pose& p,
@@ -84,37 +137,52 @@
Acceleration& a,
std::string& response) = 0;
- virtual bool GetLaserData(const std::string& name,
- Time& t,
-
uint32_t& resolution,
- double&
fov,
- Pose& p,
-
std::vector<double>& ranges,
-
std::string& response) = 0;
-
-
- virtual bool GetRangerData(const std::string& name,
- Time& t,
-
std::vector<Pose>& p,
-
std::vector<double>& ranges,
-
std::string& response) = 0;
-
-
-
-
- virtual bool GetModelExtent(const std::string& name,
+ /** Gets the extent and center of the model
+
+ @param name The name of the model
+ @param bx length
+ @param by width
+ @param bz height
+ @param center the center of the model
+
+ @returns TRUE if the method is successful.
+ */
+ virtual bool GetModelExtent(const std::string& name,
double&
bx,
double&
by,
double&
bz,
Pose&
center,
std::string& response) = 0;
- virtual bool GetNumberOfRobots(unsigned int& n) = 0;
-
- virtual bool GetSayStrings(std::vector<std::string>& sayings) = 0;
+
- /** Get the current simulation time */
+ /** Gets the tree of the model. If no model is specified as input,
+ the tree of the world will be generated.
+
+ @param name The name of the model
+ @param response the output string containing the tree in text/xml format
+ @param format specifies the format of response (text or xml)
+
+ @returns TRUE if the method is successful.
+ */
+ bool GetModelTree(const std::string& model, Format format, std::string&
response, bool everything);
+
+ /** Get the current simulation time
+
+ @returns time of simulation */
virtual Time GetTime() = 0;
+
+
+ /** Sets the PVA of the model.
+
+ @param name The name of the model
+ @param p position
+ @param v velocity
+ @param a acceleration
+ @param response the error message
+
+ @returns TRUE if the method is successful and FALSE otherwise.
+ */
bool SetPuppetPVA( const std::string& name,
Pose& p,
Velocity& v,
@@ -140,6 +208,14 @@
// Static, so that it can be passed as a callback to libevent
static void EventCallback(evhttp_request* req, void* arg);
+ /** Gets the uri parameters.
+
+ @param value the output variable
+ @param query_args the query structure
+ @param key the name of the parameter
+
+ @returns TRUE if a parameter with the given key exists.
+ */
bool GetValue( std::string& value,
struct evkeyvalq* query_args,
const std::string& key);
@@ -150,14 +226,14 @@
std::string& response);
bool HandleSimRequest(const std::string& prop,
const
std::string& action,
- bool
xmlresponse,
+ Format format,
struct
evkeyvalq* kv,
std::string&
response);
bool HandleModelRequest(const std::string& model,
const
std::string& prop,
const
std::string& action,
- bool
xmlresponse,
- struct
evkeyvalq* kv,
+ Format format,
+ struct
evkeyvalq* kv,
std::string&
response);
bool ParseURI(std::string& model,
std::string& prop,
@@ -166,62 +242,147 @@
std::string& response);
void DeleteKeyVal(struct evkeyvalq* query_args);
- void GetTextPVA(const std::string& name,
+
+
+ /** Puts the PVA data 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.
+
+ @param name the name of the model
+ @param p position
+ @param v velocity
+ @param a acceleration
+ @param format the output format
+ @param response the string output
+ @param xmlnode the xml node output
+*/
+ void GetPVA(const std::string& name,
Time& t,
const
Pose& p,
const
Velocity& v,
const
Acceleration& a,
-
std::string& response);
+ Format
format,
+
std::string& response,
+ void*
xmlnode );
+
+
+ /** Puts the laser data 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.
- void GetXMLPVA(const std::string& name,
+ @param name the name of the model
+ @param t time of the simulation
+ @param resolution the resolution of the laser
+ @param fov the field of view of the laser
+ @param p position of the laser model
+ @param ranges the data of the laser
+ @param format the output format
+ @param response the string output
+ @param xmlnode the xml node output
+*/
+ void GetLaserData(const std::string& name,
Time& t,
- const
Pose& p,
- const
Velocity& v,
- const
Acceleration& a,
-
std::string& response);
-
- void GetTextLaserData(const std::string& name,
- Time& t,
uint32_t& resolution,
double&
fov,
- Pose& p,
-
+ Pose&
p,
std::vector<double>& ranges,
-
std::string& response);
+ Format
format,
+
std::string& response,
+ void*
xmlnode );
-
- void GetXMLLaserData(const std::string& name,
+
+
+
+
+ /** Puts the ranger data 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.
+
+ @param name the name of the model
+ @param t time of the simulation
+ @param p positions of the ranger sensors
+ @param ranges the data of the ranger sensor
+ @param format the output format
+ @param response the string output
+ @param xmlnode the xml node output
+*/
+ void GetRangerData(const std::string& name,
Time& t,
-
uint32_t& resolution,
- double&
fov,
- Pose& p,
-
std::vector<double>& ranges,
-
std::string& response);
- void GetTextRangerData(const std::string& name,
- Time& t,
std::vector<Pose>& p,
std::vector<double>& ranges,
-
std::string& response);
+ Format
format,
+
std::string& response,
+ void*
xmlnode );
-
- void GetXMLRangerData(const std::string& name,
+ /** Puts the fiducial data 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.
+
+ @param name the name of the model
+ @param t time of the simulation
+ @param f the detected targets
+ @param format the output format
+ @param response the string output
+ @param xmlnode the xml node output
+*/
+ void GetFiducialData(const std::string& name,
Time& t,
-
std::vector<Pose>& p,
-
std::vector<double>& ranges,
-
std::string& response);
- void GetTextModelExtent(const std::string& name,
+
std::vector<Fiducial>& f,
+ Format
format,
+
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
+ 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.
+
+ @param name the name of the model
+ @param bx length
+ @param by width
+ @param bz height
+ @param center center of the model
+ @param format output format
+ @param response the string output
+ @param xmlnode the xml node output
+*/
+ void GetModelExtent(const std::string& name,
double&
x,
double&
y,
double&
z,
Pose&
center,
-
std::string& response);
+ Format
format,
+
std::string& response,
+ void*
xmlnode );
- void GetXMLModelExtent(const std::string&,
- double&
x,
- double&
y,
- double&
z,
- Pose&
center,
-
std::string& response);
+
+ /** Gets the children of the model.
+
+ @param name the name of the model
+ @param children the names of the children
+
+ @returns TRUE if successful.
+*/
+ virtual bool GetModelChildren(const std::string& model,
+
std::vector<std::string>& children) = 0;
+
+ /** Adds the model tree of the specified model to the xml node. If dumpdata
parameter if true,
+ the data od the models are also included in the tree, otherwise, the
tree will only contain
+ the name of the models.
+
+ @param name the name of the model
+ @param xmlparent parent node of the model
+ @param dumpdata If TRUE, the data of the models will be included in the
tree.
+
+ @returns TRUE if successful.
+*/
+ bool GetModelTreeXML(const std::string& model, void* xmlparent, bool
everything);
+
+
// forward decare
class Confederate;
@@ -400,4 +561,13 @@
Bounds() : max(0), min(0) { /* empty*/ }
};
+class Fiducial
+{
+ public:
+ double range;
+ double bearing;
+ int id;
+ 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.
------------------------------------------------------------------------------
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