35 #ifndef ROSSERIAL_SERVER_TOPIC_HANDLERS_H 36 #define ROSSERIAL_SERVER_TOPIC_HANDLERS_H 39 #include <rosserial_msgs/TopicInfo.h> 54 catch (
const std::exception& e)
59 if (!msginfo.
md5sum.empty() && msginfo.
md5sum != topic_info.md5sum)
61 ROS_WARN_STREAM(
"Message" << topic_info.message_type <<
"MD5 sum from client does not " 62 "match that in system. Will avoid using system's message definition.");
89 boost::function<
void(std::vector<uint8_t>& buffer)> write_fn)
90 : write_fn_(write_fn) {
94 opts.
md5sum = topic_info.md5sum;
95 opts.
datatype = topic_info.message_type;
100 return subscriber_.getTopic();
106 std::vector<uint8_t> buffer(length);
115 boost::function<void(std::vector<uint8_t>& buffer)> write_fn_;
123 boost::function<
void(std::vector<uint8_t>& buffer,
const uint16_t topic_id)> write_fn)
124 : write_fn_(write_fn) {
133 reqinfo =
lookupMessage(topic_info.message_type +
"Request",
"srv");
134 respinfo =
lookupMessage(topic_info.message_type +
"Response",
"srv");
136 catch (
const std::exception& e)
140 service_md5_ = srvinfo.
md5sum;
141 request_message_md5_ = reqinfo.
md5sum;
142 response_message_md5_ = respinfo.
md5sum;
145 opts.
service = topic_info.topic_name;
151 topic_id_ = topic_id;
157 return request_message_md5_;
160 return response_message_md5_;
170 service_client_.call(request_message_, response_message_, service_md5_);
174 std::vector<uint8_t> buffer(length);
177 write_fn_(buffer,topic_id_);
184 boost::function<void(std::vector<uint8_t>& buffer,
const uint16_t topic_id)> write_fn_;
195 #endif // ROSSERIAL_SERVER_TOPIC_HANDLERS_H ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
Subscriber(ros::NodeHandle &nh, rosserial_msgs::TopicInfo &topic_info, boost::function< void(std::vector< uint8_t > &buffer)> write_fn)
static void write(Stream &stream, typename boost::call_traits< T >::param_type t)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
boost::shared_ptr< Publisher > PublisherPtr
std::string getServiceMD5()
ServiceClient(ros::NodeHandle &nh, rosserial_msgs::TopicInfo &topic_info, boost::function< void(std::vector< uint8_t > &buffer, const uint16_t topic_id)> write_fn)
ros::Subscriber subscriber_
ros::ServiceClient service_client_
boost::shared_ptr< Subscriber > SubscriberPtr
void handle(const boost::shared_ptr< topic_tools::ShapeShifter const > &msg)
Publisher(ros::NodeHandle &nh, const rosserial_msgs::TopicInfo &topic_info)
void publish(const boost::shared_ptr< M > &message) const
std::string request_message_md5_
topic_tools::ShapeShifter request_message_
topic_tools::ShapeShifter response_message_
std::string response_message_md5_
static void read(Stream &stream, typename boost::call_traits< T >::reference t)
std::string getRequestMessageMD5()
void setTopicId(uint16_t topic_id)
#define ROS_WARN_STREAM(args)
boost::shared_ptr< ServiceClient > ServiceClientPtr
void handle(ros::serialization::IStream stream)
std::string getTopic() const
topic_tools::ShapeShifter message_
void init(const std::string &_topic, uint32_t _queue_size, const boost::function< void(const boost::shared_ptr< M const > &)> &_callback, const boost::function< boost::shared_ptr< M >(void)> &factory_fn=DefaultMessageCreator< M >())
uint32_t serializationLength(const T &t)
ros::Publisher publisher_
void handle(ros::serialization::IStream stream)
std::string getResponseMessageMD5()
const MsgInfo lookupMessage(const std::string &message_type, const std::string submodule="msg")