ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to list all topics/services that are known by the server with roscpp?

asked 2013-12-08 06:23:30 -0600

ISibboI gravatar image

How can I list all topics or services that are currently known by the server with roscpp?

edit retag flag offensive close merge delete

Comments

Maybe sth like rostopic list && rosservice list | grep *roscpp*? I'm not sure about the exact syntax from my mind.

atp gravatar image atp  ( 2013-12-08 07:16:59 -0600 )edit

Thx. With roscpp I mean using a C++ function.

ISibboI gravatar image ISibboI  ( 2013-12-08 07:17:43 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-12-12 16:26:13 -0600

Chengarda gravatar image

updated 2013-12-12 16:29:43 -0600

You can use the services of the omnipresent rosapi node, these are equivalent to the command line statements:

rosservice call rosapi/topics rosservice call rosapi/services

Roscpp

ros::ServiceClient topicfinder = n.serviceClient<rosapi::Topics>("rosapi/topics");
ros::ServiceClient servicesfinder = n.serviceClient<rosapi::Services>("rosapi/services");

rosapi::Topics topicsrv;
rosapi::Services servicessrv;

topicfinder.call(topicsrv);
servicesfinder.call(servicessrv);

Rospy

from rosapi.srv import Topics, Services

topics = rospy.ServiceProxy('/rosapi/topics', Topics)
services = rospy.ServiceProxy('/rosapi/services', Services)
topiclist = topics()
servicelist = services()

I've probably got some typos and mistakes in here, but that's the general gist.

edit flag offensive delete link more

Comments

1

It's much easier using the Master_API: ros::master::V_TopicInfo topics; ros::master::getTopics(topics). But anyway, nice answer.

tik0 gravatar image tik0  ( 2017-03-07 03:52:20 -0600 )edit

This gives me rospy.service.ServiceException: service [/rosapi/services] unavailable

Cerin gravatar image Cerin  ( 2018-03-13 08:50:03 -0600 )edit

Also for me as for Cerin same error..... Any ideas how to code that for rospy with the Master_API @tik0

Markus gravatar image Markus  ( 2018-05-16 04:17:27 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2013-12-08 06:23:30 -0600

Seen: 3,361 times

Last updated: Dec 12 '13