ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
After some experiment, I firstly confirms that ServiceRequests works fine with the code below.
var ros = new ROSLIB.Ros(); // If there is an error on the backend, an 'error' emit will be emitted. ros.on('error', function(error) { console.log(error); }); // Find out exactly when we made a connection. ros.on('connection', function() { console.log('Connection made!'); var getListService = new ROSLIB.Service({ ros : ros, name : '/get_list', serviceType : 'rosbridge_test_service/GetList' }); var request = new ROSLIB.ServiceRequest({}); getListService.callService(request, function(result) { console.log(result); }); }); // Create a connection to the rosbridge WebSocket server. ros.connect('ws://localhost:9090'); //98
I figured out that your code call the service twice almost simultaneously. And it seems to cause a problem when rosbridge creates a message cache. I have tried to investigate to solve this issue but the exception arises from ros core library which I can't track down more deeply.
Thus, I would suggest to clean up the server code logic to call service once. rosbridge is able to handle multiple connections and multiple service calls. However, this case was too extreme...