Class: ROS::ServiceServer
Overview
server of ROS Service. Node#advertise_service return a instance of this class. Service can be shutdown by #shutdown. This class uses TCPROS::ServiceServer for data transfer.
Instance Attribute Summary (collapse)
-
- (Integer) num_request
readonly
How many times this service called.
Attributes inherited from Service
#caller_id, #service_name, #service_type
Instance Method Summary (collapse)
-
- (Boolean) call(request, response)
execute the service callback.
-
- (Object) close
user should not call this method.
-
- (Array) get_connection_data
Connection data.
-
- (ServiceServer) initialize(caller_id, service_name, service_type, callback, host)
constructor
A new instance of ServiceServer.
-
- (String) service_uri
URI of this service (rosrpc://**).
-
- (Object) set_manager(manager)
set GraphManager for shutdown.
-
- (Object) shutdown
shutdown the service connection.
Constructor Details
- (ServiceServer) initialize(caller_id, service_name, service_type, callback, host)
Returns a new instance of ServiceServer
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ros/service_server.rb', line 37 def initialize(caller_id, service_name, service_type, callback, host) super(caller_id, service_name, service_type) @callback = callback @server = TCPROS::ServiceServer.new(@caller_id, @service_name, @service_type, self, :host => host) @server.start @num_request = 0 end |
Instance Attribute Details
- (Integer) num_request (readonly)
Returns how many times this service called
92 93 94 |
# File 'lib/ros/service_server.rb', line 92 def num_request @num_request end |
Instance Method Details
- (Boolean) call(request, response)
execute the service callback. User should not call this directly.
55 56 57 58 |
# File 'lib/ros/service_server.rb', line 55 def call(request, response) @num_request += 1 @callback.call(request, response) end |
- (Object) close
user should not call this method. Please use shutdown method.
69 70 71 |
# File 'lib/ros/service_server.rb', line 69 def close #:nodoc: @server.shutdown end |
- (Array) get_connection_data
Returns connection data
87 88 89 |
# File 'lib/ros/service_server.rb', line 87 def get_connection_data [@num_request, @server.byte_received, @server.byte_sent] end |
- (String) service_uri
URI of this service (rosrpc://**)
62 63 64 |
# File 'lib/ros/service_server.rb', line 62 def service_uri 'rosrpc://' + @server.host + ':' + @server.port.to_s end |
- (Object) set_manager(manager)
set GraphManager for shutdown
82 83 84 |
# File 'lib/ros/service_server.rb', line 82 def set_manager(manager) #:nodoc: @manager = manager end |
- (Object) shutdown
shutdown the service connection
76 77 78 |
# File 'lib/ros/service_server.rb', line 76 def shutdown @manager.shutdow_service_server(self) end |