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
00004
00005 class ServiceResponse(Capability):
00006
00007 service_response_msg_fields = [
00008 (True, "service", (str, unicode)), (False, "id", (str, unicode)),
00009 (False, "values", (str, unicode)), (True, "result", bool)
00010 ]
00011
00012 def __init__(self, protocol):
00013
00014 Capability.__init__(self, protocol)
00015
00016
00017 protocol.register_operation("service_response", self.service_response)
00018
00019 def service_response(self, message):
00020
00021 service_name = message["service"]
00022 if service_name in self.protocol.external_service_list:
00023 service_handler = self.protocol.external_service_list[service_name]
00024
00025 request_id = message["id"]
00026 values = message["values"]
00027
00028 resp = ros_loader.get_service_response_instance(service_handler.service_type)
00029 message_conversion.populate_instance(values, resp)
00030
00031 service_handler.responses[request_id] = resp
00032 else:
00033 self.protocol.log("error", "Service %s has no been advertised externally." % service_name)