service_response.py
Go to the documentation of this file.
1 from rosbridge_library.capability import Capability
2 from rosbridge_library.internal import ros_loader, message_conversion
3 from rosbridge_library.util import string_types
4 
5 
7 
8  service_response_msg_fields = [
9  (True, "service", string_types), (False, "id", string_types),
10  (False, "values", dict), (True, "result", bool)
11  ]
12 
13  def __init__(self, protocol):
14  # Call superclass constructor
15  Capability.__init__(self, protocol)
16 
17  # Register the operations that this capability provides
18  protocol.register_operation("service_response", self.service_response)
19 
20  def service_response(self, message):
21  # Typecheck the args
23 
24  # check for the service
25  service_name = message["service"]
26  if service_name in self.protocol.external_service_list:
27  service_handler = self.protocol.external_service_list[service_name]
28  # parse the message
29  request_id = message["id"]
30  values = message["values"]
31  # create a message instance
32  resp = ros_loader.get_service_response_instance(service_handler.service_type)
33  message_conversion.populate_instance(values, resp)
34  # pass along the response
35  service_handler.responses[request_id] = resp
36  else:
37  self.protocol.log("error", "Service %s has not been advertised via rosbridge." % service_name)
def basic_type_check(self, msg, types_info)
Definition: capability.py:76


rosbridge_library
Author(s): Jonathan Mace
autogenerated on Fri Oct 21 2022 02:45:18