How to extract timestamp from a bag file ?
Hi,
I checked on the API c++ but I wasn't able to do what I want. Actually, I would like to write a little program which take an input a bag file and then obtain the the timestamp of each frame as an output. All the timestamp are stored in the /camera_topic.
So far what I did is the following:
rosbag::Bag bag;
bag.open("mybag.bag", rosbag::bagmode::Read);
rosbag::View view(bag, rosbag::TopicQuery("/camera_info"));
foreach(rosbag::MessageInstance const m, view)
{
std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>();
if (s != NULL)
ASSERT_EQ(s->data, std::string("foo"));
std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>();
if (i != NULL)
ASSERT_EQ(i->data, 42);
}
bag.close();
Is anyone can help me ? Maybe there is another easy way to do that stuff (bash ?) but It would be great using c++.
Thank