①更新apt
sudo apt-get update
②安装git
sudo apt-get install git
③安装cmake
sudo apt-get install cmake
④安装gcc、g++
sudo apt-get install g++
sudo apt-get install gcc
2、安装Pangolin
①安装依赖项
sudo apt-get install libglew-dev libpython2.7-dev
②下载Pangolin
git clone https://github.com/stevenlovegrove/Pangolin.git
③编译安装
cd Pangolin
mkdir build
cd build
cmake ..
make -j
sudo make install
3、安装opencv
①安装依赖项
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
②下载opencv
wget -O opencv-3.4.1.zip https://github.com/Itseez/opencv/archive/3.4.1.zip
③解压opencv包
unzip opencv-3.4.1.zip
④编译并安装
cd ~/opencv-3.4.1
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release –D CMAKE_INSTALL_PREFIX=/usr/local ..
⑤
make -j8
⑥将编译后的文件安装到系统
sudo make install
⑦配置编译环境,将OpenCV的库添加到路径
sudo gedit /etc/ld.so.conf.d/opencv.conf
⑧使配置路径生效
sudo ldconfig
⑨配置bash,在末尾添加如下代码
sudo gedit /etc/bash.bashrc
⑩使配置生效
source /etc/bash.bashrc
4、安装Eigen3
sudo apt-get install libeigen3-dev
5、安装ORB-SLAM2
①下载ORB-SLAM2
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
②编译ORB-SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh
③配置环境
sudo gedit ~/.bashrc
source ./catkin_ws/devel/setup.sh
添加以下代码,注意修改为自己设置的路径
④使修改的文件生效
source ~/.bashrc
⑤修改Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件,添加如下代码
cd catkin_ws/src/ORB_SLAM2
chmod +x build_ros.sh
./build_ros.sh
6、运行SLAM实例
①从http://vision.in.tum.de/data/datasets/rgbd-dataset/download下载数据集并解压
②编译,注意修改为自己的路径
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txtExamples/Monocular/TUMX.yaml PATH_TO_SEQUENCE_FOLDER
7、遇到的问题
在编译ORB-SLAM2时出现错误,出错提示是:无法分配内存
解决办法:手动增加swap空间,代码如下
sudo -s
dd if=/dev/zero of=/tmp/newdisk bs=1M count=8000 //分配8G
du -sh /tmp/newdisk
mkswap -f /tmp/newdisk
free -m
chmod 0600 /tmp/newdisk
8、参考文献
①https://my.oschina.net/u/3707314/blog/1560180
②https://blog.csdn.net/qq_42585108/article/details/105519029