这里将记录一些我学习SLAM十四讲的总结心得以及实际操作,包括数学公式和理论推导,以及代码调试等,会持续不定时的更新
SLAM代码需要在Linux下编译,因此我选择采用虚拟机配置Debian系统进行环境配置(Ubuntu用太久了换换口味~)
通过VM Workbench + Debian10镜像创建系统
包括gedit, nano, G++, cmake, git等等常用工具:
sudo apt install gedit nano g++ gcc cmake cmake-gui git gdb
opencv与contrib安装较慢,因此先安装这两个部分,首先安装依赖项,
sudo apt install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libpng-dev libjpeg-dev libtiff5-dev libswscale-dev libjasper-dev libdc1394-22-dev libtiff-dev python-dev python-numpy libtbb2 libtbb-dev
这里有一个问题就是libjasper-dev的包被Debian10遗弃了。这个包主要用于JPEG-2000格式的图片处理,因此我没有安装这个包
随后git clone opencv的官方源码(如果网速太慢可以选择gitee上的opencv源)
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
开始cmake和编译安装
cd opencv
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) -D WITH_TBB=ON -D WITH_EIGEN=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ -D OPENCV_GENERATE_PKGCONFIG=ON
make -j2
sudo make install
接着需要配置opencv的环境,
# 把opencv库添加到系统路径
sudo nano /etc/ld.so.conf.d/opencv.conf
# 这是一个空白文件,在后面添加
# /usr/local/opencv/lib
sudo ldconfig
# #配置pkg-config
sudo nano /etc/bash.bashrc
# 在末尾添加
# PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
# export PKG_CONFIG_PATH
# 更新bash配置
source /etc/bash.bashrc
sudo updatedb
最后测试一下配置是否正确,
pkg-config --libs opencv4
# 如果出现 -lopencv_core 等一长串链接库则说明配置正确
首先git下十四讲的代码和第三方包,
git clone https://github.com/gaoxiang12/slambook2.git
cd slambook2
git submodule update --init --recursive
cd 3rdparty
sudo apt-get install automake autoconf g++ libtool
sudo apt-get install kdevelop
sudo apt-get install libeigen3-dev
sudo updatedb
locate eigen3
# 当前路径在slambook2/3rdparty
cd Sophus
git checkout a621ff
mkdir build
cd build
cmake ..
make -j2
# 这里有个BUG,需要把Sophus/sophus/so2.cpp中的
# unit_complex_.real() = 1. ;
# unit_complex_.imag() = 0. ;
# 改为
# unit_complex_.real(1.) ;
# unit_complex_.imag(0.) ;
# 当前路径在slambook2/3rdparty
sudo apt-get install libglew-dev libboost-dev libboost-thread-dev libboost-filesystem-dev
cd Pangolin
mkdir build && cd build
cmake ..
make -j2
sudo make install
sudo apt-get install libpcl-dev pcl-tools
# 当前路径在slambook2/3rdparty
sudo apt-get install liblapack-dev libsuitesparse-dev libgflags-dev libgoogle-glog-dev libgtest-dev libcxsparse3
cd ceres-solver
mkdir build
cd build
cmake ..
make -j2
sudo make install
# 当前路径在slambook2/3rdparty
sudo apt-get install libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-headers
cd g2o
mkdir build
cd build
cmake ..
make -j2
sudo make install
sudo add-apt-repository ppa:zarquon42/meshlab
sudo apt-get update
sudo apt-get install meshlab
git clone https://github.com/OctoMap/octomap.git
sudo apt-get install doxygen-latex doxygen-doc doxygen-gui graphviz libclang1-6.0
cd octomap
mkdir build
cd build
cmake ..
make -j2
sudo make install
cd DBow3
mkdir build
cd build
cmake ..
make -j2
sudo make install
最后总结一下各软件包的作用:
opencv: 图像处理
kdevelop: IDE
Eigen: 线性代数、矩阵计算
Sophus: 李代数库
Pangolin: 3D可视化
PCL: 点云库
Ceres-solver: 非线性优化库
g2o: 图优化
Meshlab: 三维几何网格处理
Octomap: 地图创建工具
DBoW3: 图像特征排序