说明
安装步骤
1、安装opencv3.3.1
我的环境中本来有opencv4.5.4,但据说4版本对VINS-Mono支持不完善,所以又装了opencv3.3.1 参考教程:https://blog.csdn.net/darnell888/article/details/110734510
2、安装ros依赖包
sudo apt-get install ros-melodic-cv-bridge ros-melodic-tf ros-melodic-message-filters ros-melodic-image-transport
3、安装Ceres Solver
因为我的环境中已经装了ceres,所以没有操作这一步。 官方教程:http://ceres-solver.org/installation.html 也可以参考:https://www.ncnynl.com/archives/202008/3859.html
4、安装cv_bridge
这个我也已经装了 可以参考:https://www.ncnynl.com/archives/202008/3859.html
5、下载并编译VINS-Mono源码
cd ~/catkin_ws/src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git
cd ../
catkin_make
source ~/catkin_ws/devel/setup.bash
指定使用opencv版本3.3.1
找到如下包的CMakelist.txt文件
ar_demo
pose_graph
vins_estimator
camera_model
feature_tracker
在find_package(OpenCV REQUIRED)行前面加上
set(OpenCV_DIR /home/nx/my_library/opencv/opencv-3.3.1/build/)
find_package(OpenCV 3.3.1 REQUIRED)
OpenCV_DIR后面是你自己的opencv包路径
出现的错误及解决方法
- 错误1:cv_bridgeConfig.cmake出错
出现错误类似下面情况:
CMake Error at /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake:113 (message):
Project 'cv_bridge' specifies '/usr/include/opencv4/opencv' as an include
dir, which is not found. It does neither exist as an absolute directory
nor in '${prefix}//usr/include/opencv4/opencv'. Check the issue tracker
'https://github.com/ros-perception/vision_opencv/issues' and consider
creating a ticket if the problem has not been reported yet.
Call Stack (most recent call first):
CMakeLists.txt:54 (find_package)
-- Configuring incomplete, errors occurred!
原因:多版本OpenCV出现冲突 解决方法: 参考:https://blog.csdn.net/klsjadkls/article/details/119170761 首先检查opencv cflags:
$ pkg-config --cflags opencv
-I/usr/local/include/opencv -I/usr/local/include
然后修改cv_bridgeConfig.cmake中的内容 找到cv_bridgeConfig.cmake (94行),原内容如下(方便备份):
if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/include;/usr/include/opencv")
改成:
if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/local/include/opencv;/usr/local/include")
出现错误类似下面情况:
VINS-Mono/vins_estimator/CMakeFiles/vins_estimator.dir/build.make:62: recipe for target 'VINS-Mono/vins_estimator/CMakeFiles/vins_estimator.dir/src/estimator_node.cpp.o' failed
make[2]: *** [VINS-Mono/vins_estimator/CMakeFiles/vins_estimator.dir/src/estimator_node.cpp.o] Error 4
make[2]: *** Waiting for unfinished jobs....
[ 52%] Linking CXX executable /home/ubuntu/vins-ws/devel/lib/feature_tracker/feature_tracker
[ 52%] Built target feature_tracker
CMakeFiles/Makefile2:2166: recipe for target 'VINS-Mono/vins_estimator/CMakeFiles/vins_estimator.dir/all' failed
make[1]: *** [VINS-Mono/vins_estimator/CMakeFiles/vins_estimator.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
原因:可能是用于编译的内存或交换空间不够 解决方法: 参考:https://github.com/HKUST-Aerial-Robotics/VINS-Mono/issues/9 官方给出的解决方式是:尝试"catkin_make -j1",或者一个包一个包编译,顺序是camera_model->feature_tracker->vins_estimator->ar_demo 我尝试"catkin_make -j1"没有用,第二种方法没试,因为重启后这个问题就意外解决了。
6、测试
首先要下载EuRoC数据集 官方地址:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets 如果下的很慢,也可以自行百度找网盘资源 测试命令如下:
roslaunch vins_estimator euroc.launch
roslaunch vins_estimator vins_rviz.launch
rosbag play YOUR_PATH_TO_DATASET/MH_01_easy.bag
出现的错误及解决方法
|