一、安装依赖:
关于这篇文章的所有依赖库我全部放到网盘上了,或者你也可以去网上下对应的版本,:
链接:https://pan.baidu.com/s/1yEfF0MAeIh2JU46ZyCXmWg?pwd=t5ix
提取码:t5ix
在安装依赖前请确保你的Ubuntu系统有cmake、python2等环境。
① fmt安装:
在网盘中下载好依赖传入虚拟机指定目录
使用unzip fmt-master.zip
解压
编译:
cd fmt-master
mkdir build
cd build
cmake ..
make
sudo make install
② Sophus安装:
在网盘中下载好依赖传入虚拟机指定目录
使用tar -zxvf Sophus.tar.gz
解压
编译:
cd Sophus
mkdir build
cd build
cmake ..
make
sudo make install
③ g2o优化库安装:
在网盘中下载好依赖传入虚拟机指定目录
使用unzip g2o-20230223_git.zip
解压
cd g2o-20230223_git
mkdir build
cd build
cmake ..
make
sudo make install
二、TUM数据集下载
数据集下载主页:https://cvg.cit.tum.de/data/datasets
下载上传到虚拟机指定目录:
解压tar -zxvf rgbd_dataset_freiburg1_xyz.tgz
进入文件夹在这里下载 associate.py 文件(这里的py文件是将rgbdata.txt 和depthdata.txt 转换成生成的associate.txt是rgb在前depth在后的形式)
放到解压后的数据集文件中执行
python associate.py rgb.txt depth.txt > associate.txt
三、编译工程
进入/home/zqh/slambook-master/project/0.2
修改config 文件夹中 yaml配置文件的数据集目录:
编译:
在/home/zqh/slambook-master/project/0.2下执行
mkdir build
cd build
cmake ..
make
报错:
CMakeFiles/run_vo.dir/run_vo.cpp.o: In function `main':
run_vo.cpp:(.text.startup+0xf23): undefined reference to `Sophus::SE3::inverse() const'
run_vo.cpp:(.text.startup+0xf62): undefined reference to `Sophus::SO3::matrix() const'
run_vo.cpp:(.text.startup+0xf81): undefined reference to `Sophus::SO3::matrix() const'
run_vo.cpp:(.text.startup+0xfa0): undefined reference to `Sophus::SO3::matrix() const'
run_vo.cpp:(.text.startup+0xfbf): undefined reference to `Sophus::SO3::matrix() const'
run_vo.cpp:(.text.startup+0xfde): undefined reference to `Sophus::SO3::matrix() const'
CMakeFiles/run_vo.dir/run_vo.cpp.o:run_vo.cpp:(.text.startup+0xffd): more undefined references to `Sophus::SO3::matrix() const' follow
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator=(Sophus::SE3 const&)'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3()'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::log() const'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3(Sophus::SE3 const&)'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator*(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3(Sophus::SO3 const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)'
../../lib/libmyslam.so: undefined reference to `Sophus::SO3::SO3(double, double, double)'
../../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator*(Sophus::SE3 const&) const'
collect2: error: ld returned 1 exit status
test/CMakeFiles/run_vo.dir/build.make:136: recipe for target '../bin/run_vo' failed
make[2]: *** [../bin/run_vo] Error 1
CMakeFiles/Makefile2:140: recipe for target 'test/CMakeFiles/run_vo.dir/all' failed
make[1]: *** [test/CMakeFiles/run_vo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
CMakeLists.txt中的Sophus
# Sophus
find_package( Sophus REQUIRED )
include_directories( ${Sophus_INCLUDE_DIRS} )
原因分析:
安装Sophus时,有个lib文件“libSophus.so”会出现在/usr/local/lib/libSophus.so 时,libSophus.so 应该被链接到 Sophus_LIBRARIES, cmake没链接上。
应该更改为:
# Sophus
find_package( Sophus REQUIRED )
set(Sophus_LIBRARIES libSophus.so)
include_directories( ${Sophus_INCLUDE_DIRS} )
编译通过
返回到/home/zqh/slambook-master/project/0.2 执行:
bin/run_vo config/default.yaml
出现错误:
将CMakeLists.txt中的Sophus改为:
# Sophus
find_package( Sophus REQUIRED )
set(Sophus_LIBRARIES /usr/local/lib/libSophus.so)
include_directories( ${Sophus_INCLUDE_DIRS} )
再次执行:
bin/run_vo config/default.yaml