Go to the documentation of this file.00001 from rosbridge_library.capability import Capability
00002 from rosbridge_library.internal import ros_loader, message_conversion
00003 from rosbridge_library.util import string_types
00004
00005
00006 class ServiceResponse(Capability):
00007
00008 service_response_msg_fields = [
00009 (True, "service", string_types), (False, "id", string_types),
00010 (False, "values", string_types), (True, "result", bool)
00011 ]
00012
00013 def __init__(self, protocol):
00014
00015 Capability.__init__(self, protocol)
00016
00017
00018 protocol.register_operation("service_response", self.service_response)
00019
00020 def service_response(self, message):
00021
00022 service_name = message["service"]
00023 if service_name in self.protocol.external_service_list:
00024 service_handler = self.protocol.external_service_list[service_name]
00025
00026 request_id = message["id"]
00027 values = message["values"]
00028
00029 resp = ros_loader.get_service_response_instance(service_handler.service_type)
00030 message_conversion.populate_instance(values, resp)
00031
00032 service_handler.responses[request_id] = resp
00033 else:
00034 self.protocol.log("error", "Service %s has no been advertised externally." % service_name)