How to extract the message types of all the topics available in a rosbag file ?

asked 2022-08-30 06:46:24 -0500

ros_user_ak gravatar image

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)
  return topics;
edit retag flag offensive close merge delete