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很酷,也需要耐心和堅持,智慧與技巧,接下來,我們一起進步吧~~