Thursday 15 January 2015

c++ - ROS - get current available topic in code (not command) -



c++ - ROS - get current available topic in code (not command) -

i want current available topics in code can set publisher , subscribber accordingly. know command 'rostopic list' show this, want info when programme running.

is there api this?

thanks

post edited after gabor meszaros's answer.

you find ros c++ api reference (roscpp) here , - in python - you'll find gettopics method in ros::master subsection.

here sample code of how utilize it:

ros::master::v_topicinfo master_topics; ros::master::gettopics(master_topics); (ros::master::v_topicinfo::iterator = master_topics.begin() ; != master_topics.end(); it++) { const ros::master::topicinfo& info = *it; std::cout << "topic_" << - master_topics.begin() << ": " << info.name << std::endl; }

c++ ros

No comments:

Post a Comment