目录
- 前言
- 1、准备
- 1.1 安装ROS
- 1.2 安装 Ceres Solver
- 2、安装 VINS-Fusion
- 3、测试(EuRoC MAV 数据集)
- 3.1、下载数据集
- 3.2 Monocualr camera + IMU
- 3.3 Stereo cameras + IMU
- 3.4 Stereo cameras
- 参考
前言
VINS-Fusion 是一种基于优化的多传感器状态估计器,可为自主应用(无人机、汽车和 AR/VR)实现精确的自定位。它常用于无人机的自主导航和飞行控制,通过融合视觉和惯性数据实现高精度定位和导航。VINS-Fusion 是 VINS-Mono 的扩展,它支持多种视觉惯性传感器类型(单目摄像头 + IMU、双目摄像头 + IMU,只有双目摄像头)。
我的配置如下:
虚拟机 Ubuntu 18.04 (运行内存 4G、硬盘内存 60G) 、ROS melodic 、ceres-solver 1.14
1、准备
1.1 安装ROS
安装 VINS-Fusion 之前必须要安装好ROS,ROS安装教程可以参考这篇文章👇
ubuntu安装ROS melodic(最新、超详细图文教程,包含配置rosdep)-CSDN博客
注:没有创建工作空间,可以执行下列代码,如果创建了可以跳过(catkin_make 与 catkin build 是编译功能包的两种工具,任选其一即可)
sudo apt-get install python-catkin-tools python-rosinstall-generator -y
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
catkin build
# catkin_make
# mkdir -p ~/catkin_ws/src
# cd catkin_ws/src && catkin_init_workspace
# cd .. && catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
1.2 安装 Ceres Solver
Ceres Solver 是一个开源的 C++ 库,用于解决非线性最小二乘问题。它的自动微分、鲁棒优化算法以及高效的并行计算能力,使其成为解决复杂非线性优化问题的理想选择。它被广泛应用于计算机视觉、机器人和图像处理领域中的优化问题。
Ceres Solver 官方文档
GitHub 仓库
- 安装依赖:
# 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 (可以安装,也可以不安装)
sudo apt-get install libsuitesparse-dev
- 下载 Ceres Solver 源码:
wget ceres-solver.org/ceres-solver-1.14.0.tar.gz
- 编译 Ceres Solver :
tar zxf ceres-solver-1.14.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-1.14.0
make -j3 # 大概几分钟
make test
# 这一步必须每个 test 都通过
- 安装 Ceres Solver :
# 可选择 make isntall 安装 Ceres,也可使用 CMake 导出,CMake 可以无需安装即可使用 Ceres
# 更多信息请参阅 EXPORT_BUILD_DIR 选项的文档,有关 EXPORT_BUILD_DIR 选项的更多信息。
sudo make install
- 测试:
./bin/simple_bundle_adjuster ../ceres-solver-1.14.0/data/problem-16-22106-pre.txt
测试结果:
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time0 4.185660e+06 0.00e+00 1.09e+08 0.00e+00 0.00e+00 1.00e+04 0 5.62e-02 1.64e-011 1.062590e+05 4.08e+06 8.99e+06 5.36e+02 9.82e-01 3.00e+04 1 1.26e-01 2.90e-012 4.992817e+04 5.63e+04 8.32e+06 3.19e+02 6.52e-01 3.09e+04 1 1.18e-01 4.08e-013 1.899774e+04 3.09e+04 1.60e+06 1.24e+02 9.77e-01 9.26e+04 1 1.20e-01 5.28e-014 1.808729e+04 9.10e+02 3.97e+05 6.39e+01 9.51e-01 2.78e+05 1 1.20e-01 6.48e-015 1.803399e+04 5.33e+01 1.48e+04 1.23e+01 9.99e-01 8.33e+05 1 1.20e-01 7.67e-016 1.803390e+04 9.02e-02 6.35e+01 8.00e-01 1.00e+00 2.50e+06 1 1.19e-01 8.86e-01Solver Summary (v 1.14.0-eigen-(3.3.4)-lapack-suitesparse-(5.1.2)-cxsparse-(3.1.9)-eigensparse-openmp-no_tbb)Original Reduced
Parameter blocks 22122 22122
Parameters 66462 66462
Residual blocks 83718 83718
Residuals 167436 167436Minimizer TRUST_REGIONDense linear algebra library EIGEN
Trust region strategy LEVENBERG_MARQUARDTGiven Used
Linear solver DENSE_SCHUR DENSE_SCHUR
Threads 1 1
Linear solver ordering AUTOMATIC 22106,16
Schur structure 2,3,9 2,3,9Cost:
Initial 4.185660e+06
Final 1.803390e+04
Change 4.167626e+06Minimizer iterations 7
Successful steps 7
Unsuccessful steps 0Time (in seconds):
Preprocessor 0.107879Residual only evaluation 0.093588 (7)Jacobian & residual evaluation 0.309654 (7)Linear solver 0.358153 (7)
Minimizer 0.848724Postprocessor 0.003480
Total 0.960084Termination: CONVERGENCE (Function tolerance reached. |cost_change|/cost: 1.769761e-09 <= 1.000000e-06)
2、安装 VINS-Fusion
执行下列命令:
cd ~/catkin_ws/src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git
cd ../
catkin build # 大概几分钟
source ~/.bashrc
3、测试(EuRoC MAV 数据集)
3.1、下载数据集
点击下载地址 ,下载 MH_01_easy.bag,浏览器默认下载到 Downloads 目录。
3.2 Monocualr camera + IMU
执行下面命令:
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml
(可选) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml
rosbag play ~/Downloads/MH_01_easy.bag
3.3 Stereo cameras + IMU
执行下面命令:
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
(可选) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
rosbag play ~/Downloads/MH_01_easy.bag
3.4 Stereo cameras
执行下面命令:
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml
(可选) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml
rosbag play ~/Downloads/MH_01_easy.bag
参考
VINS-Fusion 论文
GitHub - HKUST-Aerial-Robotics/VINS-Fusion: An optimization-based multi-sensor state estimator
Installation — Ceres Solver (ceres-solver.org)
vins-fusion环境配置、安装与测试-CSDN博客
Installation — Ceres Solver (ceres-solver.org)
vins-fusion环境配置、安装与测试-CSDN博客