rosコード(C++, Python)から現在存在するトピックのリストを取得する方法
C++
c++ - ROS - get current available topic in code (not command) - Stack Overflow
roscpp: ros::master Namespace Reference
ros::master::V_TopicInfo master_topics; ros::master::getTopics(master_topics); for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) { const ros::master::TopicInfo& info = *it; std::cout << "topic_" << it - master_topics.begin() << ": " << info.name << std::endl; }
Python
http://docs.ros.org/api/rospy/html/rospy.client-module.html#get_published_topics
import rospy rospy.get_published_topics('/')