def create_service(self, srv_type, srv_name, callback, *, qos_profile=qos_profile_services_default, callback_group=None): if callback_group is None: callback_group = self._default_callback_group check_for_type_support(srv_type) failed = False try: [service_handle, service_pointer ] = _rclpy.rclpy_create_service(self.handle, srv_type, srv_name, qos_profile.get_c_qos_profile()) except ValueError: failed = True if failed: self._validate_topic_or_service_name(srv_name, is_service=True) service = Service(self.handle, service_handle, service_pointer, srv_type, srv_name, callback, callback_group, qos_profile) self.services.append(service) callback_group.add_entity(service) return service
def __init__(self, node): super().__init__(ReentrantCallbackGroup()) self.server = _rclpy.rclpy_create_service( node.handle, EmptySrv, 'test_server', qos_profile_default.get_c_qos_profile())[0] self.server_index = None self.server_is_ready = False self.node = node self.future = None
def __init__(self, node): super().__init__(ReentrantCallbackGroup()) with node.handle as node_capsule: self.server = _rclpy.rclpy_create_service( node_capsule, EmptySrv, 'test_server', QoSProfile(depth=10).get_c_qos_profile()) self.server_index = None self.server_is_ready = False self.node = node self.future = None
def create_service( self, srv_type, srv_name, callback, qos_profile=qos_profile_services_default): if srv_type.__class__._TYPE_SUPPORT is None: srv_type.__class__.__import_type_support__() if srv_type.__class__._TYPE_SUPPORT is None: raise NoTypeSupportImportedException [service_handle, service_pointer] = _rclpy.rclpy_create_service( self.handle, srv_type, srv_name, qos_profile.get_c_qos_profile()) service = Service( self.handle, service_handle, service_pointer, srv_type, srv_name, callback, qos_profile) self.services.append(service) return service
def create_service(self, srv_type, srv_name: str, callback: Callable[[SrvTypeRequest, SrvTypeResponse], SrvTypeResponse], *, qos_profile: QoSProfile = qos_profile_services_default, callback_group: CallbackGroup = None) -> Service: """ Create a new service server. :param srv_type: The service type. :param srv_name: The name of the service. :param callback: A user-defined callback function that is called when a service request received by the server. :param qos_profile: The quality of service profile to apply the service server. :param callback_group: The callback group for the service server. If ``None``, then the nodes default callback group is used. """ if callback_group is None: callback_group = self.default_callback_group check_for_type_support(srv_type) failed = False try: with self.handle as node_capsule: service_capsule = _rclpy.rclpy_create_service( node_capsule, srv_type, srv_name, qos_profile.get_c_qos_profile()) except ValueError: failed = True if failed: self._validate_topic_or_service_name(srv_name, is_service=True) service_handle = Handle(service_capsule) service_handle.requires(self.handle) service = Service(service_handle, srv_type, srv_name, callback, callback_group, qos_profile) self.__services.append(service) callback_group.add_entity(service) return service