ROSBAG使用(一):可視化bag文件

安裝ROS可以參考:Win10安裝ROS

注:以下的命令行指的都是經過 ROS 的 setup.bat 的。

  • 首先,打開一個命令行,運行:

    roscore
    

    基本上,使用ROS的服務之前,都要先啓動這個。

  • 然後,查看要可視化的 bag 信息:

    rosbag info bagname.bag
    

    我的結果如下:

    path:        2019-01-26-09-53-54_0.bag
    version:     2.0
    duration:    1:58s (118s)
    start:       Jan 26 2019 09:53:54.80 (1548467634.80)
    end:         Jan 26 2019 09:55:53.18 (1548467753.18)
    size:        3.9 GB
    messages:    2383
    compression: none [1192/1192 chunks]
    types:       sensor_msgs/CompressedImage [8f7a12909da2c9d3332d540a0977563f]
                 sensor_msgs/PointCloud2     [1158d486dd51d683ce2f1be655c3c181]
    topics:      /pandora/sensor/pandora/camera/front_color/compressed   1192 msgs    : sensor_msgs/CompressedImage
                 /pandora/sensor/pandora/hesai40/PointCloud2             1191 msgs    : sensor_msgs/PointCloud2
    

    這裏的 topics 說明我的 bag 文件中有圖片和點雲的信息,待會要用到。

  • 然後對 bag 進行回放,打開一個新的命令行輸入:

    rosbag play bagname.bag
    

    然後這裏就會相當於一個 publisher ,我們可以接下來要做的就是接收這裏發佈的消息。

  • 再打開一個命令行輸入:

    rosrun rviz rviz
    

    就會打開如下界面:

在這裏插入圖片描述

現在什麼都沒有,因爲我們沒有設置 `subsriber`。

點擊左下角的 `Add`,選擇 `By topic` 可以看到這個就是我們上面顯示出來的 `topics`。

注:如果沒有顯示這個,可以去查看一下 `rosbag play` 那個命令行,看是不是數據已經回放結束了,如果結束了可以重新回放,或者使用:`rosbag play bagname.bag -l` 來循環回放。

在這裏插入圖片描述

選擇 `PointCloud2`。有的人可能已經能夠看到結果了,但是有的會發現什麼都沒有,左邊還顯示了 `Status:Error`,因此需要修改 `Fixed Frame` 的值,官網對於 `Fixed Frame` 的解釋是:

> The fixed frame is the reference frame used to denote the "world" frame. This is usually the "map", or "world", or something similar, but can also be, for example, your odometry frame.
>
> If the fixed frame is erroneously set to, say, the base of the robot, then all the objects the robot has ever seen will appear in front of the robot, at the position relative to the robot at which they were detected. For correct results, **the fixed frame should not be moving relative to the world**.
>
> If you change the fixed frame, all data currently being shown is cleared rather than re-transformed.

我也不是搞得很清楚,我觀察了一下 `topics` 發現我的數據用的是 `hesai40`,因此更改 `Fixed Frame` 爲 `hesai40` ,就成功把數據顯示出來了:

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-9UON43RX-1585448218935)(http://memoryxinxin.xyz/usr/imgs/image-3.png#pic_center)]

hesai40 ,就成功把數據顯示出來了:

http://memoryxinxin.xyz/usr/imgs/image-3.png

  • 同樣的,也可以再添加其他的 topic ,這裏不再贅述。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章