因已安装ROS noetic,eigen,opencv及ceres等库,这部分环境配置就不细讲,直接下载VINS-FUSION的代码库
cd ~/vins-fusion/src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git
cd ../
catkin_make
source ~/catkin_ws/devel/setup.bash
编译时会发现一堆错误,别急,无非就是环境冲突问题,一个个解决
1)首先,ROS noetic版本中自带的OpenCV4和VINS-mono中需要使用的OpenCV3冲突的问题。修改vins-mono代码兼容opencv4。其实主要修改的是camera_model这个包,幸运的是发现不用修改代码中不兼容的变量,而是可以直接包含缺失的头文件即可。于是参考opencv参考文档查找opencv4中未定义的变量在opencv3中所属的头文件,然后添加到camera_model相应的头文件中顺利解决问题。
在camera_model包中的头文件Chessboard.h中添加
#include
#include
在CameraCalibration.h中添加
#include
#include
2)报错:
/usr/local/include/ceres/internal/integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
64 | struct SumImpl<std::integer_sequence<T, N, Ns...>> {
| ^~~~~~~~~~~~~~~~
解决:
这是因为较新版本中的ceres对c++版本有要求
在报错的项目的CMakeList里的
set(CMAKE_CXX_FLAGS “-std=c++11”)
改成
set(CMAKE_CXX_STANDARD 14)
3)编译时遇到报错 error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
将报错文件上的 CV_FONT_HERSHEY_SIMPLEX 参数改为 cv::FONT_HERSHEY_SIMPLEX
4)报错:
error: ‘CV_RGB2GRAY’ was not declared in this scope
53 | cv::cvtColor(image, aux, CV_RGB2GRAY);
| ^~~~~~~~~~~
解决:
在报错头文件里添加
#include
5)报错:
error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
125 | imLeft = cv::imread(leftImagePath, CV_LOAD_IMAGE_GRAYSCALE );
| ^~~~~~~~~~~~~~~~~~~~~~~
但在Opencv4中,CV_LOAD_IMAGE_GRAYSCALE找不到,经过查看Opencv的API可知,CV_LOAD_IMAGE_GRAYSCALE已改为 IMREAD_GRAYSCALE,修改即可。
修改之后即可编译成功。
Monocualr camera + IMU
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml
(optional) rosrun loop_fusion loop_fusion_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml
rosbag play ~/SLAM/test_data/MH_01_easy.bag
Stereo cameras + IMU
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
(optional) rosrun loop_fusion loop_fusion_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
rosbag play ~/SLAM/test_data/MH_01_easy.bag
Stereo cameras
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml
(optional) rosrun loop_fusion loop_fusion_node ~/vins-fusion/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml
rosbag play ~/SLAM/test_data/MH_01_easy.bag
Stereo cameras + GPS
roslaunch vins vins_rviz.launch
rosrun vins kitti_gps_test ~/catkin_ws/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml YOUR_DATASET_FOLDER/2011_10_03_drive_0027_sync/
rosrun global_fusion global_fusion_node