操作系统ubuntu18.04
《视觉 SLAM 十四讲》第二版源码在高翔GitHub上下载GitHub
#安装必要库,将安装一堆新包,包括gcc,g ++和make
sudo apt install build-essential
打开 /etc/ld.so.conf 添加一行内容:/usr/local/lib,保存退出再运行 udo ldconfig,避免错误 ***: cannot open shared object file(没有配置共享库所在文件夹的路径)
使用的是opencv-4.3.0 安装教程
cmake 用来管理c++项目源代码
cmake .. 根据CMakeLists.txt文件,去生成makefile
make -j4 根据makefile文件内容编译工程,即生成可执行文件
make install 将可执行文件、第三方依赖包和文档复制到正确的路径
#到cmake官网下载最新的cmake
https://cmake.org/download/
#下载后解压,然后进入目录执行:
cd cmake-3.**
./bootstrap
make -j8
sudo make install
#验证版本
cmake --version
#使用以下指令解决缺库问题(Could not find OpenSSL):
sudo apt-get install libssl-dev
在ubuntu上安装slam发环境建议先安装opencv,opencv的依赖与下面要安装的依赖有重复。
#终端输入
sudo apt-get install libeigen3-dev
#无需要安装直接将sophus复制到/usr/include中(qt中直接引库,调用.hpp)
sudo cp -r /slambook2/3rdparty/Sophus/sophus /usr/include
#安装依赖库
sudo apt-get install libglew-dev # OpenGL库
sudo apt-get install pkg-config
sudo apt-get install doxygen
#进入Pangolin源码目录,创建build 目录,cd build 运行
sudo mkdir build && cd build
#生成Makefile
sudo cmake ..
#编译
sudo make -j8
#安装
sudo make install
#错误信息
CMake Error at external/pybind11/tools/FindPythonLibsNew.cmake:95 (message):
Python config failure:
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'sysconfig'
#解决
sudo apt-get install python3-pip
#安装日志和测试工具(glog、gtest)
sudo apt install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
#进入ceres-solver源码目录,创建build 目录,cd build 运行
sudo mkdir build && cd build
#生成Makefile
sudo cmake ..
#编译
sudo make -j8
#安装
sudo make install
#安装依赖项
sudo apt install qt5-qmake qt5-default libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3
#进入g2o源码目录,创建build 目录,cd build 运行
sudo mkdir build && cd build
#生成Makefile
sudo cmake ..
#编译
sudo make -j8
#安装
sudo make install
#进入DBoW3源码目录,创建build 目录,cd build 运行
sudo mkdir build && cd build
#生成Makefile
sudo cmake ..
#编译
sudo make -j8
#安装
sudo make install
#qt使用依赖库 /usr/include/vtk-6.3;/usr/include/boost
sudo apt install libpcl-dev pcl-tools
报错:
The following packages have unmet dependencies:libpcl-dev : Depends: libvtk6-dev but it is not going to be installed Depends: libvtk6-qt-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages.
解决
#使用aptitude 安装
sudo aptitude install libpcl-dev #先选择n,在选择y
sudo apt install liboctomap-dev octovis
#修改/slam2/slambook2/ch5/imageBasics/CMakeLists.txt 配置文件,添加opencv库路径
project(imageBasics)
set(OpenCV_DIR "/usr/lib/opencv")
find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui)
add_executable(imageBasics imageBasics.cpp)
# 链接OpenCV库
target_link_libraries(imageBasics ${OpenCV_LIBS})
add_executable(undistortImage undistortImage.cpp)
# 链接OpenCV库
target_link_libraries(undistortImage ${OpenCV_LIBS})
错误:./g2oCurveFitting: error while loading shared libraries: libg2o_core.so: cannot open shared object file: No such file or directory
解决:打开 sudo gedit /etc/ld.so.conf
添加内容:/usr/local/lib
启动配置:sudo ldconfig
错误:make[2]: *** 没有规则可制作目标“/usr/local/lib/libDBoW3.a”,由“gen_vocab” 需求。 停止。
1解决:打开ch11下面的 sudo gedit CMakeFiles.txt 修改libDBoW3.a为libDBoW3.so
运行错误:terminate called after throwing an instance of 'std::__cxx11::basic_string, std::allocator >' 已放弃 (核心已转储)
2解决:管理员运行:sudo ./feature_training
在终端使用octovis命令打开.bt文件:octovis octomap.bt
在使用pcl_viewer命令打开.pcd文件:pcl_viewer map.pcd
INCLUDEPATH += /usr/include/eigen3 \
/usr/include/opencv4 \
/usr/include/sophus \
/usr/include/glog \
/usr/include/suitesparse \
/usr/local/include/ceres \
/usr/local/include/g2o \
/usr/local/include/DBoW3 \
/usr/include/vtk-6.3 \
/usr/local/include/boost \
/usr/include/pcl-1.8 \
/usr/include/octomap \
LIBS += /usr/lib/opencv/libopencv_*.so \
/usr/local/lib/libceres.a \
/usr/local/lib/libg2o_*.so \
/usr/local/lib/libDBoW3.so \
/usr/lib/x86_64-linux-gnu/libcholmod.so \
/usr/lib/x86_64-linux-gnu/liblapack.so \
/usr/lib/x86_64-linux-gnu/libblas.so \
/usr/lib/x86_64-linux-gnu/libcxsparse.so \
/usr/lib/x86_64-linux-gnu/libglog.so \
/usr/lib/x86_64-linux-gnu/libvtk*.so \
/usr/lib/x86_64-linux-gnu/libboost_*.so \
/usr/lib/x86_64-linux-gnu/libpcl_*.so \
/usr/lib/liboctomath.so \
/usr/lib/liboctomap.so \
1错误:
error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow’
1解决:
opencv图片路径错误,或 图片的名称和路径改成英文或数字
2错误:
undefined reference to google::LogMessage::stream()' undefined reference to
google::FlagRegisterer::FlagRegisterer(char const*, char const*, char const*, bool*, bool*)’
2解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/glog
LIBS += /usr/lib/x86_64-linux-gnu/libglog.so
3错误:
error: vtkSmartPointer.h: No such file or directory
#include
^~~~~~~~~~~~~~~~~~~
3解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/vtk-6.3
LIBS += /usr/lib/x86_64-linux-gnu/libvtk*.so
4错误:
/usr/lib/liboctomath.so.1.8 error: error adding symbols: DSO missing from command line
4解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/octomap
LIBS += /usr/lib/liboctomath.so
5错误:
reorder_program.cc:(.text+0x396): undefined reference to `cholmod_free_sparse’
5解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/suitesparse
LIBS += /usr/lib/x86_64-linux-gnu/libcholmod.so
6错误:
/usr/lib/x86_64-linux-gnu/liblapack.so.3: error adding symbols: DSO missing from command line
6解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/suitesparse
LIBS += /usr/lib/x86_64-linux-gnu/liblapack.so
7错误:
/usr/local/lib/libceres.a(cxsparse.cc.o): In function ceres::internal::CXSparse::Solve(cs_di_symbolic*, cs_di_numeric*, double*)': cxsparse.cc:(.text+0x92): undefined reference to
cs_di_ipvec’
7解决:
在qt的pro中添加共享库
INCLUDEPATH += /usr/include/suitesparse
LIBS += /usr/lib/x86_64-linux-gnu/libcxsparse.so