service_response.py
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         # Call superclass constructor
00015         Capability.__init__(self, protocol)
00016 
00017         # Register the operations that this capability provides
00018         protocol.register_operation("service_response", self.service_response)
00019 
00020     def service_response(self, message):
00021         # check for the service
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             # parse the message
00026             request_id = message["id"]
00027             values = message["values"]
00028             # create a message instance
00029             resp = ros_loader.get_service_response_instance(service_handler.service_type)
00030             message_conversion.populate_instance(values, resp)
00031             # pass along the response
00032             service_handler.responses[request_id] = resp
00033         else:
00034             self.protocol.log("error", "Service %s has no been advertised externally." % service_name)


rosbridge_library
Author(s): Jonathan Mace
autogenerated on Thu Jun 6 2019 21:51:43