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

Revision history [back]

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...");
    console.log(result.topics);
    });
};