[ros-users] NodeHandle.subscribe(...) - callbacks

Peter Müller grandmastermt2000 at yahoo.de
Sun Jul 4 13:10:02 UTC 2010


I have started using ROS recently and played around with it to see how it fits my needs. So far I could work out everything I needed. I just have one little problem left.

This is regarding the callbacks, which get executed when you subscribe to a topic. Lets assume I subscribe to two (three, four...) topics, and the callback method is always the same. Is there a way to tell, which topic executed the callback method?
For example:
    ros::Subscriber sub = n.subscribe("topic1", 100, subCallback);
    ros::Subscriber sub1 = n.subscribe("topic2", 100, subCallback);

So when subCallback(..) gets executed I can tell if it came from sub or sub1. Is that possible?

Ideally I would like to add an argument to the subCallback method. 
For example:
void chatterCallback(int queue_id, const std_msgs::StringConstPtr& msg)

With queue_id being an int I defined when subscribing. Could I do that with my own boost::bind(...)? If so, how?

I looked over the NodeHandle.subscribe code but I believe there is nothing which works the way I want it to? 

Any help is appreciated, thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20100704/2acca72b/attachment-0002.html>

More information about the ros-users mailing list