how to bind a callback to include a MessageEvent [closed]
I am trying to use MessageEvent to get topic information in a callback. While I have referred to the example here
and here
I can't figure out how to use boost::bind to tell the subscriber to give me both the PointCloud message and the MessageEvent. Is there an example of this somewhere? Here is what I have, which is definitely wrong:
sub_cloud_ = nh_.subscribe<sensor_msgs::PointCloud2>
(input_topic_, 1,
boost::bind(&HapticNode::cloudCallback, this, _1, _2));
void HapticNode::cloudCallback(const sensor_msgs::PointCloud2ConstPtr &input,
const ros::MessageEvent<std_msgs::String const>& event)
{
std::string topic;
const std::string& publisher_name = event.getPublisherName();
ros::M_string connection_header = event.getConnectionHeader();
topic = connection_header["topic"];
ROS_INFO("Got a cloud on topic %s in frame %s with %d points!",
topic.c_str(),
input->header.frame_id.c_str(),
input->width*input->height);
}