Calling a callback function in a class method with multiple arguments

asked 2018-09-28 05:26:33 -0600

surabhi96 gravatar image

updated 2018-09-28 10:31:29 -0600

lucasw gravatar image

Hi, I have a callback function as a class method in a nodelet. While the callback function had a single argument

void nodelet_class::ReceiveA1(const sensor_msgs::ImageConstPtr& image)

this is how I called it:

A1_subscriber = it_->subscribe(image_color", 1, boost::bind(&nodelet_class::ReceiveA1, this, _1));

For multiple argument like this:

void nodelet_class::ReceiveA1(const sensor_msgs::ImageConstPtr& image, image_transport::Publisher image_pub_);

how do I use boost::bind? I tried doing something like this:

A1_subscriber = it_->subscribe("image_color", 1, boost::bind(&nodelet_class::ReceiveA1, this, _1, image_pub_A1));

but this resulted in an error. Here, image_pub_A is a publisher object:

image_pub_A1 = it_p_->advertise("image_publish", 1);
edit retag flag offensive close merge delete



What is the error? Put it into the question using the preformatted text option (the 010101 button).

lucasw gravatar image lucasw  ( 2018-09-28 10:43:09 -0600 )edit