Go to the documentation of this file.
29 #ifndef ROSCPP_ADVERTISE_SERVICE_OPTIONS_H
30 #define ROSCPP_ADVERTISE_SERVICE_OPTIONS_H
32 #include "ros/forwards.h"
33 #include "ros/service_callback_helper.h"
34 #include "ros/service_traits.h"
35 #include "ros/message_traits.h"
56 template<
class MReq,
class MRes>
57 void init(
const std::string& _service,
const std::function<
bool(MReq&, MRes&)>& _callback)
59 namespace st = service_traits;
60 namespace mt = message_traits;
61 if (st::md5sum<MReq>() != st::md5sum<MRes>())
63 ROS_FATAL(
"the request and response parameters to the server "
64 "callback function must be autogenerated from the same "
65 "server definition file (.srv). your advertise_servce "
66 "call for %s appeared to use request/response types "
67 "from different .srv files.", service.c_str());
72 md5sum = st::md5sum<MReq>();
74 req_datatype = mt::datatype<MReq>();
75 res_datatype = mt::datatype<MRes>();
76 helper = std::make_shared<ServiceCallbackHelperT<ServiceSpec<MReq, MRes> > >(_callback);
84 template<
class Service>
85 void init(
const std::string& _service,
const std::function<
bool(
typename Service::Request&,
typename Service::Response&)>& _callback)
87 namespace st = service_traits;
88 namespace mt = message_traits;
89 typedef typename Service::Request Request;
90 typedef typename Service::Response Response;
92 md5sum = st::md5sum<Service>();
94 req_datatype = mt::datatype<Request>();
95 res_datatype = mt::datatype<Response>();
96 helper = std::make_shared<ServiceCallbackHelperT<ServiceSpec<Request, Response> > >(_callback);
105 void initBySpecType(
const std::string& _service,
const typename Spec::CallbackType& _callback)
107 namespace st = service_traits;
108 namespace mt = message_traits;
109 typedef typename Spec::RequestType Request;
110 typedef typename Spec::ResponseType Response;
112 md5sum = st::md5sum<Request>();
114 req_datatype = mt::datatype<Request>();
115 res_datatype = mt::datatype<Response>();
116 helper = std::make_shared<ServiceCallbackHelperT<Spec> >(_callback);
148 template<
class Service>
150 const std::function<
bool(
typename Service::Request&,
typename Service::Response&)>&
callback,
155 ops.
init<
typename Service::Request,
typename Service::Response>(service,
callback);
const char * md5sum()
returns MD5Sum<M>::value();
#define ROS_BREAK()
Aborts program execution.
ServiceCallbackHelperPtr helper
Helper object used for creating messages and calling callbacks.
Encapsulates all options available for creating a ServiceServer.
static AdvertiseServiceOptions create(const std::string &service, const std::function< bool(typename Service::Request &, typename Service::Response &)> &callback, const VoidConstPtr &tracked_object, CallbackQueueInterface *queue)
Templated helper function for creating an AdvertiseServiceOptions with all of its options.
const char * datatype()
returns DataType<M>::value();
std::string service
Service name.
void init(const std::string &_service, const std::function< bool(MReq &, MRes &)> &_callback)
Templated convenience method for filling out md5sum/etc. based on the service request/response types.
VoidConstPtr tracked_object
An object whose destruction will prevent the callback associated with this service from being called.
void initBySpecType(const std::string &_service, const typename Spec::CallbackType &_callback)
Templated convenience method for filling out md5sum/etc. based on the service spec type.
std::string res_datatype
Response message datatype.
void init(const std::string &_service, const std::function< bool(typename Service::Request &, typename Service::Response &)> &_callback)
Templated convenience method for filling out md5sum/etc. based on the service type.
std::string datatype
Datatype of the service.
Abstract interface for a queue used to handle all callbacks within roscpp.
std::string md5sum
MD5 of the service.
AdvertiseServiceOptions()
std::shared_ptr< ServiceCallbackHelper > ServiceCallbackHelperPtr
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
std::string req_datatype
Request message datatype.
std::shared_ptr< void const > VoidConstPtr
void callback(const sick_scan_xd::RadarScan::ConstPtr &oa)
sick_scan_xd
Author(s): Michael Lehning
, Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:07