Revision: 7438
http://playerstage.svn.sourceforge.net/playerstage/?rev=7438&view=rev
Author: gerkey
Date: 2009-03-10 08:22:13 +0000 (Tue, 10 Mar 2009)
Log Message:
-----------
Fixed deadlock on libgazebo tick system, got other stuff working
Modified Paths:
--------------
code/branches/federation/gazebo/libgazebo/SimIface.cc
code/branches/federation/gazebo/libgazebo/gazebo.h
code/branches/federation/gazebo/server/World.cc
code/branches/federation/gazebo/webgazebo/WebGazebo.cc
code/branches/federation/gazebo/webgazebo/WebGazebo.hh
code/branches/federation/gazebo/webgazebo/main.cc
Modified: code/branches/federation/gazebo/libgazebo/SimIface.cc
===================================================================
--- code/branches/federation/gazebo/libgazebo/SimIface.cc 2009-03-10
07:45:57 UTC (rev 7437)
+++ code/branches/federation/gazebo/libgazebo/SimIface.cc 2009-03-10
08:22:13 UTC (rev 7438)
@@ -18,8 +18,6 @@
{
this->goAckThread = NULL;
- this->goAckCond = NULL;
- this->mutex = NULL;
}
@@ -27,23 +25,10 @@
/// Destroy an interface
SimulationIface::~SimulationIface()
{
- if (this->mutex)
- delete this->mutex;
- this->mutex = NULL;
-
if (this->goAckThread)
delete this->goAckThread;
this->goAckThread = NULL;
- // Deleting this condition causes and error...no time to debug this.
- /*if (this->goAckCond)
- {
- printf("Delete the condition\n");
- delete this->goAckCond;
- printf("Done deleting the condition\n");
- }*/
- this->goAckCond = NULL;
-
this->data = NULL;
}
@@ -90,8 +75,6 @@
// then signals the goAckSignal
if (this->goAckThread == NULL)
{
- this->mutex = new boost::mutex;
- this->goAckCond = new boost::condition;
this->goAckThread = new boost::thread(
boost::bind(&SimulationIface::BlockThread, this));
usleep(100);
@@ -104,11 +87,6 @@
while (true)
{
- boost::mutex::scoped_lock lock(*this->mutex);
-
- // Wait on a condition that signals when the thread should run
- this->goAckCond->wait(lock);
-
// Wait for Gazebo to send a Post
this->GoAckWait();
Modified: code/branches/federation/gazebo/libgazebo/gazebo.h
===================================================================
--- code/branches/federation/gazebo/libgazebo/gazebo.h 2009-03-10 07:45:57 UTC
(rev 7437)
+++ code/branches/federation/gazebo/libgazebo/gazebo.h 2009-03-10 08:22:13 UTC
(rev 7438)
@@ -476,11 +476,7 @@
this->Unlock();
{
- boost::mutex::scoped_lock lock(*this->mutex);
-
- // Set the time the thread should block for
- this->blockTimeUs = us;
-
+ //boost::mutex::scoped_lock lock(*this->mutex);
if (this->currentConnection.connected())
this->currentConnection.disconnect();
@@ -488,8 +484,6 @@
// (below) finishes waiting
this->currentConnection = this->goAckSignal.connect( subscriber
);
}
-
- this->goAckCond->notify_one();
}
/// \brief Pause the simulation
@@ -522,14 +516,10 @@
public: void GoAckPost();
private: void BlockThread();
- private: unsigned int blockTimeUs;
private: boost::signal<void (void)> goAckSignal;
private: boost::signals::connection currentConnection;
private: boost::thread *goAckThread;
- private: boost::condition *goAckCond;
- private: boost::mutex *mutex;
-
/// Pointer to the simulation data
public: SimulationData *data;
};
Modified: code/branches/federation/gazebo/server/World.cc
===================================================================
--- code/branches/federation/gazebo/server/World.cc 2009-03-10 07:45:57 UTC
(rev 7437)
+++ code/branches/federation/gazebo/server/World.cc 2009-03-10 08:22:13 UTC
(rev 7438)
@@ -207,12 +207,13 @@
{
//printf("SimTime[%f] PauseTime[%f]\n",
Simulator::Instance()->GetSimTime(), this->simPauseTime);
+ this->simPauseTime = 0;
+ Simulator::Instance()->SetPaused(true);
+
// Tell the simiface that it's okay to trigger the go ack
this->simIface->GoAckPost();
- this->simPauseTime = 0;
- Simulator::Instance()->SetPaused(true);
}
else
{
Modified: code/branches/federation/gazebo/webgazebo/WebGazebo.cc
===================================================================
--- code/branches/federation/gazebo/webgazebo/WebGazebo.cc 2009-03-10
07:45:57 UTC (rev 7437)
+++ code/branches/federation/gazebo/webgazebo/WebGazebo.cc 2009-03-10
08:22:13 UTC (rev 7438)
@@ -39,9 +39,6 @@
// TODO:
// - make ghost models not collide, fall, etc.
-// - add SetState
-// - expose URI command to run for 1 tick
-// - do performance test
WebGazebo::WebGazebo(const std::string& fedfile,
const std::string& host, unsigned short port,
@@ -262,13 +259,17 @@
void
WebGazebo::GoCallback()
{
- puts("GoCallback");
+ this->goCond.notify_one();
}
bool
WebGazebo::Go(double t)
{
- this->simIface->Go((unsigned int)rint(t/1e6),
+ unsigned int us = (unsigned int)rint(t*1e6);
+ this->simIface->Go(us,
boost::bind(&WebGazebo::GoCallback, this));
+ // Wait for the callback to fire
+ boost::mutex::scoped_lock lock(this->goMutex);
+ this->goCond.wait(lock);
return true;
}
Modified: code/branches/federation/gazebo/webgazebo/WebGazebo.hh
===================================================================
--- code/branches/federation/gazebo/webgazebo/WebGazebo.hh 2009-03-10
07:45:57 UTC (rev 7437)
+++ code/branches/federation/gazebo/webgazebo/WebGazebo.hh 2009-03-10
08:22:13 UTC (rev 7438)
@@ -67,7 +67,7 @@
private:
double sq_dist_tol, sq_ang_tol;
- boost::condition goMutex;
+ boost::mutex goMutex;
boost::condition goCond;
gazebo::Client *client;
Modified: code/branches/federation/gazebo/webgazebo/main.cc
===================================================================
--- code/branches/federation/gazebo/webgazebo/main.cc 2009-03-10 07:45:57 UTC
(rev 7437)
+++ code/branches/federation/gazebo/webgazebo/main.cc 2009-03-10 08:22:13 UTC
(rev 7438)
@@ -55,6 +55,7 @@
for(;;)
{
wg.Update();
+ wg.Go(1.0);
}
return 0;
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