Multiple parameters in subscribe method's callback function [closed]
Hi
I'm trying to make a subscription to a topic where the callback function takes 2 parameters, but I can't figure out how to write it. The function I want to call look like this:
void writeOut(const std_msgs::String::ConstPtr& msg, const sound_play::SoundClient& sound)
{
// code here
}
The part where I try to subscribe to the topic looks like this:
int main(int argc, char **argv)
{
ros::init(argc, argv, "name");
ros::NodeHandle n;
sound_play::SoundClient sound;
ros::Subscriber sub = n.subscribe("topic-name",1000,writeOut);
ros::spin();
return 0;
}
I know that I can't just call the writeOut function like this. From searching around, I think I have to use something like boost::bind, but I can't figure out how to use it right.
The code is based on the tutorials, I'm just modifying it a bit.
Any help would be appreciated.
EDIT:
Using boost::bind as described in the answer narrowed the errors down, now I only get this error
'cref' was not declared in this scope
Do I need to use some external library?
cref is part of boost. I updated my answer.