On Mon, Jan 31, 2011 at 5:46 AM, Markus Bader wrote: > I have multiple subscriber calling the same callback function. How can > I determinate within my callback function the related topic name? > getPublisherName gives me the related publisher but not the topic? hi Markus, At the time that you make the subscription, you can arrange for the topic to be passed into the callback, using boost::bind. Appended below is a simple example that demonstrates this. brian. #include #include #include class MyClass { public: std::vector subs; MyClass() { ros::NodeHandle n; std::vector topics; topics.push_back("foo"); topics.push_back("bar"); for (unsigned int i = 0; i < topics.size(); i++) { subs.push_back(n.subscribe(topics[i], 1000, boost::bind(&MyClass::callback, this, _1, topics[i]))); } } void callback(const ros::MessageEvent& event, const std::string& topic) { const std::string& publisher_name = event.getPublisherName(); ROS_INFO("publisher: %s\ttopic: %s", publisher_name.c_str(), topic.c_str()); } }; int main(int argc, char** argv) { ros::init(argc, argv, "mynode"); MyClass m; ros::spin(); return 0; }