rossvcclient
Connect to ROS service server
Description
Use rossvcclient
or ros.ServiceClient
to
create a service client object over ROS network. This service client uses a persistent
connection to send requests to, and receive responses from, a ROS service server. The
connection persists until the service client is deleted or the service server becomes
unavailable.
Use the ros.ServiceClient
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 client with the given client
= rossvcclient(servicename
,servicetype
)ServiceName
that connects to a service serve of type ServiceType
.
This command syntax prevents the current MATLAB® program from running until it can connect to the service
server.
provides additional options specified by one or more
client
= rossvcclient(servicename
,servicetype
,Name,Value)Name,Value
pair arguments.
[
returns a new service request message in client
,reqmsg
]
= rossvcclient(___)reqmsg
, using
any of the arguments from previous syntaxes. The message type of
reqmsg
is determined by the service that
client
is connected to. The message is initialized
with default values. You can also create the request message using rosmessage
.
[___]
= rossvcclient(___,"DataFormat","struct")
uses message structures instead of objects. For more information, see ROS Message Structures.
[___]
= rossvcclient(___,"IsPersistent","true")
determines that the service client is persistent.
client = ros.ServiceClient(
creates a service client that connects to a service server. The client gets
its service type from the server. The service client attaches to the
node
,name
)ros.Node
object handle,
node
.
client = ros.ServiceClient(
creates a service client that connects to a service server with the given
service name node
,name
,type
)name
, and type, type
.
The service client attaches to the ros.Node
object
handle, node
.
client = ros.ServiceClient(
specifies a timeout period in seconds for the client to connect the service
server.node
, name
,"Timeout",timeout
)
[___]
= ros.ServiceClient(___,"DataFormat","struct")
uses message structures instead of objects. For more information, see ROS Message Structures.
Properties
Object Functions
rosmessage | Create ROS messages |
call | Call ROS or ROS 2 service server and receive a response |
isServerAvailable | Determine if ROS or ROS 2 service server is available |
waitForServer | Wait for ROS or ROS 2 service server to start |
Examples
Extended Capabilities
Version History
Introduced in R2019bSee Also
rosservice
| rossvcserver
| call
| isServerAvailable
| waitForServer
| rosmessage