You can use rosbag::View::getConnectionInfo.
rosbag::Bag bag("foo.bag");
rosbag::View view(bag);
std::vector<const rosbag::ConnectionInfo *> connection_infos = view.getConnectionInfo();
std::set<std::string> topics;
BOOST_FOREACH(const rosbag::ConnectionInfo *info, connection_infos) {
if( !topics.find(info->topic) ) {
topics.insert(info->topic);
}
}
Originally posted by Lorenz with karma: 22731 on 2012-07-20
This answer was ACCEPTED on the original site
Post score: 4
Original comments
Comment by Ankush on 2012-07-20:
Thank you, that really helped. On the same note, what is the C++ equivalent of "rewriting bag", given in the cookbook (http://www.ros.org/wiki/rosbag/Cookbook)?
I want to process a particular topic from a rosbag file and write the others unchanged to a new bagfile.