Subscriber with member callback function
I am trying to subscribe to the model msgs in gazebo, however I cannot bind the callback function in a correct way. This is the code:
class WorldInterface : public WorldPlugin
{
public:
void messageReceived1(const msgs::Model& _msg)
{
std::cout << "Got the message!" << std::endl;
modelLoaded_ = true;
}
void Load(physics::WorldPtr _parent, sdf::ElementPtr _sdf)
{
transport::NodePtr node(new transport::Node());
node->Init();
transport::SubscriberPtr modelSub =
node->Subscribe("~/model/info", std::bind(&gazebo::WorldInterface::messageReceived1, this, _1));
.....
}
};
The error I get is:
error: no matching function for call to ‘gazebo::transport::Node::Subscribe(const char [13], std::_Bind_helper<false, void (gazebo::WorldInterface::*)(const gazebo::msgs::Model&), gazebo::WorldInterface*, boost::arg<1>&>::type)’
node->Subscribe("~/model/info", std::bind(&gazebo::WorldInterface::messageReceived1, this, _1));