how to use rosbag API?
I collected odometry data from dspace. It's a .csv file. I want to write it into a rosbag file to do Gmapping. I searched other similar questions and the answers are rosbag API.
So I'm following the API. I want to first try a simple example by writing some simple messages into rosbag. After I write down the code as .cpp file, What should I do next? Do I need to specially create a package for this? (Now it reports rosbag/bag.h no such file or directory)
#include <rosbag/bag.h>
#include <std_msgs/Int32.h>
#include <std_msgs/String.h>
int main(argc, char** argv)
{
ros::init(argc,argv,"bagit");
rosbag::Bag bag;
bag.open('test.bag',rosbag::bagmode::Write);
std_msgs::String str;
str.data=std::string("foo");
std_msgs::Int32 i;
i.data=42;
bag.write("chatter",ros::Time::now(),str);
bag.write("number",ros::Time::now(),i);
bag.close();
return 0;
}
This is not a question, the link you provide is not a tutorial. Describe what you want to do, what your problem is, what you expect to happen and what actually happens. Otherwise, we cannot help you!
@mig Thanks for reminding. I have revised my question. Can you help me?