2018-3-20 update
最近注册了微信公众号,开始分享SLAM学习过程中的点点滴滴+算法练习+科研过程与心得,如果大家感兴趣的话,可以一起交流学习哦~~~期待共同进步
之前这个号,我是在做英语口语分享,最近准备做一个改变啦,希望我们一起进步~
---------------以下是原文--------分割线----------------------
下面是我一步一步搭建的过程,话不多说,开题:
环境信息:Ubuntu14.04
一:前提工作:
建立一个文件夹(把需要的库都放在这里面);进入该目录;
cd /
mkdir myslam cd myslam
二:安装必要工具,如下:
sudo apt-get install cmake sudo apt-get install gcc g++ sudo apt-get install git
Pangolin
sudo apt-get install libglew-dev sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev sudo apt-get install libpython2.7-dev sudo apt-get install build-essential git clone https://github.com/stevenlovegrove/Pangolin.git cd Pangolin mkdir build cd build cmake .. make
OpenCV
cd /myslam
#安装OpenCV依赖项: sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev libtbb-dev #下载OpenCV git clone https://github.com/opencv/opencv.git #编译链接安装 mkdir build cd build cmake .. make make install
Eigen3
cd /myslam git clone https://github.com/eigenteam/eigen-git-mirror.git mkdir build cd build cmake .. make
DBoW2
虽然并不需要安装完整的DBoW2(在ORB_SLAM2项目的Thirdparty下有),但是我们还是要安装它的依赖项。
sudo apt-get install libboost-dev
g2o
虽然并不需要安装完整的g2o(在ORB_SLAM2项目的Thirdparty下有),但是我们还是要安装它的依赖项。
sudo apt-get install cmake libeigen3-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev
ORB SLAM2
cd /myslam git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2 cd ORB_SLAM2
#在ORB SLAM2里面并没有加入usleep()函数的头文件,所以,我事先加入了如下代码:
vim include/System.h
#include <unistd.h>
#然后保存退出。 chmod +x build.sh ./build.sh
三、下载数据集进行练习:
下载TUM公开单目数据集:
https://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.tgz
发现下载到了/Downloads:
#把数据集放到/myslam文件夹里面 cd /myslam mv /Downloads/rgbd_dataset_freiburg1_xyz.tgz . #解压数据集: tar xzvf rgbd_dataset_freiburg1_xyz.tgz
然后进行执行:
#进入ORB_SLAM2目录 cd /myslam/ORB_SLAM2 #执行: ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml rgbd_dataset_freiburg1_xyz
哦豁!然后我就遇到了一个这样的问题:
=======================================求教,谢谢大家================================================
问题:(已经解决~)
1、第一次执行的时候,一直在提示:初始化失败,正在重置,初始化失败,正在重置......反复着。然后显示是正常的,到最后一个图片变成灰色,不可以正常结束。输出信息如下:
ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Monocular Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Create KeyFrame Database Create the Map Create Drawers. These are used by the Viewer Initialize the Tracking thread Initialize the Local Mapping thread and launch Initialize the Loop Closing thread and launch Initialize the Viewer thread and launch Set pointers between threads Camera Parameters: - fx: 517.306 - fy: 516.469 - cx: 318.643 - cy: 255.314 - k1: 0.262383 - k2: -0.953104 - k3: 1.16331 - p1: -0.005358 - p2: 0.002628 - fps: 30 - color order: RGB (ignored if grayscale) ORB Extractor Parameters: - Number of Features: 1000 - Scale Levels: 8 - Scale Factor: 1.2 - Initial Fast Threshold: 20 - Minimum Fast Threshold: 7 Start processing sequence ... Images in the sequence: 798 (ORB-SLAM2: Current Frame:19837): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed (ORB-SLAM2: Current Frame:19837): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed (ORB-SLAM2: Current Frame:19837): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed Create MapPoint.、Fill Current Frame structure、Add to Map、Update Connections、Bundle Adjustment Set median depth to 1 New Map created with 84 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 96 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 95 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 106 points ^C #我强制退出程序的(Ctrl+C)
然后我发现反复初始化是因为map point在程序中是必须大于100才可以继续执行的。所以,我把这个值改成了大于70即可以初始化成功。然后进行下一次执行。
2、第二次执行这个可执行程序:mono_tum时候,不可以正常运行退出,我发现输出信息+报错信息如下:
ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Monocular Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Camera Parameters: - fx: 517.306 - fy: 516.469 - cx: 318.643 - cy: 255.314 - k1: 0.262383 - k2: -0.953104 - k3: 1.16331 - p1: -0.005358 - p2: 0.002628 - fps: 30 - color order: RGB (ignored if grayscale) ORB Extractor Parameters: - Number of Features: 1000 - Scale Levels: 8 - Scale Factor: 1.2 - Initial Fast Threshold: 20 - Minimum Fast Threshold: 7 ------- Start processing sequence ... Images in the sequence: 798 (ORB-SLAM2: Current Frame:17959): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed (ORB-SLAM2: Current Frame:17959): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed (ORB-SLAM2: Current Frame:17959): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed New Map created with 85 points ^C #这里的^C是程序不可以正常结束,最后一个图片页面会变成灰色。所以我按着ctrl+c结束的
其中,程序mono_tum并没有执行结束。
3、我使用kdevelop调试,发现在slam.shutdown()这里,终止了,程序不能正常进行下去。
然后,我把pangolin调用的代码注释了:
在System.cc里面
//if(mpViewer) // pangolin::BindToContext("ORB-SLAM2: Map Viewer");
ok,大功告成!
如果你有什么问题,欢迎提问,我们一起进步~~
总结:
SLAM很酷,也需要耐心和坚持,智慧与技巧,接下来,我们一起进步吧~~