Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I solved the problem, here is what I did:

#include <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include <gazebo/common/common.hh>
using namespace std;
namespace gazebo 
{ 
  class systemPlugin : public SystemPlugin 
  {    

    public: void Load(int argc, char ** argv)
    {
      robotName= argv[argc-1];
    }
    private: virtual void Init()
    {

      node=transport::NodePtr(new transport::Node());
      node->Init();
      pub = node->Advertise<msgs::GzString>("~/robotName");

      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          boost::bind(&systemPlugin::OnUpdate, this));      
    }
    private: virtual void OnUpdate()
    {
       msgs::GzString msg;
       msg.set_data(robotName);
       pub->Publish(msg);
    }
    private: event::ConnectionPtr updateConnection;

    transport::NodePtr node;
    transport::PublisherPtr pub;
    string robotName;
 };

  GZ_REGISTER_SYSTEM_PLUGIN(systemPlugin)
}