Revision: 8732
http://playerstage.svn.sourceforge.net/playerstage/?rev=8732&view=rev
Author: natepak
Date: 2010-05-29 17:19:24 +0000 (Sat, 29 May 2010)
Log Message:
-----------
Added remove handler function
Modified Paths:
--------------
code/gazebo/branches/simpar/libgazebo/SimIface.cc
code/gazebo/branches/simpar/libgazebo/gz.h
code/gazebo/branches/simpar/plugins/pioneer_spiral.cc
code/gazebo/branches/simpar/server/Handler.cc
code/gazebo/branches/simpar/server/Handler.hh
code/gazebo/branches/simpar/server/Simulator.cc
code/gazebo/branches/simpar/server/Simulator.hh
code/gazebo/branches/simpar/server/World.cc
code/gazebo/branches/simpar/tools/gazebomodel.cc
Modified: code/gazebo/branches/simpar/libgazebo/SimIface.cc
===================================================================
--- code/gazebo/branches/simpar/libgazebo/SimIface.cc 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/libgazebo/SimIface.cc 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -1020,4 +1020,20 @@
this->Unlock();
}
+////////////////////////////////////////////////////////////////////////////////
+/// Remove a handler
+void SimulationIface::RemoveHandler(const std::string &name)
+{
+ this->Lock(1);
+ this->data->responseCount = 0;
+ SimulationRequestData *request;
+
+ request = &(this->data->requests[this->data->requestCount++]);
+ request->type = SimulationRequestData::REMOVE_HANDLER;
+ memset(request->strValue, 0, 512);
+ strncpy(request->strValue, name.c_str(), 512);
+ request->strValue[511] = '\0';
+
+ this->Unlock();
+}
Modified: code/gazebo/branches/simpar/libgazebo/gz.h
===================================================================
--- code/gazebo/branches/simpar/libgazebo/gz.h 2010-05-29 17:04:31 UTC (rev
8731)
+++ code/gazebo/branches/simpar/libgazebo/gz.h 2010-05-29 17:19:24 UTC (rev
8732)
@@ -455,7 +455,8 @@
GET_STEP_TYPE,
APPLY_FORCE,
APPLY_TORQUE,
- ADD_HANDLER
+ ADD_HANDLER,
+ REMOVE_HANDLER
};
public: Type type;
@@ -689,6 +690,9 @@
/// \brief Add a handler
public: void AddHandler(const std::string &name);
+ /// \brief Remove a handler
+ public: void RemoveHandler(const std::string &name);
+
private: void BlockThread();
/// \brief Wait for a return message
Modified: code/gazebo/branches/simpar/plugins/pioneer_spiral.cc
===================================================================
--- code/gazebo/branches/simpar/plugins/pioneer_spiral.cc 2010-05-29
17:04:31 UTC (rev 8731)
+++ code/gazebo/branches/simpar/plugins/pioneer_spiral.cc 2010-05-29
17:19:24 UTC (rev 8732)
@@ -11,6 +11,8 @@
PioneerSpiral::~PioneerSpiral()
{
+ World::Instance()->DisconnectWorldUpdateStartSignal(
+ boost::bind(&PioneerSpiral::UpdateCB, this));
}
void PioneerSpiral::Load()
Modified: code/gazebo/branches/simpar/server/Handler.cc
===================================================================
--- code/gazebo/branches/simpar/server/Handler.cc 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/server/Handler.cc 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -22,8 +22,17 @@
Handler::Handler() {}
Handler::~Handler() {}
+////////////////////////////////////////////////////////////////////////////////
+/// Get the name of the handler
+std::string Handler::GetName() const
+{
+ return this->name;
+}
+
+
Handler *Handler::Create(const std::string &plugin)
{
+ Handler *result = NULL;
struct stat st;
bool found = false;
std::string fullname;
@@ -55,7 +64,7 @@
}
// Register the new controller.
- return registerFunc();
+ result = registerFunc();
#elif HAVE_LTDL
@@ -93,7 +102,7 @@
}
// Register the new controller.
- return registerFunc();
+ result = registerFunc();
#else // HAVE_LTDL
@@ -101,5 +110,7 @@
#endif // HAVE_LTDL
+ result->name = plugin;
+ return result;
}
Modified: code/gazebo/branches/simpar/server/Handler.hh
===================================================================
--- code/gazebo/branches/simpar/server/Handler.hh 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/server/Handler.hh 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -13,7 +13,12 @@
public: virtual ~Handler();
public: virtual void Load() = 0;
+ /// \brief Get the name of the handler
+ public: std::string GetName() const;
+
public: static Handler *Create(const std::string &name);
+
+ protected: std::string name;
};
}
Modified: code/gazebo/branches/simpar/server/Simulator.cc
===================================================================
--- code/gazebo/branches/simpar/server/Simulator.cc 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/server/Simulator.cc 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -309,15 +309,6 @@
}
////////////////////////////////////////////////////////////////////////////////
-// Add a handler
-void Simulator::AddHandler(const std::string &name)
-{
- Handler *handler = Handler::Create(name);
- handler->Load();
- this->handlers.push_back(handler);
-}
-
-////////////////////////////////////////////////////////////////////////////////
/// Initialize the simulation
void Simulator::Init()
{
@@ -770,3 +761,27 @@
{
return this->state;
}
+
+////////////////////////////////////////////////////////////////////////////////
+// Add a handler
+void Simulator::AddHandler(const std::string &name)
+{
+ Handler *handler = Handler::Create(name);
+ handler->Load();
+ this->handlers.push_back(handler);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Add a handler
+void Simulator::RemoveHandler(const std::string &name)
+{
+ std::vector<Handler*>::iterator iter;
+ for (iter = this->handlers.begin(); iter != this->handlers.end(); iter++)
+ {
+ if ((*iter)->GetName() == name)
+ {
+ delete (*iter);
+ this->handlers.erase(iter);
+ }
+ }
+}
Modified: code/gazebo/branches/simpar/server/Simulator.hh
===================================================================
--- code/gazebo/branches/simpar/server/Simulator.hh 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/server/Simulator.hh 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -174,6 +174,9 @@
/// \brief Add a handler
public: void AddHandler(const std::string &plugin);
+ /// \brief Remove a handler
+ public: void RemoveHandler(const std::string &plugin);
+
/// \brief Connect a boost::slot the the pause signal
public: template<typename T>
void ConnectPauseSignal( T subscriber )
Modified: code/gazebo/branches/simpar/server/World.cc
===================================================================
--- code/gazebo/branches/simpar/server/World.cc 2010-05-29 17:04:31 UTC (rev
8731)
+++ code/gazebo/branches/simpar/server/World.cc 2010-05-29 17:19:24 UTC (rev
8732)
@@ -1602,6 +1602,12 @@
break;
}
+ case libgazebo::SimulationRequestData::REMOVE_HANDLER:
+ {
+ Simulator::Instance()->RemoveHandler(req->strValue);
+ break;
+ }
+
case libgazebo::SimulationRequestData::GO:
{
int sec = req->runTime/1000;
Modified: code/gazebo/branches/simpar/tools/gazebomodel.cc
===================================================================
--- code/gazebo/branches/simpar/tools/gazebomodel.cc 2010-05-29 17:04:31 UTC
(rev 8731)
+++ code/gazebo/branches/simpar/tools/gazebomodel.cc 2010-05-29 17:19:24 UTC
(rev 8732)
@@ -128,6 +128,8 @@
}
}
+
//////////////////////////////////////////////////////////////////////////////
+ // Add a handler
public: void AddHandler()
{
if (this->params.size() < 2)
@@ -140,6 +142,20 @@
}
//////////////////////////////////////////////////////////////////////////////
+ // Remove a handler
+ public: void RemoveHandler()
+ {
+ if (this->params.size() < 2)
+ std::cerr << "Missing pluing filename\n";
+ else
+ {
+ this->simIface->RemoveHandler(params[1]);
+ }
+
+ }
+
+
+
//////////////////////////////////////////////////////////////////////////////
// Spawn a new model into the world
public: void Spawn()
{
@@ -237,8 +253,10 @@
this->Spawn();
else if (params[0] == "set")
this->Set();
- else if (params[0] == "handler")
+ else if (params[0] == "add_handler")
this->AddHandler();
+ else if (params[0] == "remove_handler")
+ this->RemoveHandler();
else
std::cerr << "Unknown command[" << this->params[0] << "]\n";
}
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