I am writing a program to read data from rosbag directly without playing it in ros2. Sample code snippet is below. The intention of the code is that it checks for a ros2 topic and fetches only message in that topic. I am not able to fetch the data from the bag. When printed the console is printing hexadecimal values.
auto read_only_storage = factory.open_read_only(bag_file_path, storage_id);
while(read_only_storage->has_next())
{
auto msg = read_only_storage->read_next();
if(msg->topic_name == topic)
{
cout << msg->serialized_data<<endl;
}
}
Any help in this regard would be appreciable.