Mastering ROS for Robotics Programming(Second Edition)
上QQ阅读APP看书,第一时间看更新

ROS bags

A bag file in ROS is for storing ROS message data from topics and services. The .bag extension is used to represent a bag file.

Bag files are created using the rosbag command, which will subscribe one or more topics and store the message's data in a file as it's received. This file can play the same topics as they are recorded from or it can remap the existing topics too.

The main application of rosbag is data logging. The robot data can be logged and can visualize and process offline.

The rosbag command is used to work with rosbag files. Here are the commands to record and playback a bag file:

  • $ rosbag record [topic_1] [topic_2] -o [bag_name]: This command will record the given topics into a bag file that is given in the command. We can also record all topics using the -a argument.
  • $ rosbag play [bag_name]: This will playback the existing bag file.

Further details about this command can be found at: http://wiki.ros.org/rosbag/Commandline

There is a GUI tool to handle the record and playback of bag files called rqt_bag. To learn more about rqt_bag, go to: http://wiki.ros.org/rqt_bag.