https://github.com/HKUST-Aerial-Robotics/VINS-Fusion
https://blog.csdn.net/haner27/article/details/104004745
0环境
opencv3.4.9
ubuntu20
1.ROS安装
我自己的是ubuntu20
安装ros后,安装需要补充的ROS 功能包:
sudo apt-get install ros-melodic-cv-bridge ros-melodic-tf ros-melodic-message-filters ros-melodic-image-transport
1.2 修改ros cv bridge
https://blog.csdn.net/zhaodeming000/article/details/119859665
ros自带的 bridge 是opencv4的,自己的是opencv3.4.9,需要单独重新编译下
究其原因,是因为在安装ROS时,cv_bridge默认连接了4.0+版本的opencv进行编译。只修改cvbridgeConfig.cmake
中opencv的路径,编译可能没问题,但在代码执行时如果引用到libcv_bridge.so
,还是会链接到opencv原来的版本。
1.卸载原来版本的cv_bridge
sudo apt-get remove ros-noetic-cv-bridge
2.下载新版本cv_bridge
浏览器打开
https://github.com/ros-perception/vision_opencv
选择noetic对应的cv_bridge,
或者直接,
git clone https://github.com/ros-perception/vision_opencv/tree/melodic
![](https://img2023.cnblogs.com/blog/1008336/202302/1008336-20230207001926936-161243625.png)
3.修改cv_bridge中的cmakelists.txt
find_package(OpenCV 3.4.10 REQUIRED) //改成你安装的opencv的版本
4.cmake单独编译cv_bridge
在cv_bridge文件夹下,
mkdir build cd build cmake .. sudo make sudo make install
5.在开源代码需要的cmaklist.txt中添加cv_bridge的cmake路径
set(cv_bridge_DIR /usr/local/share/cv_bridge/cmake) //在find_package前面
比如,在vinsfusion开源SLAM代码中,只需要在loop_fusion和vins_estimator两个子模块的cmakelist.txt开头添加set,即可完美编译通过。
2.ceres solver安装
2.安装ceres1.14.0
接着从以下链接安装ceres1.14.0:
https://codeload.github.com/ceres-solver/ceres-solver/tar.gz/refs/tags/1.14.0
http://ceres-solver.org/installation.html
(之前openvslam 安装了cere版本直接编译报错,大概率不适配,这里安装最新的,以后如果要开启openvslam 记得还原对应ceres版本重装 sudo make uninstall)
官方给的源是国外源,下载不了,这里是国内的下载链接
https://github.com/ceres-solver/ceres-solver.git
# CMake sudo apt-get install cmake # google-glog + gflags sudo apt-get install libgoogle-glog-dev libgflags-dev # Use ATLAS for BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 sudo apt-get install libeigen3-dev # SuiteSparse (optional) sudo apt-get install libsuitesparse-dev
#14.04 sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libeigen3-dev libgtest-dev #18.04 20.04 sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libeigen3-dev libgtest-dev git clone https://github.com/ceres-solver/ceres-solver.git cd ceres-solver/ mkdir build cd build cmake .. make sudo make install
如果报错cuda错误,大概率是找不到cuda的位置,手动添加cmakelist.txt
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
记得安装依赖项,记得最后的make install
3.VINS_Fusion安装
创建ros空间
安装VINS_Fusion
cd ~/catkin_ws/src git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git cd ../ catkin_make source ~/catkin_ws/devel/setup.bash
注:直接git获取VINS_Fusion,由于网络原因获取不成功,换了个电脑在github网站下载后,放到/catkin_ws/src文件夹中即可。
cd ~/catkin_ws catkin_make source ~/catkin_ws/devel/setup.bash
opencv报错解决
1 添加头文件
cv::CV_GRAY2RGB 报错替换为
COLOR_GRAY2RGB
对应文件添加
#include<opencv2/imgproc/types_c.h>
2 一些老的参数换成新的参数
CV_FONT_HERSHEY_SIMPLEX报错替换 cv::FONT_HERSHEY_SIMPLEX CV_LOAD_IMAGE_GRAYSCALE报错替换 cv::LOAD_IMAGE_GRAYSCALE CV_LOAD_IMAGE_GRAYSCALE报错替换 cv::ImreadModes::IMREAD_GRAYSCALE
3跑通实例
相机参数
设置输出参数
数据位置
#!/bin/sh #延迟5秒执行 sleep 1 echo "运行开始" #可视化 cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin source devel/setup.bash roslaunch vins vins_rviz.launch # 实时双目视觉vo cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin source devel/setup.bash rosrun vins kitti_gps_test /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml /media/dongdong/Elements/数据集/公共数据集/vinskkt数据/2011_10_03_drive_0027_sync # gps全局优化 cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin source devel/setup.bash rosrun global_fusion global_fusion_node
自动脚本
给与脚本权限
sudo chmod -R 777 run.sh
脚本内容
#!/bin/sh #延迟5秒执行 sleep 1 echo "运行开始" gnome-terminal -t "1-vins_rviz" -x bash -c "\ cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin ;\ source devel/setup.bash ;\ roslaunch vins vins_rviz.launch ;\ exit;exec bash;" sleep 3 echo "2 kitti_gps_test" gnome-terminal -t "2-kitti_gps_test" -x bash -c "\ cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin ;\ source devel/setup.bash ;\ rosrun vins kitti_gps_test /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml /media/dongdong/Elements/数据集/公共数据集/vinskkt数据/2011_10_03_drive_0027_sync ;\ exit;exec bash;" sleep 1 echo "3 global_fusion" gnome-terminal -t "3-global_fusion" -x bash -c "\ cd /home/dongdong/v2_Project/v3_SLAM/v5_VinsFusion/catkin ;\ source devel/setup.bash ;\ rosrun global_fusion global_fusion_node ;\ exit;exec bash;" sleep 1
4.KITTI数据集下载
http://www.cvlibs.net/datasets/kitti/raw_data.php
国外源打不开,感谢这个博主提供的国内源下载:https://blog.csdn.net/weixin_43599336/article/details/86533572
(刚开始可以下载,后来中断了,网页打不开,等一会再下就可以)
泡泡链接(百度网盘):https://www.sohu.com/a/219232053_715754
这两个链接都没能成功下载,最后找到了下面的链接:
https://www.dalipan.com/detail/40c8f99ba2120a493a148f8332094668
终于成功下载了。。
5.跑通KITTI数据集
1.KITTI Odometry (Stereo):使用sequences 00数据集
roslaunch vins vins_rviz.launch (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml rosrun vins kitti_odom_test ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml YOUR_DATASET_FOLDER/sequences/00/
2.KITTI GPS Fusion (Stereo + GPS):使用 2011_10_03_drive_0027_synced 数据集
Green path is VIO odometry; blue path is odometry under GPS global fusion
绿色路径是VIO里程计结果,蓝色路径是GPS+odometry全局融合后的结果。
注:开多个终端,跑上面的语句,如果rosrun的时候找不到包,重新运行一下:
source ~/catkin_ws/devel/setup.bash
查看话题
rostopic list
问题:这里GPS数据与Stereo方向不一致?
答:感谢博友“贵在坚持,不忘初心”的解答,这里的GPS数据与Stereo都是原始数据,没有进行对齐以及坐标转换,所以垂直是正常的,而vins-fusion所做的就是将两者对齐,得到融合的结果。
补充说明:
若运行roscore提示已经有一个在运行,但实际上并没有打开,那么可以在终端执行下面的命令:
killall -9 roscore
killall -9 rosmaster