Class: Service

Service(options)

new Service(options)

A ROS service client.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
ros Ros

The ROSLIB.Ros connection handle.

name string

The service name, like '/add_two_ints'.

serviceType string

The service type, like 'rospy_tutorials/AddTwoInts'.

Source:

Methods

Advertise the service. This turns the Service object from a client into a server. The callback will be called with every request that's made on this service.

Parameters:
Name Type Description
callback function

This works similarly to the callback for a C++ service and should take the following params:

Properties
Name Type Description
request ServiceRequest

The service request.

response Object

An empty dictionary. Take care not to overwrite this. Instead, only modify the values within. It should return true if the service has finished successfully, i.e., without any fatal errors.

Source:

callService(request, callback, failedCallbackopt)

Call the service. Returns the service response in the callback. Does nothing if this service is currently advertised.

Parameters:
Name Type Attributes Description
request ServiceRequest

The ROSLIB.ServiceRequest to send.

callback function

Function with the following params:

Properties
Name Type Description
response Object

The response from the service request.

failedCallback function <optional>

The callback function when the service call failed with params:

Properties
Name Type Description
error string

The error message reported by ROS.

Source: