[ros-users] How to identify the subscriber or the topic name…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: ros-users
Subject: [ros-users] How to identify the subscriber or the topic name related to a callback
Hello

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?


for (unsigned int i = 0; i < topics.size(); i++) {
        sub[i] = n_.subscribe(topics[i], 1000, &MyClass::callback, this);
}


void callback(const ros::MessageEvent<std_msgs::String const>& event)
{
const std::string& publisher_name = event.getPublisherName();
#Here comes the problem
const std::string& topic_name = event.?????????();
}

Thanks
Markus