29 #ifndef TOPIC_PROXY_SERVICE_CLIENT_H 30 #define TOPIC_PROXY_SERVICE_CLIENT_H 33 #include <ros/common.h> 46 template <
typename Service>
49 init<Service>(service_name, host, port, header_values);
52 template <
typename Service>
55 return init(service_name, std::string(ros::service_traits::md5sum<Service>()), host, port, header_values);
58 bool init(
const std::string& service_name,
const std::string& service_md5sum, std::string host = std::string(), uint32_t port = 0,
const ros::M_string& header_values =
ros::M_string());
64 template<
class MReq,
class MRes>
65 bool call(MReq& req, MRes& res)
74 if (strcmp(st::md5sum(req), st::md5sum(res)))
76 ROS_ERROR(
"The request and response parameters to the service " 77 "call must be autogenerated from the same " 78 "server definition file (.srv). your service call " 79 "for %s appeared to use request/response types " 80 "from different .srv files. (%s vs. %s)",
impl_->name_.c_str(), st::md5sum(req), st::md5sum(res));
84 return call(req, res, st::md5sum(req));
90 template<
class Service>
91 bool call(Service& service)
100 return call(service.request, service.response, st::md5sum(service));
106 template<
typename MReq,
typename MRes>
107 bool call(
const MReq& req, MRes& resp,
const std::string& service_md5sum)
112 bool ok =
call(ser_req, ser_resp, service_md5sum);
120 ser::deserializeMessage(ser_resp, resp);
122 catch (std::exception& e)
160 ROS_ERROR(
"Exception thrown while while deserializing service call: %s", e.what());
184 #endif // TOPIC_PROXY_SERVICE_CLIENT_H
boost::shared_ptr< Impl > ImplPtr
bool call(Service &service)
Call the service aliased by this handle with the specified service request/response.
boost::weak_ptr< Impl > ImplWPtr
bool call(MReq &req, MRes &res)
std::map< std::string, std::string > M_string
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...
void deserializeFailed(const std::exception &e)
ros::ServiceServerLinkPtr server_link_
bool call(MReq &req, MRes &res)
Call the service aliased by this handle with the specified request/response messages.
ServiceClient(const std::string &service_name, const std::string &host=std::string(), uint32_t port=0, const ros::M_string &header_values=ros::M_string())
bool init(const std::string &service_name, std::string host=std::string(), uint32_t port=0, const ros::M_string &header_values=ros::M_string())
ros::M_string header_values_
void deserializeFailed(const std::exception &e)