ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I have solved the problem : the cpp file given on ros tutorial is not ready for direct usage (f). We need to include it in int main() and include a few more libraries like
and remove ASSERT_EQ as it will further give error.
rosplay.cpp
int main (int argc, char** argv) { ros::init (argc, argv, "bag_it"); rosbag::Bag bag; bag.open("~/bagfiles/2016-12-20-18-18-30.bag", rosbag::bagmode::Read);
std::vector<std::string> topics;
topics.push_back(std::string("chatter"));
topics.push_back(std::string("numbers"));
rosbag::View view(bag, rosbag::TopicQuery(topics));
foreach(rosbag::MessageInstance const m, view)
{
std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>();
if (s != NULL)
std::cout << s->data << std::endl;
std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>();
if (i != NULL)
std::cout << i->data << std::endl;
}
bag.close();
return (0);
}
2 | No.2 Revision |
I have solved the problem : the cpp file given on ros tutorial is not ready for direct usage (f). We need to include it in int main() and include a few more libraries like
and remove ASSERT_EQ as it will further give error.
rosplay.cpp
#include <ros/ros.h>
#include <rosbag/view.h>
#include <gtest/gtest.h>
#include <std_msgs/String.h>
#include <std_msgs/Int32.h>
#include <boost/foreach.hpp>
#define
foreach
}