ROS(七):用Kinect v1仿激光数据创建地图

LZ知道最近写的博客有些杂,不是一步一步的按照官网的tutorial写下来的,可能是因为需求不同,所以LZ只学一些可能对项目有用的部分,学艺不精,多多包涵!

之前LZ已经使用过了kinect v1,这里在进一步了解ros的情况下,发现,ros可以直接利用kinect创建地图,并且可以仿激光数据,下面也就是单纯做个记录.

LZ的kinect 在架子上摇摇欲坠,要买个稳定的支架...

1.进入ros工作空间下载测试源码:
https://github.com/ros-perception/pointcloud_to_laserscan,有个问题要注意一下,LZ的是indigo版本的ros,下载的时候注意一下branch.使用kinect深度相机将点云数据转换为激光数据

2.编译配置

//编译功能包并添加路径
catkin_make
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/felaim/catkin_ws/src/pointcloud_to_laserscan-indigo-devel

3.修改launch文件

<?xml version="1.0"?>

<launch>

    <arg name="camera" default="camera" />

    <!-- start sensor-->
    <include file="$(find openni_launch)/launch/openni.launch">  #由于我们使用的kinect,openni2已近不支持了。所以用openni
        <arg name="camera" default="$(arg camera)"/>
    </include>

    <!-- run pointcloud_to_laserscan node -->
    <node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan">  #节点名称可以更改为自己想要的

        <remap from="cloud_in" to="$(arg camera)/depth_registered/points_processed"/>  #话题名称也可以更改,不过在rviz中要明白该订阅那个话题
        <remap from="scan" to="$(arg camera)/scan"/>
        <rosparam>
            target_frame: camera_link 
            transform_tolerance: 0.01
            min_height: 0.0
            max_height: 1.0

            angle_min: -1.5708 # -M_PI/2
            angle_max: 1.5708 # M_PI/2
            angle_increment: 0.087 # M_PI/360.0
            scan_time: 0.3333
            range_min: 0.45
            range_max: 4.0
            use_inf: true

            # Concurrency level, affects number of pointclouds queued for processing and number of threads used
            # 0 : Detect number of cores
            # 1 : Single threaded
            # 2->inf : Parallelism level
            concurrency_level: 1
        </rosparam>

    </node>

</launch>

4.运行启动

roslaunch pointcloud_to_laserscan sample_node.launch

这里写图片描述

可以看到kinect已经链接成功了,LZ还没有标定...

通过rviz可以看到
这里写图片描述

好像看不出来这是啥?

这里写图片描述

彩色图像?如上图所示.

这里写图片描述

节点的连接图如上.

5.利用深度相机仿激光数据创建地图
开始建图~\(≧▽≦)/~啦啦啦

在工作空间中下载源码;https://github.com/chenxingzhe/hector_slam_example并用catkin_make进行编译,要注意

source devel/setup.bash

安装依赖项:

rosdep install hector_slam_example

按照3中所示,修改launch文件
运行:

roslaunch hector_slam_example hector_openni.launch

这里写图片描述

OK!具体后面怎么弄,还是有些懵...

参考地址:
http://www.cnblogs.com/zxouxuewei/p/5307736.html

猜你喜欢

转载自blog.csdn.net/felaim/article/details/79864003