Hi all,
I'm trying to parse a rosbag file. According to the guide here, I wrote something like this:
rosbag::Bag bag;
std::vector topics;
std::cout << "Opening " << filename_ << std::endl;
bag.open(filename_.c_str(), rosbag::bagmode::Read);
std::cout << "Mode: " << bag.getMode() << std::endl;
topics.push_back(std::string("/Imu"));
topics.push_back(std::string("/joint_states"));
rosbag::View view(bag, rosbag::TopicQuery(topics));
foreach(rosbag::MessageInstance const m, view) {
std::cout << "Found message of type " << m.getDataType() << std::endl;
if(m.getDataType().compare("sensor_msgs/Imu") == 0) {
sensor_msgs::ImuConstPtr s = m.instantiate();
cout << "S = " << s << std::endl;
double ax = s->linear_acceleration.x;
}
The address printed by S is not NULL, but when I reach the last line to get the data, I get a SEGFAULT.
↧