40 bool getTopicBase(
const std::string& topic, std::string& topicBase) {
41 std::string tmp = topic;
42 int i = tmp.rfind(
'/');
44 while( (tmp.size() > 0) && (i >= (
int)(tmp.size()-1))) {
45 tmp = tmp.substr(0,tmp.size()-1);
55 topicBase = tmp.substr(i+1, tmp.size()-i-1);
62 &
callback, subscriberTransportHints);
66 if(
lazy && !subscriber)
80 if (connectionHeader) {
81 ros::M_string::const_iterator it = connectionHeader->find(
"latching");
82 if ((it != connectionHeader->end()) && (it->second ==
"1"))
87 message->getType().getMD5Sum(), message->getType().getDataType(),
89 options.
latch = latch;
91 publisher = nodeHandle->advertise<variant_msgs::Variant>(
publisherTopic,
98 message->toVariantMessage();
99 publisher.
publish(variantMessage);
105 int main(
int argc,
char **argv) {
107 printf(
"\nusage: relay TOPIC [VARIANT_TOPIC]\n\n");
112 ROS_ERROR(
"Failed to extract topic base from [%s]", argv[1]);
127 bool unreliable =
false;
128 nodeHandle->getParam(
"unreliable", unreliable);
129 nodeHandle->getParam(
"lazy",
lazy);
boost::shared_ptr< void const > VoidConstPtr
boost::function< void(const SingleSubscriberPublisher &)> SubscriberStatusCallback
TransportHints & reliable()
void publish(const boost::shared_ptr< M > &message) const
Header file providing the Message class interface.
size_t publisherQueueSize
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
const boost::shared_ptr< M_string > & getConnectionHeaderPtr() const
std::string subscriberTopic
void connectCallback(const ros::SingleSubscriberPublisher &)
const boost::shared_ptr< ConstMessage > & getConstMessage() const
TransportHints & unreliable()
ros::NodeHandlePtr nodeHandle
void callback(const ros::MessageEvent< variant_topic_tools::Message > &messageEvent)
bool getTopicBase(const std::string &topic, std::string &topicBase)
int main(int argc, char **argv)
std::string publisherTopic
ros::TransportHints subscriberTransportHints
size_t subscriberQueueSize
uint32_t getNumSubscribers() const
ros::Subscriber subscriber