realsense R200转成costmap_2d

来源:互联网 发布:mac mnmp 一键安装包 编辑:程序博客网 时间:2024/05/29 18:02

使用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_linkwidth: 10height: 10footprint: [[-0.325, -0.325], [-0.325, 0.325], [0.325, 0.325], [0.46, 0.0], [0.325, -0.325]]#robot_radius: 0.46footprint_padding: 0.01plugins:    - {name: obstacles,        type: "costmap_2d::ObstacleLayer"}update_frequency: 6.0publish_frequency: 2.0always_send_full_costmap: trueobstacles:    observation_sources: base_scan    z_resolution: 0.6    z_voxels: 2    publish_voxel_map: true    base_scan:        data_type: PointCloud2        topic: /camera/depth/points        clearing: true        marking: true        max_obstacle_height: 2.0        obstacle_range: 6.0        raytrace_range: 8.0

然后,roslaunch realsense_camera r200_default.launch,先运行r200,在roslaunch costmap_2d example.launch。

此时运行起来发现costmap_2d并没有正常运行,打开rviz观看,costmap_2d没有正常转化。

经过观察costmap_2d的launch文件发现,运行r200的时候,costmap_2d的默认的example.launch文件里有个参数/user_sim_time将其设置为true了。但运行realsense和costmap_2d的时候并没有任何node提供/user_sim_time这个值。遂将其置为false。再次运行发现,costmap_2d可以正常转化了。

0 0