How to extract the message types of all the topics available in a rosbag file ?
I'm reading into a rosbag file and I need code which gives me the message type of each topic when i iterate through all the topics in the bag file (ex: in a for loop).
std::vector<std::string> getTopicNames(rosbag::Bag& bag)
{
rosbag::View viewTopics(bag);
std::vector<std::string> topics;
std::vector<const rosbag::ConnectionInfo*> connection_infos = viewTopics.getConnections();
BOOST_FOREACH (const rosbag::ConnectionInfo* info, connection_infos)
{
topics.push_back(info->topic);
}
return topics;
}