rossvcserver
Create ROS service server
Description
Use rossvcserver
or ros.ServiceServer
to
create a ROS service server that can receive requests from, and send responses to, a ROS
service client. You must create the service server before creating the service client
rossvcclient
.
When you create the service client, it establishes a connection to the server. The
connection persists while both client and server exist and can reach each other. When
you create the service server, it registers itself with the ROS
master. To get a list of services, or to get information
about a particular service that is available on the current ROS network, use the
rosservice
function.
The service has an associated message type and contains a pair of messages: one for the request and one for the response. The service server receives a request, constructs an appropriate response based on a call function, and returns it to the client. The behavior of the service server is inherently asynchronous because it becomes active only when a service client connects to the ROS network and issues a call.
Use the ros.ServiceServer
syntax when connecting to a specific ROS
node.
Note
In a future release, ROS Toolbox will use message structures instead of objects for ROS messages.
To use message structures now, set the "DataFormat"
name-value
argument to "struct"
. For more information, see ROS Message Structures.
Creation
Syntax
Description
creates a service server object with the specified
server
= rossvcserver(servicename
,svctype
)ServiceType
available in the ROS network under the
name ServiceName
. The service object cannot respond to
service requests until you specify a function handle callback,
NewMessageFcn
.
specifies the callback function that constructs a response when the server
receives a request. The server
= rossvcserver(servicename
,svctype
,callback
)callback
specifies the
NewMessageFcn
property.
[___] = rossvcclient(___,"DataFormat","struct")
uses message structures instead of objects with any of the arguments in
previous syntaxes. For more information, see ROS Message Structures.
server = ros.ServiceServer(
creates a service server that attaches to the ROS node,
node
, name
,type
)node
. The server becomes available through the
specified service name and type once a callback function handle is specified
in NewMessageFcn
.
server = ros.ServiceServer(
specifies the callback function, which is set to the
node
, name
,type
,callback
)NewMessageFcn
property.
[___]
= ros.ServiceServer(___,"DataFormat","struct")
uses message structures instead of objects. For more information, see ROS Message Structures.
Properties
Object Functions
rosmessage | Create ROS messages |