Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while obtaining service_type for services with a long name #104

Closed
piyushk opened this issue May 2, 2014 · 0 comments · Fixed by #105
Closed

Error while obtaining service_type for services with a long name #104

piyushk opened this issue May 2, 2014 · 0 comments · Fixed by #105

Comments

@piyushk
Copy link
Contributor

piyushk commented May 2, 2014

https://github.com/RobotWebTools/rosbridge_suite/blob/develop/rosbridge_library/src/rosbridge_library/internal/services.py#L100 throws an exception for me when the full service name is too long. I believe this happens because a unicode string is passed to the rosservice tool to obtain the service type.

A quick check shows that this might be an upstream issue at, or the fact that unicode strings are not supposed to be passed to the rosservice tool. Some examples are below.

Changing the above line of code from:

service_type = get_service_type(service)

to

service_type = get_service_type(str(service))

should solve the problem.

@dirk-thomas: Do you think this is an upstream issue?

Examples:

piyushk@robot-devil:~/catkin_ws/src/bwi_guidance/bwi_guidance/www$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from rosservice import get_service_type
>>> get_service_type('/services/bwi_guidance_server_service/person/camera/rgb/image_raw/compressed/set_parameters')
'dynamic_reconfigure/Reconfigure'
>>> get_service_type(u'/services/bwi_guidance_server_service/person/camera/rgb/image_raw/compressed/set_parameters')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosservice/__init__.py", line 147, in get_service_type
    return get_service_headers(service_name, service_uri).get('type', None)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosservice/__init__.py", line 123, in get_service_headers
    rosgraph.network.write_ros_handshake_header(s, header)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosgraph/network.py", line 415, in write_ros_handshake_header
    s = encode_ros_handshake_header(header)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosgraph/network.py", line 401, in encode_ros_handshake_header
    return struct.pack('<I', len(s)) + s
UnicodeDecodeError: 'ascii' codec can't decode byte 0x96 in position 0: ordinal not in range(128)
>>> get_service_type(u'/services/bwi_guidance_server_service/person/camera/rgb/image_raw/compressed/set_parameters')
KeyboardInterrupt
>>> get_service_type(u'/services/bwi_guidance_server_service/person/camera/rgb/image_raw/compressed/set_parameters')
KeyboardInterrupt
>>> get_service_type('/services/bwi_guidance_server_service/rosapi/service_request_details')
'rosapi/ServiceRequestDetails'
>>> get_service_type(u'/services/bwi_guidance_server_service/rosapi/service_request_details')
'rosapi/ServiceRequestDetails'
>>> get_service_type(u'/services/bwi_guidance_server_service/rosapi/service_response_details')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosservice/__init__.py", line 147, in get_service_type
    return get_service_headers(service_name, service_uri).get('type', None)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosservice/__init__.py", line 123, in get_service_headers
    rosgraph.network.write_ros_handshake_header(s, header)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosgraph/network.py", line 415, in write_ros_handshake_header
    s = encode_ros_handshake_header(header)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/rosgraph/network.py", line 401, in encode_ros_handshake_header
    return struct.pack('<I', len(s)) + s
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128)

'/services/bwi_guidance_server_service/rosapi/service_request_details' was the longest service name I was able to process succesfully.

piyushk added a commit to piyushk/rosbridge_suite that referenced this issue May 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant