class Service(ServiceImpl):
Constructor: Service(name, service_class, handler, buff_size, error_handler)
Declare a ROS service. Service requests are passed to the specified handler.
- Service Usage::
- s = Service('getmapservice', GetMap, get_map_handler)
Method | __init__ |
ctor. |
Inherited from ServiceImpl
:
Method | error |
Undocumented |
Method | handle |
Process incoming request. This method should be run in its own thread. If header['persistent'] is set to 1, method will block until connection is broken. @param transport: transport instance @type transport: L{TCPROSTransport} @param header: headers from client @type header: dict... |
Method | shutdown |
Stop this service @param reason: human-readable shutdown reason @type reason: str |
Method | spin |
Let service run and take over thread until service or node shutdown. Use this method to keep your scripts from exiting execution. |
Instance Variable | buff |
Undocumented |
Instance Variable | done |
Undocumented |
Instance Variable | handler |
Undocumented |
Instance Variable | protocol |
Undocumented |
Instance Variable | registered |
Undocumented |
Instance Variable | seq |
Undocumented |
Instance Variable | uri |
Undocumented |
Method | _handle |
Process a single incoming request. @param transport: transport instance @type transport: L{TCPROSTransport} @param request: Message @type request: genpy.Message |
Method | _write |
Send error message to client @param transport: transport connection to client @type transport: Transport @param err_msg: error message to send to client @type err_msg: str |
ctor.
@param name: service name, str @param service_class: Service definition class
@param handler: callback function for processing service request. Function takes in a ServiceRequest and returns a ServiceResponse of the appropriate type. Function may also return a list, tuple, or dictionary with arguments to initialize a ServiceResponse instance of the correct type.
If handler cannot process request, it may either return None, to indicate failure, or it may raise a rospy.ServiceException to send a specific error message to the client. Returning None is always considered a failure.
@type handler: fn(req)->resp
@param buff_size: size of buffer for reading incoming requests. Should be at least size of request message @type buff_size: int
@param error_handler: callback function for handling errors raised in the service code. @type error_handler: fn(exception, exception_type, exception_value, traceback)->None