Functions
ros::service Namespace Reference

Contains functions for querying information about and calling a service. More...

Functions

template<class MReq , class MRes >
bool call (const std::string &service_name, MReq &req, MRes &res)
 Invoke an RPC service. More...
 
template<class Service >
bool call (const std::string &service_name, Service &service)
 Invoke an RPC service. More...
 
template<class MReq , class MRes >
ServiceClient createClient (const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
 Create a client for a service. More...
 
template<class Service >
ServiceClient createClient (const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
 Create a client for a service. More...
 
ROSCPP_DECL bool exists (const std::string &service_name, bool print_failure_reason)
 Checks if a service is both advertised and available. More...
 
ROSCPP_DECL bool waitForService (const std::string &service_name, int32_t timeout)
 Wait for a service to be advertised and available. Blocks until it is. More...
 
ROSCPP_DECL bool waitForService (const std::string &service_name, ros::Duration timeout=ros::Duration(-1))
 Wait for a service to be advertised and available. Blocks until it is. More...
 

Detailed Description

Contains functions for querying information about and calling a service.

Function Documentation

◆ call() [1/2]

template<class MReq , class MRes >
bool ros::service::call ( const std::string &  service_name,
MReq &  req,
MRes &  res 
)

Invoke an RPC service.

This method invokes an RPC service on a remote server, looking up the service location first via the master.

Parameters
service_nameThe name of the service.
reqThe request message.
[out]resStorage for the response message.
Returns
true on success, false otherwise.

Definition at line 65 of file service.h.

◆ call() [2/2]

template<class Service >
bool ros::service::call ( const std::string &  service_name,
Service &  service 
)

Invoke an RPC service.

This method invokes an RPC service on a remote server, looking up the service location first via the master.

Parameters
service_nameThe name of the service.
serviceThe service class that contains the request and response messages
Returns
true on success, false otherwise.

Definition at line 85 of file service.h.

◆ createClient() [1/2]

template<class MReq , class MRes >
ServiceClient ros::service::createClient ( const std::string &  service_name,
bool  persistent = false,
const M_string header_values = M_string() 
)

Create a client for a service.

When the last handle reference of a persistent connection is cleared, the connection will automatically close.

Parameters
service_nameThe name of the service to connect to
persistentWhether this connection should persist. Persistent services keep the connection to the remote host active so that subsequent calls will happen faster. In general persistent services are discouraged, as they are not as robust to node failure as non-persistent services.
header_valuesKey/value pairs you'd like to send along in the connection handshake

Definition at line 134 of file service.h.

◆ createClient() [2/2]

template<class Service >
ServiceClient ros::service::createClient ( const std::string &  service_name,
bool  persistent = false,
const M_string header_values = M_string() 
)

Create a client for a service.

When the last handle reference of a persistent connection is cleared, the connection will automatically close.

Parameters
service_nameThe name of the service to connect to
persistentWhether this connection should persist. Persistent services keep the connection to the remote host active so that subsequent calls will happen faster. In general persistent services are discouraged, as they are not as robust to node failure as non-persistent services.
header_valuesKey/value pairs you'd like to send along in the connection handshake

Definition at line 152 of file service.h.

◆ exists()

bool ros::service::exists ( const std::string &  service_name,
bool  print_failure_reason 
)

Checks if a service is both advertised and available.

Parameters
service_nameName of the service to check for
print_failure_reasonWhether to print the reason for failure to the console (service not advertised vs. could not connect to the advertised host)
Returns
true if the service is up and available, false otherwise

Definition at line 41 of file service.cpp.

◆ waitForService() [1/2]

bool ros::service::waitForService ( const std::string &  service_name,
int32_t  timeout 
)

Wait for a service to be advertised and available. Blocks until it is.

Parameters
service_nameName of the service to wait for.
timeoutThe amount of time to wait for, in milliseconds. If timeout is -1, waits until the node is shutdown
Note
rospy wait_for_service() has timeout in seconds.
Returns
true on success, false otherwise

Definition at line 129 of file service.cpp.

◆ waitForService() [2/2]

bool ros::service::waitForService ( const std::string &  service_name,
ros::Duration  timeout = ros::Duration(-1) 
)

Wait for a service to be advertised and available. Blocks until it is.

Parameters
service_nameName of the service to wait for.
timeoutThe amount of time to wait for before timing out. If timeout is -1 (default), waits until the node is shutdown
Returns
true on success, false otherwise

Definition at line 87 of file service.cpp.



roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:27