29 #ifndef SWRI_ROSCPP_TOPIC_SERVICE_SERVER_H_ 30 #define SWRI_ROSCPP_TOPIC_SERVICE_SERVER_H_ 45 template<
class MReq,
class MRes,
class T>
51 bool(T::*callback_)(
const MReq &, MRes &);
56 const std::string &service,
57 bool(T::*srv_func)(
const MReq &, MRes &),
67 response_pub_ = nh.
advertise<MRes>(rservice +
"/response", 10);
75 ROS_DEBUG(
"Got request from %s with sequence %i", message.srv_header.sender.c_str(), message.srv_header.sequence);
79 bool result = (obj_->*callback_)(message, response);
80 response.srv_header.result = result;
81 response.srv_header.sequence = message.srv_header.sequence;
82 response.srv_header.sender = message.srv_header.sender;
83 response_pub_.
publish(response);
96 template<
class MReq,
class MRes,
class T>
98 const std::string &service,
99 bool(T::*srv_func)(
const MReq &, MRes &),
109 template<
class MReq,
class MRes,
class T>
112 const std::string &service,
113 bool(T::*srv_func)(
const MReq &, MRes &),
122 #endif // SWRI_ROSCPP_TOPIC_SERVICE_SERVER_H_
ros::Publisher response_pub_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCONSOLE_DECL void initialize()
void initialize(ros::NodeHandle &nh, const std::string &service, bool(T::*srv_func)(const MReq &, MRes &), T *obj)
void publish(const boost::shared_ptr< M > &message) const
ros::Subscriber request_sub_
std::string resolveName(const std::string &name, bool remap=true) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void request_callback(const MReq &message)
boost::shared_ptr< ImplRoot > impl_
const std::string response
void initialize(ros::NodeHandle &nh, const std::string &service, bool(T::*srv_func)(const MReq &, MRes &), T *obj)