整个SVO2.0环境搭建过程按照官网的说明进行(链接:https://github.com/uzh-rpg/rpg_svo_pro_open)
开发环境是ubuntu18.04+ROS-Melodic
Install catkin tools and vcstools if you haven’t done so before. Depending on your operating system
# For Ubuntu 18.04 + Melodic
sudo apt-get install python-catkin-tools python-vcstool
Install system dependencies and dependencies for Ceres Solver
# system dep.
sudo apt-get install libglew-dev libopencv-dev libyaml-cpp-dev
# Ceres dep.
sudo apt-get install libblas-dev liblapack-dev libsuitesparse-dev
mkdir svo_ws && cd svo_ws
# see below for the reason for specifying the eigen path
catkin config --init --mkdirs --extend /opt/ros/melodic --cmake-args -DCMAKE_BUILD_TYPE=Release -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3
cd src
# 下载源码
git clone https://github.com/uzh-rpg/rpg_svo_pro_open.git
# 下载源码所需要的其他功能包,下面的命令会下载失败,打开dependencies.yaml文件,
# 根据每个包中的地址,使用git clone分开进行下载
# vcs-import < ./rpg_svo_pro_open/dependencies.yaml
# 这里以第一个为例,其余均按照这种形式进行下载,如果下载失败可能是网络超时,多试几次
git clone https://github.com/catkin/catkin_simple.git
touch minkindr/minkindr_python/CATKIN_IGNORE
# 下载词袋用于位置识别
cd rpg_svo_pro_open/svo_online_loopclosing/vocabularies && ./download_voc.sh
cd ../../..
词袋下载完成后,在src/dbow2_catkin/CmakeList.txt中,将git的地址进行相应的修改
ExternalProject_Add(dbow2_src
#GIT_REPOSITORY git@github.com:dorian3d/DBoW2.git
GIT_REPOSITORY https://github.com/dorian3d/DBoW2.git
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CATKIN_DEVEL_PREFIX}
BUILD_COMMAND CXXFLAGS=-i${CATKIN_DEVEL_PREFIX}/include make
INSTALL_COMMAND make install
)
在src目录下
catkin build -j40
1.编译svo_direct报错,因为在本地安装了单独的yaml-cpp功能包,与ros自带的功能包出现了冲突
libvikit_cameras.so: undefined reference to `YAML::detail::node_data::empty_scalar[abi:cxx11]()'
解决,在rpg_svo_pro_open/vikit/vikit_cameras中的cmakelists.txt中加入以下内容
link_directories(/usr/local/lib)
include_directories(/usr/local/include/yaml-cpp)
2.编译svo_ceres_backend功能包报错,疑似eigen版本不对,需要3.3.7版本,当前为3.3.4
Errors << svo_ceres_backend:make /home/lusx/Demos/svo_ws/logs/svo_ceres_backend/build.make 000.log
In file included from /usr/local/include/eigen3/Eigen/Core:22:0,
from /home/lusx/Demos/svo_ws/src/rpg_svo_pro_open/svo/include/svo/global.h:18,
from /home/lusx/Demos/svo_ws/src/rpg_svo_pro_open/svo/include/svo/abstract_bundle_adjustment.h:12,
from /home/lusx/Demos/svo_ws/src/rpg_svo_pro_open/svo_ceres_backend/include/svo/ceres_backend_interface.hpp:7,
from /home/lusx/Demos/svo_ws/src/rpg_svo_pro_open/svo_ceres_backend/src/ceres_backend_interface.cpp:1:
/usr/local/include/eigen3/Eigen/src/Core/util/ConfigureVectorization.h:39:38: error: attribute ignored in declaration of ‘struct pcl::_PointXYZHSV’ [-Werror=attributes]
#define EIGEN_ALIGN_TO_BOUNDARY(n) alignas(n)
更换eigen版本方法:https://blog.csdn.net/reasonyuanrobot/article/details/114372363
更新完eigen版本后需要将/usr/local/include/Eigen 整个文件夹替换到/usr/local/include/eigen3中,然后将/usr/local/include/eigen3整个文件夹复制到/usr/include目录下
sudo cp -r /usr/local/include/Eigen /usr/local/include/eigen3
sudo cp -r /usr/local/include/eigen3 /usr/include
3.出现报错,svo_ros编译失败:
private/svo/lib/libsvo.so: undefined reference to `YAML::ostream_wrapper::write(std::__cxx11::basic_string, std::allocator > const&)'
在svo的CmakeLists.txt中加入以下内容:
link_directories(/usr/local/lib)
include_directories(/usr/local/include/yaml-cpp)
并在下面对应的地方链接上yaml-cpp的动态库
target_link_libraries(svo ${LINK_LIBS} ${EIGEN3_LIBS} yaml-cpp)
其中有部分功能包需要实时下载,可能会下载失败,直接catkin build多试几次即可。
运行:
在rpg_svo_pro_open/doc目录下有运行的说明文档,以VIO为例
roslaunch svo_ros euroc_vio_stereo.launch
rosbag play V2_03_difficult.bag
1.首先把上面提到的阻止svo_global_map编译的CATKIN_IGNORE删除
cd
rm rpg_svo_pro_open/svo_global_map/CATKIN_IGNORE
2.并且在svo_cmake/cmake/Modules/SvoSetup.cmake中进行以下修改:
SET(USE_GLOBAL_MAP TRUE)
3.在src目录下载GTSAM
git clone --branch 4.0.3 https://github.com/borglab/gtsam.git
并且修改一些GTSAM的编译配置
# 1. gtsam/CMakelists.txt: use system Eigen
# 将对应位置的OFF修改为OFF
-option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" OFF)
+option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" ON)
# 2. gtsam/cmake/GtsamBuildTypes: disable avx instruction set
# below the line `list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC "-march=native")`
list_append_cache(GTSAM_COMPILE_OPTIONS_PUBLIC "-mno-avx")
执行编译
catkin build -j40
4.运行:参考rpg_svo_pro_open/doc/global_map.md
Source the workspace first:
source ~/svo_ws/devel/setup.bash
Executing
roslaunch svo_ros euroc_global_map_mono.launch
rosbag play MH_03_medium.bag -s 15
运行launch文件时报错,重启电脑后解决
inotify_add_watch("/home/lusx/.config/fcitx/dbus") failed: "No space left on device"
inotify_add_watch("/home/lusx/.config/fcitx/dbus/90db5a81999741db9c60033a14d268ae-1") failed: "No space left on device"
[svo-2] process has died [pid 2630, exit code -11, cmd /home/lusx/Demos/svo_ws/devel/lib/svo_ros/svo_node --v=0 __name:=svo __log:=/home/lusx/.ros/log/7ee9c8d4-9f9d-11ed-8d4c-f46b8c68a314/svo-2.log].
log file: /home/lusx/.ros/log/7ee9c8d4-9f9d-11ed-8d4c-f46b8c68a314/svo-2*.log
运行launch文件时报错,疑似个别库的版本不对导致冲突暂未解决
[svo-2] process has died [pid 19424, exit code -11, cmd /home/lusx/Demos/svo_ws/devel/lib/svo_ros/svo_node --v=0 __name:=svo __log:=/home/lusx/.ros/log/57f6132c-9fa2-11ed-b21c-f46b8c68a314/svo-2.log].
log file: /home/lusx/.ros/log/57f6132c-9fa2-11ed-b21c-f46b8c68a314/svo-2*.log