使用realsense R200可以直接得到/camera/color/image_raw,/camera/depth/image_raw和/camera/depth/points.
分别是原始图像数据,深度数据和点云。要转换成2D的代价地图,使用costmap_2d的package。
其中costmap_2d的package只支持laserScan,pointCloud和pointCloud2格式的数据转换。幸好,Realsense R200的/camera/depth/points是pointCloud2格式的,可以直接用与costmap_2d。但是pointCloud2格式的数据太大,运行可能会卡顿。
这种情况下可以使用名字叫depthimage_to_laserscan-indigo-devel的packge,将/camera/depth/image_raw的sensor_msg/Image格式的深度数据转换成laserScan。进而使用costmap_2d。
两种方法都可以,直接用pointClouds2,或者把深度数据转成laserScan再使用costmap_2d。如果采用别的双目摄像头没有pointCloud格式的输出,那么只能先转成laserScan。
costmap_2d/launch文件夹下新建一个yaml文件,名称随意,比如example.yaml,写入以下代码:其中重点在于标红的两行代码,数据类型写PointCloud2,topic写名称。
global_frame: /camera_link
width: 10
height: 10
footprint: [[-0.325, -0.325], [-0.325, 0.325], [0.325, 0.325], [0.46, 0.0], [0.325, -0.325