ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Get list of topics via rosbridge and websocket

asked 2013-10-01 02:23:06 -0500

tropic gravatar image

I am currently using rosbridge 2.0 to communicate with ROS via websocket. In connection with this I would like to retrieve a list of all topics through my interface. As I can read from the rosbridge website it should be possible to retrieve a list of topics currently running in ROS via a service call, however, I cannot figure out how this should be done since there are no examples. There is a link on the rosbridge website to a pdf with more information, but this link is unfortunately outdated and does not work.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2013-10-01 07:22:48 -0500

tropic gravatar image

So I can answer this question myself now. I do not know what I was thinking when implementing this, because I already did it successfully for reading topics. I simply forgot to serialize my message as a JSON object. Now that I have done that, I can retrieve all available ROS topics.

For calling the topics and services I also found these two links very useful:

edit flag offensive delete link more

answered 2013-10-01 04:45:14 -0500

Pi Robot gravatar image

This function appears to do the trick under ROS Groovy and Ubuntu 12.04. However, the function doesn't always seem to return the list of topics (especially if run immediately after loading the webpage) and I'm guessing it's because it's not waiting for the result from the service call (although that is only a guess). Is there a "wait_for_service" or "timeout" parameter for rosbridge service calls?

function getTopics() {
    var topicsClient = new ROSLIB.Service({
    ros : ros,
    name : '/rosapi/topics',
    serviceType : 'rosapi/Topics'

    var request = new ROSLIB.ServiceRequest();

    topicsClient.callService(request, function(result) {
    console.log("Getting topics...");
edit flag offensive delete link more


Hello, i tried that and it works. But i cant return the result from the function. Do you know how to return that ?

Eduardo Soares gravatar image Eduardo Soares  ( 2019-09-23 11:54:48 -0500 )edit

answered 2013-10-01 02:45:39 -0500

rtoris288 gravatar image

updated 2017-02-03 02:36:56 -0500

Here is an example in JavaScript on how to make the call, but the service call can easily be ported to other languages as well:

edit flag offensive delete link more


So it should look something like this if you also look at the service call on the rosbridge website? {'op': 'call_service', 'service': '/rosapi/topics', 'arg': 'rosapi/Topics'}. However, I get the "Unable to deserialize message..." when sending this. Any suggestions?

tropic gravatar image tropic  ( 2013-10-01 03:25:54 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2013-10-01 02:23:06 -0500

Seen: 4,494 times

Last updated: Feb 03 '17