Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 475

Why am I getting a nullptr from my bag file?

$
0
0
I am playing back a bagfile and I get a nullptr when I should be getting actual data. Below is a screenshot of the bagfile being viewed from RQT. There is only one message called "decomposition/sectors" and I am certain that it should have data. Yet, when I am playing back the bag file in C++ code for a unit test, I get a nullptr for this particular item. Why am I getting this? The other messages will be properly read and instantiated, but not this one. ![image description](/upfiles/14909806363918583.png) Here is a snippet of code which shows how I am reading this: void CoverageReporterTester::SendMessage(const rosbag::MessageInstance& bag_msg) { if (topic_name == avidbots_topics::decomposition_sectors) { message_stack::sector_array msg1 = *bag_msg.instantiate(); SendMessage(topic_name, msg1); } } /* Read bag file */ rosbag::Bag bag_file; std::string bag_dir = ros::package::getPath("coverage_reporter") + "/test/data/bag_files/coverage_reporter.bag"; bag_file.open(bag_dir, rosbag::bagmode::Read); /* List of topics we are interested in */ std::vector topics; topics.push_back(topics::decomposition_sectors); topics.push_back(avidbots_topics::static_3d_costmap_topic); rosbag::View view(bag_file, rosbag::TopicQuery(topics)); /* Loop through each message in the bag file which is associated with one of our topics listed above */ foreach(rosbag::MessageInstance const bag_msg, view) { coverage_reporter.SendMessage(bag_msg); }

Viewing all articles
Browse latest Browse all 475

Trending Articles