Ask Your Question

how to use rosbag API?

asked 2017-03-07 16:07:59 -0500

Bill5785 gravatar image

updated 2017-03-08 09:16:13 -0500

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)
    rosbag::Bag bag;'test.bag',rosbag::bagmode::Write);

    std_msgs::String str;"foo");

    std_msgs::Int32 i;;

    return 0;
edit retag flag offensive close merge delete



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!

mgruhler gravatar image mgruhler  ( 2017-03-08 02:22:46 -0500 )edit

@mig Thanks for reminding. I have revised my question. Can you help me?

Bill5785 gravatar image Bill5785  ( 2017-03-08 09:14:52 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-05-22 00:44:11 -0500

updated 2017-05-22 01:22:27 -0500

I am assuming you have already created a workspace with a package that has a CMakeList.txt file and package.xml file with std_msgs specified where necessary.

To answer your question:

  1. takes a string of type std::string const &filename as its first parameter, so change from using ' ' to using " " when specifying a file name.
  2. As this is just an exercise, I would put the hard path to file so you know exactly where the bag file will be saved.
  3. 'catkin build <package_name>' the package that you created.
  4. Create a launch file with the node that has the type as the executable that you just created and place in launch directory (you will have to create this directory).
  5. Launch the launch file, by using roslaunch.

EDIT: For step 3., use catkin_make --pkg <package_name> as per @chwimmer point in the comments.

edit flag offensive delete link more



Goog answer. Just be carefull with point 3: Many beginners dont use catkin tools and dont know that this exists. This step would fail than. Just catkin_make --pkg <package_name> would be better. Every catkin tools user would know than too what to do.

chwimmer gravatar image chwimmer  ( 2017-05-22 01:05:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-03-07 16:07:59 -0500

Seen: 1,285 times

Last updated: May 22 '17