Revision: 7433
http://playerstage.svn.sourceforge.net/playerstage/?rev=7433&view=rev
Author: gerkey
Date: 2009-03-10 06:53:56 +0000 (Tue, 10 Mar 2009)
Log Message:
-----------
adding clock support to websim
Modified Paths:
--------------
code/websim/src/websim.cc
code/websim/src/websim.h
Modified: code/websim/src/websim.cc
===================================================================
--- code/websim/src/websim.cc 2009-03-10 06:52:24 UTC (rev 7432)
+++ code/websim/src/websim.cc 2009-03-10 06:53:56 UTC (rev 7433)
@@ -37,7 +37,7 @@
WebSim::WebSim(const std::string& _fedfile,
const std::string& _host,
int _port) :
- fedfile(_fedfile), host(_host), port(_port)
+ fedfile(_fedfile), host(_host), port(_port), tick_count_expected(0)
{
// Set up the HTTP server
// Not sure whether it's safe to do this more that once in one process
@@ -63,7 +63,12 @@
void
WebSim::Update()
{
- event_dispatch();
+ tick_count = 0;
+ do
+ {
+ event_loop(EVLOOP_ONCE);
+ } while(tick_count < tick_count_expected);
+ tick_count = 0;
}
void
@@ -169,6 +174,20 @@
return false;
}
}
+ else if(prop == "clock")
+ {
+ if(action == "tick")
+ {
+ tick_count++;
+ response = "Ticked the clock";
+ return true;
+ }
+ else
+ {
+ response = "ERROR: Unknown action " + action + " for sim/clock";
+ return false;
+ }
+ }
else
{
response = "ERROR: Unknown property " + prop + " for sim";
@@ -185,7 +204,7 @@
{
if(action == "get")
{
- if(prop == "pose")
+ if(prop == "pva")
{
Pose p;
Velocity v;
@@ -326,10 +345,6 @@
}
evbuffer_add_printf(eb, "%s\n", response.c_str());
- /*
- printf("[webgazebo] Sending reply: %d %s\n",
- response_code, response_string.c_str());
- */
evhttp_send_reply(req, response_code, response_string.c_str(), eb);
evbuffer_free(eb);
Modified: code/websim/src/websim.h
===================================================================
--- code/websim/src/websim.h 2009-03-10 06:52:24 UTC (rev 7432)
+++ code/websim/src/websim.h 2009-03-10 06:53:56 UTC (rev 7433)
@@ -57,19 +57,19 @@
// Interface to be implemented by simulators
virtual bool CreateModel(const std::string& name,
const std::string& type,
- std::string& error) = 0;
+ std::string& response) = 0;
virtual bool DeleteModel(const std::string& name,
- std::string& error) = 0;
+ std::string& response) = 0;
virtual bool SetModelPVA(const std::string& name,
const Pose& p,
const Velocity& v,
const Acceleration& a,
- std::string& error) = 0;
+ std::string& response) = 0;
virtual bool GetModelPVA(const std::string& name,
Pose& p,
Velocity& v,
Acceleration& a,
- std::string& error) = 0;
+ std::string& response) = 0;
protected:
void StringSplit(const std::string &s,
@@ -81,6 +81,11 @@
std::string host;
int port;
+ // Number of ticks we require before exiting Update()
+ int tick_count_expected;
+ // Number of ticks we've received since the last Update()
+ int tick_count;
+
struct evhttp* eh;
// Static, so that it can be passed as a callback to libevent
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