您的位置:首页 > 编程语言 > Go语言

LSD-SLAM在Ubuntu14.04+indigo环境中编译运行

2017-10-08 14:51 751 查看
LSD-SLAM在Ubuntu14.04+indigo环境中编译运行

LSD-SLAM源码:https://github.com/tum-vision/lsd_slam

LSD-SLAM官网:https://vision.in.tum.de/research/vslam/lsdslam

1、初始化ROS工作空间

sudo apt-get install python-rosinstall

mkdir ~/rosbuild_ws

cd ~/rosbuild_ws

rosws init . /opt/ros/indigo

mkdir package_dir

rosws set ~/rosbuild_ws/package_dir -t .

echo "source ~/rosbuild_ws/setup.bash" >> ~/.bashrc

bash

cd package_dir

2、安装依赖项:

sudo apt-get install ros-indigo-libg2o ros-indigo-cv-bridge liblapack-dev libblas-dev freeglut3-dev libqglviewer-dev libsuitesparse-dev libx11-dev

3、在package_dir目录下克隆lsd_slam源码

git clone https://github.com/tum-vision/lsd_slam.git lsd_slam

4、编译lsd_slam包

rosmake lsd_slam

5、下载Datasets
https://vision.in.tum.de/research/vslam/lsdslam
官网提供了Datasets,可以下载

 

下载video:后面的.bag文件或者.png文件都可以。

6、运行测试lsd_slam,下面提供三种测试方式

1)使用.bag数据集

将第5步下载的.bag文件解压。

例如我解压后得到了 LSD_room.bag文件,该文件831.7MB。

在新终端运行roscore

roscore

在新终端运行 lsd_slam viewer

rosrun lsd_slam_viewer viewer

在新终端运行lsd_slam main ros node

rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info

在新终端运行.bag文件

rosbag play ~/LSD_room.bag

2)使用.png数据集

第5步下载.png得到的压缩包解压后得到LSD_room文件夹,里面包含images文件夹和cameraCalibration.cfg文件。

在新终端运行roscore

roscore

在新终端运行 lsd_slam viewer

rosrun lsd_slam_viewer viewer

在新终端运行lsd_slam main ros node

rosrun lsd_slam_core dataset_slam _files:=/home/username/LSD_room/images _hz:=0 _calib:=/home/username/LSD_room/cameraCalibration.cfg

注:这儿的路径应与你的数据集路径一致

3)使用USB摄像头实时采集视频

安装uvc_camera

mkdir catkin_ws

cd catkin_ws

mkdir src

cd src

git clone https://github.com/ros-drivers/libuvc_ros.git
cd ..

catkin_make

编译完成后,若是使用笔记本电脑,因为其自带摄像头编号为/dev/video0,因此需修改uvc_camera.launch文件,将/dev/video0改为/dev/video1

gedit src/camera_umd/uvc_camera/launch/camera_node.launch

 当然还可以在里面修改摄像头的分辨率,我将分辨率改为了640*480。

设置好后,我们可以运行检查驱动是否安装成功

先source一下uvc_camera的setup.bash文件,然后

roslaunch uvc_camera camera_node.launch

rosrun image_view image_view image:=/image_raw

此时出现视频窗口说明驱动安装成功。

下面使用USB摄像头进行lsd_slam

roscore

在新终端运行 lsd_slam viewer

rosrun lsd_slam_viewer viewer

在新终端运行uvc_camera.launch

roslaunch uvc_camera camera_node.launch

在新终端运行lsd_slam main ros node

rosrun lsd_slam_core live_slam /image:=<yourstreamtopic> _calib:=<calibration_file>

我的命令行为:rosrun lsd_slam_core live_slam /image:=image_raw _calib:= ~/rosbuild_ws/package_dir/lsd_slam/lsd_slam_core/calib/OpenCV_example_calib.cfg

此处<yourstreamtopic> 为USB摄像头发布的话题,可执行rostopic list查看,为image_raw

<calibration_file>为摄像机标定文件,规则参考如下:

Camera Calibration:

LSD-SLAM operates on a pinhole camera model, however we give the option to undistort images before they are being used. You can find some sample calib files in lsd_slam_core/calib.

Calibration File for FOV camera model:

fx/width fy/height cx/width cy/height d

in_width in_height

"crop" / "full" / "none" / "e1 e2 e3 e4 0"

out_width out_height

Here, the values in the first line are the camera intrinsics and radial distortion parameter as given by the PTAM cameracalibrator, in_width and in_height is the input image size, and out_width out_height is the desired undistorted image size. The latter can
be chosen freely, however 640x480 is recommended as explained in section 3.1.6. The third line specifies how the image is distorted, either by specifying a desired camera matrix in the same format as the first four intrinsic parameters, or by specifying "crop",
which crops the image to maximal size while including only valid image pixels.

Calibration File for Pre-Rectified Images

This one is without radial distortion correction, as a special case of ATAN camera model but without the computational cost:

fx/width fy/height cx/width cy/height 0

width height

none

width height

Calibration File for OpenCV camera model:

fx fy cx cy k1 k2 p1 p2

inputWidth inputHeight

"crop" / "full" / "none" / "e1 e2 e3 e4 0"

outputWidth outputHeight

注:若出现[rospack]Error:package’***’not found,请source你的setup.bash

参考网站:
http://blog.csdn.net/gobitan/article/details/51541977 http://www.mamicode.com/info-detail-957983.html https://vision.in.tum.de/research/vslam/lsdslam https://github.com/tum-vision/lsd_slam
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: