Ask Your Question
1

Get all topics in c++

asked 2013-01-24 00:47:47 -0500

nemo gravatar image

updated 2014-01-28 17:14:58 -0500

ngrennan gravatar image

Hi everyone,

is there any way to do something like "rostopic list" or "rostopic find <msg_type>" NOT in a command line but in a C++ code and get the corresponding topics?

Thank you in advance

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2013-01-24 01:06:40 -0500

dornhege gravatar image

updated 2013-01-24 01:07:38 -0500

Yes, look at the Master API.

getPublishedTopics or getSystemState should do what you want.

edit flag offensive delete link more

Comments

do you have an c++ and/or python example for the command getPublishedTopics??????????

silgon gravatar imagesilgon ( 2014-01-13 04:20:19 -0500 )edit
0

answered 2015-05-07 08:41:46 -0500

Gzork gravatar image

I got this one

bool getRosTopics(ros::master::V_TopicInfo& topics){
    XmlRpc::XmlRpcValue args, result, payload;
    args[0] = ros::this_node::getName();

    if (!ros::master::execute("getTopicTypes", args, result, payload, true)){
        std::cout << "Failed!" << std::endl;
        return false;
    }

    topics.clear();
    for (int i = 0; i < payload.size(); ++i)
        topics.push_back(ros::master::TopicInfo(std::string(payload[i][0]), std::string(payload[i][1])));
    return true;
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-01-24 00:47:47 -0500

Seen: 2,555 times

Last updated: Jan 24 '13