35 bool getTopicBase(
const std::string& topic, std::string& topicBase) {
36 std::string tmp = topic;
37 int i = tmp.rfind(
'/');
39 while( (tmp.size() > 0) && (i >= (
int)(tmp.size()-1))) {
40 tmp = tmp.substr(0,tmp.size()-1);
50 topicBase = tmp.substr(i+1, tmp.size()-i-1);
65 if (!messageDefinition.
isValid()) {
68 std::cout <<
"Topic: " << message->getHeader().getTopic() <<
"\n";
69 std::cout <<
"Publisher: " << message->getHeader().getPublisher() <<
"\n";
70 std::cout <<
"Latched: " << (message->getHeader().isLatched() ?
71 "yes" :
"no") <<
"\n";
73 std::cout <<
"Type: " << message->getType().getDataType() <<
"\n";
74 std::cout <<
"MD5 Sum: " << message->getType().getMD5Sum() <<
"\n";
75 std::cout <<
"Definition:\n";
84 int main(
int argc,
char **argv) {
86 printf(
"\nusage: info TOPIC\n\n");
91 ROS_ERROR(
"Failed to extract topic base from [%s]", argv[1]);
Header file providing the MessageDefinition class interface.
Header file providing the Message class interface.
variant_topic_tools::MessageDefinition messageDefinition
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
const boost::shared_ptr< ConstMessage > & getConstMessage() const
void callback(const ros::MessageEvent< variant_topic_tools::Message > &messageEvent)
size_t subscriberQueueSize
int main(int argc, char **argv)
ros::Subscriber subscriber
ROSCPP_DECL void shutdown()
ros::NodeHandlePtr nodeHandle
std::string subscriberTopic
bool getTopicBase(const std::string &topic, std::string &topicBase)