Method: Rclrb::Node#create_service

Defined in:
lib/rclrb/node.rb

#create_service(srv_type, srv_name, qos_profile = QoSProfileServicesDefault, callback_group = nil, &callback) ⇒ Object

Create a new service server.

Parameters:

  • srv_type: The service type.

  • srv_name (str): The name of the service.

  • callback (block): A user-defined callback function that is called when a service request received by the server, it expects a request and response argument.

  • qos_profile (QoSProfile): The quality of service profile to apply the service server.

  • callback_group (optional CallbackGroup): The callback group for the service server. If None, then the nodes default callback group is used.



91
92
93
94
95
96
97
# File 'lib/rclrb/node.rb', line 91

def create_service(srv_type, srv_name, qos_profile=QoSProfileServicesDefault, callback_group=nil, &callback)
  callback_group = @default_callback_group if callback_group.nil?
  handle = CApi::rcl_get_zero_initialized_service()
  service = Service.new(handle, @node_handle, srv_type, srv_name, callback, qos_profile, callback_group)
  @services.append(service)
  return service
end