Robotics StackExchange | Archived questions

memory mapping in ros bag

Instead of reading all the data from the ros bag file, is their any ros provided method to read the bag file using memory mapped methode? For example right now i am using below program to read the ros bag named obj.bag using memory mapped i/o,

#include <cstddef>
#include <string>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>
namespace bip = boost::interprocess;
int main() {

std::string filename = "obj.bag";
bip::file_mapping mapping(filename.c_str(), bip::read_only);
bip::mapped_region mapped_rgn(mapping, bip::read_only);
char const* const mmaped_data = static

_cast<char*>(mapped_rgn.get_address());
std::size_t const mmap_size = mapped_rgn.get_size();
std::cout<<mmap_size<<std::endl;
}

Asked by dinesh on 2017-02-02 05:04:08 UTC

Comments

Answers