Go to the documentation of this file.
28 #ifndef ROSCPP_SERVICE_CLIENT_H
29 #define ROSCPP_SERVICE_CLIENT_H
32 #include "ros/common.h"
46 ServiceClient(
const std::string& service_name,
bool persistent,
const M_string& header_values,
const std::string& service_md5sum);
55 template<
class MReq,
class MRes>
56 bool call(MReq& req, MRes& res)
58 namespace st = service_traits;
65 if (strcmp(st::md5sum(req), st::md5sum(res)))
67 ROS_ERROR(
"The request and response parameters to the service "
68 "call must be autogenerated from the same "
69 "server definition file (.srv). your service call "
70 "for %s appeared to use request/response types "
71 "from different .srv files. (%s vs. %s)", impl_->name_.c_str(), st::md5sum(req), st::md5sum(res));
75 return call(req, res, st::md5sum(req));
81 template<
class Service>
82 bool call(Service& service)
84 namespace st = service_traits;
91 return call(service.request, service.response, st::md5sum(service));
97 template<
typename MReq,
typename MRes>
98 bool call(
const MReq& req, MRes& resp,
const std::string& service_md5sum)
100 namespace ser = serialization;
103 bool ok =
call(ser_req, ser_resp, service_md5sum);
111 ser::deserializeMessage(ser_resp, resp);
113 catch (std::exception& e)
115 deserializeFailed(e);
128 bool isValid()
const;
133 bool isPersistent()
const;
162 std::string getService();
164 operator void*()
const {
return isValid() ? (
void*)1 : (
void*)0; }
167 return impl_ < rhs.
impl_;
172 return impl_ == rhs.
impl_;
177 return impl_ != rhs.
impl_;
186 ROS_ERROR(
"Exception thrown while while deserializing service call: %s", e.what());
195 bool isValid()
const;
boost::shared_ptr< ServiceClient > ServiceClientPtr
bool operator<(const ServiceClient &rhs) const
boost::shared_ptr< Impl > ImplPtr
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
Checks if a service is both advertised and available.
bool call(const std::string &service_name, MReq &req, MRes &res)
Invoke an RPC service.
ROSCPP_DECL void shutdown()
Disconnects everything and unregisters from the master. It is generally not necessary to call this fu...
void deserializeFailed(const std::exception &e)
ROSCPP_DECL bool ok()
Check whether it's time to exit.
bool call(Service &service)
Call the service aliased by this handle with the specified service request/response.
boost::weak_ptr< Impl > ImplWPtr
bool operator!=(const ServiceClient &rhs) const
ServiceServerLinkPtr server_link_
bool operator==(const ServiceClient &rhs) const
Provides a handle-based interface to service client connections.
bool call(MReq &req, MRes &res)
Call the service aliased by this handle with the specified request/response messages.
roscpp's interface for creating subscribers, publishers, etc.
bool call(const MReq &req, MRes &resp, const std::string &service_md5sum)
Mostly for internal use, the other templated versions of call() just call into this one.
std::string service_md5sum_
std::map< std::string, std::string > M_string
roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35