Revision: 8780
http://playerstage.svn.sourceforge.net/playerstage/?rev=8780&view=rev
Author: natepak
Date: 2010-06-22 23:00:46 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
Update the tools and added a gazeboplugin tool
Modified Paths:
--------------
code/gazebo/trunk/tools/CMakeLists.txt
code/gazebo/trunk/tools/Toolbase.cc
code/gazebo/trunk/tools/Toolbase.hh
code/gazebo/trunk/tools/gazebobody.cc
code/gazebo/trunk/tools/gazebomodel.cc
Added Paths:
-----------
code/gazebo/trunk/tools/gazeboplugin.cc
Modified: code/gazebo/trunk/tools/CMakeLists.txt
===================================================================
--- code/gazebo/trunk/tools/CMakeLists.txt 2010-06-22 22:59:54 UTC (rev
8779)
+++ code/gazebo/trunk/tools/CMakeLists.txt 2010-06-22 23:00:46 UTC (rev
8780)
@@ -14,19 +14,24 @@
)
-set (sources gazebomodel.cc gazebobody.cc Toolbase.cc)
+set (sources gazebomodel.cc gazebobody.cc gazeboplugin.cc Toolbase.cc)
set_source_files_properties(${sources} PROPERTIES COMPILE_FLAGS "-ggdb -g2
-Wall")
add_executable(gazebomodel gazebomodel.cc Toolbase.cc)
add_executable(gazebobody gazebobody.cc Toolbase.cc)
+add_executable(gazeboplugin gazeboplugin.cc Toolbase.cc)
target_link_libraries(gazebomodel gazebo yaml ${boost_libraries})
target_link_libraries(gazebobody gazebo yaml ${boost_libraries})
+target_link_libraries(gazeboplugin gazebo yaml ${boost_libraries})
set_target_properties(gazebomodel PROPERTIES SKIP_BUILD_RPATH TRUE)
set_target_properties(gazebomodel PROPERTIES LINK_FLAGS "${LINK_FLAGS}
${gazebo_lflags}")
set_target_properties(gazebobody PROPERTIES SKIP_BUILD_RPATH TRUE)
set_target_properties(gazebobody PROPERTIES LINK_FLAGS "${LINK_FLAGS}
${gazebo_lflags}")
+set_target_properties(gazeboplugin PROPERTIES SKIP_BUILD_RPATH TRUE)
+set_target_properties(gazeboplugin PROPERTIES LINK_FLAGS "${LINK_FLAGS}
${gazebo_lflags}")
-install (TARGETS gazebomodel gazebobody DESTINATION
${CMAKE_INSTALL_PREFIX}/bin)
+
+install (TARGETS gazebomodel gazebobody gazeboplugin DESTINATION
${CMAKE_INSTALL_PREFIX}/bin)
Modified: code/gazebo/trunk/tools/Toolbase.cc
===================================================================
--- code/gazebo/trunk/tools/Toolbase.cc 2010-06-22 22:59:54 UTC (rev 8779)
+++ code/gazebo/trunk/tools/Toolbase.cc 2010-06-22 23:00:46 UTC (rev 8780)
@@ -47,9 +47,9 @@
this->ParseYAML();
- this->client = new gazebo::Client();
- this->simIface = new gazebo::SimulationIface();
- this->factoryIface = new gazebo::FactoryIface();
+ this->client = new libgazebo::Client();
+ this->simIface = new libgazebo::SimulationIface();
+ this->factoryIface = new libgazebo::FactoryIface();
try
{
Modified: code/gazebo/trunk/tools/Toolbase.hh
===================================================================
--- code/gazebo/trunk/tools/Toolbase.hh 2010-06-22 22:59:54 UTC (rev 8779)
+++ code/gazebo/trunk/tools/Toolbase.hh 2010-06-22 23:00:46 UTC (rev 8780)
@@ -41,9 +41,9 @@
/// \brief Print all the commands to stdout
protected: void PrintCommands(std::string prefix);
- protected: gazebo::Client *client;
- protected: gazebo::SimulationIface *simIface;
- protected: gazebo::FactoryIface *factoryIface;
+ protected: libgazebo::Client *client;
+ protected: libgazebo::SimulationIface *simIface;
+ protected: libgazebo::FactoryIface *factoryIface;
protected: std::map<std::string, std::string> yamlValues;
protected: std::vector<std::string> params;
Modified: code/gazebo/trunk/tools/gazebobody.cc
===================================================================
--- code/gazebo/trunk/tools/gazebobody.cc 2010-06-22 22:59:54 UTC (rev
8779)
+++ code/gazebo/trunk/tools/gazebobody.cc 2010-06-22 23:00:46 UTC (rev
8780)
@@ -15,7 +15,7 @@
public: void PrintBody(std::string name, std::string prefix)
{
std::string type;
- gazebo::Pose pose;
+ libgazebo::Pose pose;
this->simIface->GetEntityType(name, type);
if (type == "body")
Modified: code/gazebo/trunk/tools/gazebomodel.cc
===================================================================
--- code/gazebo/trunk/tools/gazebomodel.cc 2010-06-22 22:59:54 UTC (rev
8779)
+++ code/gazebo/trunk/tools/gazebomodel.cc 2010-06-22 23:00:46 UTC (rev
8780)
@@ -1,5 +1,9 @@
#include <iostream>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
@@ -14,7 +18,7 @@
public: void PrintModel(std::string name, std::string prefix)
{
std::string type;
- gazebo::Pose pose;
+ libgazebo::Pose pose;
std::cout << prefix << name << "\n";
@@ -70,8 +74,8 @@
{
std::string name = params[i];
std::string type;
- gazebo::Pose pose;
- gazebo::Vec3 linearVel, linearAccel, angularVel, angularAccel;
+ libgazebo::Pose pose;
+ libgazebo::Vec3 linearVel, linearAccel, angularVel, angularAccel;
unsigned int paramCount;
if (!this->simIface->GetModelType(name, type))
@@ -128,6 +132,7 @@
}
}
+
//////////////////////////////////////////////////////////////////////////////
// Spawn a new model into the world
public: void Spawn()
@@ -193,7 +198,7 @@
{
std::vector<std::string> strs;
boost::split(strs, iter->second, boost::is_any_of("\t "));
- gazebo::Vec3 vec( boost::lexical_cast<float>(strs[0]),
+ libgazebo::Vec3 vec( boost::lexical_cast<float>(strs[0]),
boost::lexical_cast<float>(strs[1]),
boost::lexical_cast<float>(strs[2]));
Copied: code/gazebo/trunk/tools/gazeboplugin.cc (from rev 8771,
code/gazebo/branches/simpar/tools/gazeboplugin.cc)
===================================================================
--- code/gazebo/trunk/tools/gazeboplugin.cc (rev 0)
+++ code/gazebo/trunk/tools/gazeboplugin.cc 2010-06-22 23:00:46 UTC (rev
8780)
@@ -0,0 +1,123 @@
+#include <iostream>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <boost/regex.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include "Toolbase.hh"
+
+class PluginTool : public Toolbase
+{
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Print out a list of all the plugins
+ public: void List()
+ {
+ unsigned int numPlugins = 0;
+
+ std::string prefix = "";
+ if (!this->simIface->GetPluginCount(numPlugins))
+ std::cerr << "Unable to get the plugin count\n";
+
+ for (unsigned int i=0; i < numPlugins; i++)
+ {
+ std::string name;
+ if (!this->simIface->GetPluginName(i, name))
+ std::cerr << "Unable to get plugin[" << i << "]\n";
+ else
+ std::cout << name << "\n";
+ }
+ }
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Remove a plugin from the simulation
+ public: void RemovePlugin()
+ {
+ if (this->params.size() < 2)
+ std::cerr << "Missing pluing filename\n";
+ else
+ {
+ std::string plugin;
+ struct stat buf;
+ if (stat(params[1].c_str(),&buf) == 0)
+ plugin = std::string(getenv("PWD")) + "/" + params[1];
+ else
+ plugin = params[1];
+
+ this->simIface->RemovePlugin(plugin);
+ }
+ }
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Add a handler
+ public: void AddPlugin()
+ {
+ if (this->params.size() < 3)
+ std::cerr << "Must specify a filename and a handle name\n";
+ else
+ {
+ std::string filename, handle;
+ struct stat buf;
+ if (stat(params[1].c_str(),&buf) == 0)
+ filename = std::string(getenv("PWD")) + "/" + params[1];
+ else
+ filename = params[1];
+
+ handle = params[2];
+
+ this->simIface->AddPlugin(filename, handle);
+ }
+
+ }
+
+ public: bool Run()
+ {
+ if (!Toolbase::Run())
+ {
+ if (this->params[0] == "list")
+ this->List();
+ else if (params[0] == "add")
+ this->AddPlugin();
+ else if (params[0] == "remove")
+ this->RemovePlugin();
+ else
+ std::cerr << "Unknown command[" << this->params[0] << "]\n";
+ }
+
+ return true;
+ }
+
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Print out help information
+ public: void Help()
+ {
+ std::cout << "gazeboplugin is a command-line tool for manipulating plugins
in a gazebo world.\n";
+ std::cout << "\n";
+ std::cout << "Usage: gazeboplugin <command> <option_1> ... <option_n>\n";
+ std::cout << "\n";
+
+ std::cout << "Commands:\n";
+
+ this->PrintCommands("gazeboplugin");
+
+ std::cout << "\tgazeboplugin list \t List all the models\n";
+ std::cout << "\tgazeboplugin add \t Add a plugin to the world\n";
+ std::cout << "\tgazeboplugin remove \t Remove a plugin from the world\n";
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Main
+int main(int argc, char **argv)
+{
+ PluginTool tool;
+ tool.Init(argc, argv);
+ tool.Run();
+
+ return 1;
+}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit