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... | |
Contains functions for querying information about and calling a service.
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.
service_name | The name of the service. | |
req | The request message. | |
[out] | res | Storage for the response message. |
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.
service_name | The name of the service. |
service | The service class that contains the request and response messages |
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.
service_name | The name of the service to connect to |
persistent | Whether 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_values | Key/value pairs you'd like to send along in the connection handshake |
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.
service_name | The name of the service to connect to |
persistent | Whether 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_values | Key/value pairs you'd like to send along in the connection handshake |
bool ros::service::exists | ( | const std::string & | service_name, |
bool | print_failure_reason | ||
) |
Checks if a service is both advertised and available.
service_name | Name of the service to check for |
print_failure_reason | Whether to print the reason for failure to the console (service not advertised vs. could not connect to the advertised host) |
Definition at line 41 of file service.cpp.
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.
service_name | Name of the service to wait for. |
timeout | The amount of time to wait for, in milliseconds. If timeout is -1, waits until the node is shutdown |
Definition at line 128 of file service.cpp.
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.
service_name | Name of the service to wait for. |
timeout | The amount of time to wait for before timing out. If timeout is -1 (default), waits until the node is shutdown |
Definition at line 87 of file service.cpp.