Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 92

Multiple parameters in subscribe method's callback function

$
0
0
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?

Viewing all articles
Browse latest Browse all 92

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>