1. 程式人生 > >ROS進二階學習筆記(6) -- ROS Bag

ROS進二階學習筆記(6) -- ROS Bag

ROS Bag是ROS計算圖級的一個概念:

Bags:

ref : http://wiki.ros.org/Bags

在 計算圖裡 線上使用

   工具:rosbag
   建立bags, 收聽topic,記錄資料。可以回放或者remap到別的topic。
   rosbag還能處理具有時間戳的資料,publish一個 simulated clock that corresponds to the time the data was recorded in the file。
   bag檔案的格式用來記錄和回放資料都是非常高效的,訊息都是跟在ros裡一樣的格式記錄的。
   具體command-line使用方法:

rosbag command-line usage

離線使用和資料遷移

   有多種離線使用方式。

   工具:rqt_bag

     可以讓你視覺化bag資料,plot 或者image。ref rqt_bag: http://wiki.ros.org/rqt_bag

   工具:rostopic

     快速檢視bag檔案,list topics 和 echoing data to console.
       Display messages in a bag file:
             $ rostopic echo -b log_file.bag /topic_name
       rostopic list
             list

      Display a list of current topics.
            $ rostopic list
            list <namespace>
            List topics in the specified namespace. In previous versions, this is equivalent to the rostopic info command.
                    $ rostopic list /namespace
          -b
          List topics in a bag file

.
          -p
          List only publishers.
          -s
          List only subscribers.
          -v
          Verbose mode.
                    $ rostopic list -v
          --host New in Diamondback
          Group list by hostname.
   ref more: http://wiki.ros.org/rostopic

   Programmatic APIs - rosbag工具

     rosbag 工具可以更快速操作bag檔案,這讓你提取滿足特定filter的訊息到一個新的bag檔案。
     參考: rosbag Code APICookbook examples,
               
     rosrecord 包裡有APIs,可以讓其他的C++/python 包有能力to iterate over stored messages,它老了,已經被rosbag取代了。

     msg檔案有更新時,bag file可以輕易地被提取。bag 檔案格式裡存有與之所存資料匹配的 msg 檔案。像rosbagmigration這樣的工具可以寫規則進去,來自動的更新bag files當它變得out of date.

工具:

   >> rosbag: unified console tool for recording, playback, and other operations.
   >> rqt_bag: graphical tool for visualizing bag file data.
   >> rostopic: the echo and list commands are compatible with bag files.

Older tools

    The following tools have been superceded by rosbag, but are still supported:
    >> rosrecord
    >> rosplay
    >> rosrebag

格式

bag檔案的格式與普通使用者沒多大關係了。
The underlying format of a bag file should not be relevant to the average user. It is subject to change, but backwards compatibility will be maintained by the programmatic access libraries, or custom conversion libraries.

===================

如何在程式中使用bag 檔案

問題1: 資料的記錄和回放到console

        ref: http://wiki.ros.org/rosbag/Code%20API

問題2: a collection of code fragments demonstrating use of the rosbag APIs.

        ref: http://wiki.ros.org/rosbag/Cookbook

更多高階的玩法

當需要更高階的功能時,得ref: rosBag 的 API 文件
提取資料時,可能會涉及到 tuples Generator 的操作。