rosjava: calling rosservice fails
Dear all,
I made my first homebrewed rosservice with Java. I have generated my custom service GetCylinders.srv
---
string name
float32 likelihood
which should return a name and a likelihood with an empty request. I have generated the service and included it in my server like this:
import org.ros.service.reasoner_msgs.*;
ServiceServer<org.ros.service.reasoner_msgs.GetCylinders.Request, org.ros.service.reasoner_msgs.GetCylinders.Response> server = node.newServiceServer(
"callme", "reasoner_msgs/GetCylinders",
new ServiceResponseBuilder<org.ros.service.reasoner_msgs.GetCylinders.Request, org.ros.service.reasoner_msgs.GetCylinders.Response>() {
@Override
public org.ros.service.reasoner_msgs.GetCylinders.Response build(org.ros.service.reasoner_msgs.GetCylinders.Request request) throws ServiceException {
org.ros.service.reasoner_msgs.GetCylinders.Response response = new org.ros.service.reasoner_msgs.GetCylinders.Response();
// ...
response.name="CylinderA";
response.likelihood=(float) 0.7;
return response;
}
}
);
When I start the node the service /callme shows up. Well that is fine. But if I use rosservice call /callme i get an error. Have I done something wrong in the setup of the service? The error message I get is
Traceback (most recent call last):
File "/opt/ros/electric/ros/bin/rosservice", line 46, in <module>
rosservice.rosservicemain()
File "/opt/ros/electric/stacks/ros_comm/tools/rosservice/src/rosservice.py", line 731, in rosservicemain
_rosservice_cmd_call(argv)
File "/opt/ros/electric/stacks/ros_comm/tools/rosservice/src/rosservice.py", line 586, in _rosservice_cmd_call
service_class = get_service_class_by_name(service_name)
File "/opt/ros/electric/stacks/ros_comm/tools/rosservice/src/rosservice.py", line 357, in get_service_class_by_name
service_type = get_service_type(service_name)
File "/opt/ros/electric/stacks/ros_comm/tools/rosservice/src/rosservice.py", line 141, in get_service_type
return get_service_headers(service_name, service_uri).get('type', None)
File "/opt/ros/electric/stacks/ros_comm/tools/rosservice/src/rosservice.py", line 113, in get_service_headers
return roslib.network.read_ros_handshake_header(s, cStringIO.StringIO(), 2048)
File "/opt/ros/electric/ros/core/roslib/src/roslib/network.py", line 367, in read_ros_handshake_header
raise ROSHandshakeException("connection from sender terminated before handshake header received. %s bytes were received. Please check sender for additional details."%b.tell())
roslib.network.ROSHandshakeException: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
Can anyone help me in solving this problem?
I found out that using rosservice info /callme and rosservice args /callme give the same error. rosservice list shows /callme and rosservice uri /callme gives rosrpc://127.0.0.1:53311. Strange. Is there maybe a bug in the rosjavas service call?