安装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
,就成功把数据显示出来了:
- 同样的,也可以再添加其他的
topic
,这里不再赘述。