ORB-SLAM2环境配置

ORB-SLAM2环境配置
随着ORB-SLAM2和ORB-SLAM3的盛行,越来越多的人踏入到了SLAM这个领域中,本文对ORB-SLAM2的配置环境进行介绍。
硬件基础:内存、硬盘足够
系统:Ubuntu16.04

接下来介绍配置过程(新手小白只需要跟着这个步骤一步一步地来即可)

Step1:由于我使用的虚拟机,因此虚拟机和Ubuntu系统可以随便从某乎等一些网站进行搜索,安装即可。

Step2:基础环境依赖
打开Ubuntu的命令行,依次输入以下内容

sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install cmake-gui
sudo apt-get install pkg-config
sudo apt-get install python-dev
sudo apt-get install python-numpy
sudo apt-get install git
sudo apt-get install vim cmake
sudo apt-get install git
sudo apt-get install gcc g++

Step3:安装eigen

(注意下面内容是一行输入的,这里空间太小,换行了)

wget https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.zip

unzip -O cp936 eigen-3.3.9.zip
cd eigen-3.3.9
mkdir build
cd build
cmake …
make
sudo make install

Step4:安装g2o

1.git clone https://github.com/RainerKuemmerle/g2o.git
2.cd g2o
3.mkdir build
4.cd build
5.cmake …
6.make
7.sudo make install

Step5:安装OctoMap

1.git clone https://github.com/OctoMap/octomap.git
2.cd octomap
3.mkdir build
4.cd build
5.cmake …
6.make
7.sudo make install

Step6:安装Sophus

git clone https://github.com/strasdat/Sophus.git
cd Sophus
mkdir build
cd build
cmake …
make
sudo make install

Step7:安装Pangolin

1 sudo apt install libgl1-mesa-dev
2 sudo apt install libglew-dev
3 sudo apt install libpython2.7-dev
4 sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
5 sudo apt install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
6 sudo apt install libdc1394-22-dev libraw1394-dev
7 sudo apt install libjpeg-dev libpng12-dev libtiff5-dev libopenexr-dev
8 git clone https://github.com/zzx2GH/Pangolin.git
9 cd Pangolin
10 mkdir build
11 cd build
12 cmake …
13 make
14 sudo make install

Step8:安装Glog

git clone https://github.com/google/glog.git
cd glog
cmake -H. -Bbuild -G “Unix Makefiles”
cmake --build build
cmake --build build --target test
cmake --build build --target install

Step9:安装Gflags

git clone https://github.com/gflags/gflags.git
cd gflags
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON DBUILD_STATIC_LIBS=ON …
make
sudo make install

Step10:安装Ceres

sudo apt-get install libatlas-base-dev liblapack-dev
sudo apt-get install libsuitesparse-dev libcxsparse3.1.4
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
mkdir build
cd build
cmake …
make
sudo make install

Step11:安装OpenCV3.4
首先下载包 百度网盘 https://pan.baidu.com/s/1XFsJMEgDPWRLiyGrAzVl4A 提取码slam
(我在windows里面把这个下载好,然后用U盘考到Ubuntu系统里面)

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev
libjpeg.dev
sudo apt-get install libtiff4.dev libswscale-dev libjasper-dev
tar -zxvf 文件名
cd opencv-3.4.5
mkdir build
cd build
cmake …
make
sudo make install
sudo vim /etc/ld.so.conf.d/opencv.conf

在打开的空白文件中添加 /usr/local/lib
执行 sudo ldconfig ,使配置的环境变量生效
(配置 .bashrc ,末尾添加下面两行)
//打开.bashrc

sudo vim /etc/bash.bashrc

//添加以下两行内容到.bashrc

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export
PKG_CONFIG_PATH

source 与 update

source /etc/bash.bashrc
sudo updatedb

测试是否正常安装 (成功会出现带 “hello opcv” 字样的窗口)

cd opencv-3.4.5/samples/cpp/example_cmake
cmake …
make
./opencv_example

Step12:安装DBoW3

git clone https://github.com/rmsalinas/DBow3.git
cd DBoW3
mkdir build
cd build
cmake …
make
sudo make install

Step13:安装运行ORB-SLAM2

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

有了ORB-SLAM2文件夹以后,还需要以下操作

cd ORB-SLAM2
cd Thirdparty/DBoW2
mkdir build
cd build
cmake …-DCMAKE_BUILD_TYPE=Release
make -j

cd ORB-SLAM2
cd Thirdparty/g2o
mkdir build
cd build
cmake … -DCMAKE_BUILD_TYPE=Release
make -j

cd ORB-SLAM2
(mkdir build) //这个之前创建过了,省略这步
cd build
cmake …-DCMAKE_BUILD_TYPE=Release
make -j

通过以上的操作,slam的环境就差不多配好了,现在差数据集和启动slam的代码,下面讲解

运行代码:

./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /home/huang/rgbd_dataset_freiburg1_rpy

其中:
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1(这个地方的1根据后面那个数据集是1或者2或者3来进行修改即可!).yaml /home/huang/rgbd_dataset_freiburg1_rpy(这个地方直接换数据集即可)

数据集下载网站:https://vision.in.tum.de/data/datasets/rgbd-dataset/download

以上是配置ORB-SLAM2的详细教程,欢迎讨论 + 点赞收藏

日常更新遇到的问题,也欢迎大家来帮忙解决!

你可能感兴趣的:(SLAM+计算机视觉,自动驾驶,ubuntu,人工智能)