mdonoughe / rosbridge

a ROS node for connecting JavaScript applications by WebSocket
4 stars 0 forks source link

Error while calling service #1

Open frank-van-heesch opened 13 years ago

frank-van-heesch commented 13 years ago

Hi,

first of all, great work on the ROS-bridge. it is exactly what I'm looking for, however... When using the bridge to call my self implemented (and tested in ROS) own service, called "robot_locator" I get the error message:

Error while calling service undefined, response: 'ROSProxy' object has no attribute 'wait_for_service'

The specific javascript that produces the error is: connection.callService('/robot_locator/getLocation', {data: {}, success: function(rsp, svc) {addToLog('> Listened to /robot_locator/getLocation');},
error: function(rsp, svc) {addToLog('> Error while calling service ' + svc + ', response: ' + rsp); }, complete: function(rsp, svc) {addToLog('> Done calling ' + svc + '! The raw response from rosbridge was ' + rsp + '.'); } } );

The "wait_for_service" is called in rosbridge.py:

             def callService(self, receiver, msg, callback):
                              call = {'callback':callback}
                              try:
                                   self.ros.wait_for_service(receiver)

I did manage to get the rest to work.. i.e. establishing a connection and working in "subscribe mode"

Any help on the "wait_for_service" issue would be greatly appreciated :-)

regards, Frank

mdonoughe commented 13 years ago

I'm not the original author of ROSBridge. It was pretty close to exactly what I was looking for too, in theory.

It should be fixed in 647a202. Let me know if you run into more trouble.

frank-van-heesch commented 13 years ago

The fix works but ran into a problem at the next line... I think that -because my service does not take any arguments- you cannot request slot_types... I guess it should be something like this:

if hasattr(request_class, 'slot_types'): rsp = self.ros.callService(receiver, ros.specify(slot_types, msg)) else: rsp = self.ros.callService(receiver, [])

Now it works for in my project, but my python knowledge is too limited to propose this implementation as a patch ;-)