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

トップ ページ
添付ファイル:
Eメールのメッセージ
+ (text/plain)
このメッセージを削除
このメッセージに返信
著者: User discussions
日付:  
To: ros-users
題目: [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