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)
rosbridge_library.capabilities.service_response.ServiceResponse.__init__
def __init__(self, protocol)
Definition: service_response.py:13
rosbridge_library.capabilities.service_response.ServiceResponse
Definition: service_response.py:6
rosbridge_library.capabilities.service_response.ServiceResponse.service_response
def service_response(self, message)
Definition: service_response.py:20
rosbridge_library.capabilities.service_response.ServiceResponse.service_response_msg_fields
list service_response_msg_fields
Definition: service_response.py:8
rosbridge_library.util
Definition: src/rosbridge_library/util/__init__.py:1
rosbridge_library.capability.Capability.protocol
protocol
Definition: capability.py:58
rosbridge_library.capability.Capability.basic_type_check
def basic_type_check(self, msg, types_info)
Definition: capability.py:76
rosbridge_library.capability
Definition: capability.py:1
rosbridge_library.capability.Capability
Definition: capability.py:37
rosbridge_library.internal
Definition: src/rosbridge_library/internal/__init__.py:1


rosbridge_library
Author(s): Jonathan Mace
autogenerated on Tue Oct 3 2023 02:12:45