VINS-Mono视觉SLAM总体设计框架解读

文章目录

    • 写在前面
    • 论文解读
      • vins-mono 概述
      • 1. Measurement Preprocessing 过程
      • 2. Estimator Initialization 过程
      • 3. Tightly Computed Monocular VIO
    • 代码解读
      • 各文件夹功能解读
      • 从CMakeLists.txt分析
      • vins_estimator
      • 从多线程角度分析
      • 功能类的问题
    • 附录:
      • 参数/变量 名称
      • class 名称
        • FeatureTracker 特征点追踪类
        • CameraFactory 不同的相机类型和校准模型
        • TicToc 计算时间差的功能类
        • Estimator

写在前面

VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator 的设计思路主要突出两点:

  1. 针对于单目的鲁棒性很强的VIO 系统
  2. 通用性很强的VIO框架

从论文和工程的设计思路无不体现着这两点,从考虑周密的初始化过程,到球面相机模型的引入等等都有体现,至于中间的Keyframe、Sliding Windows 以及4-DoF Pose Graph Optimization都是为了既保证优化的性能,也兼顾系统的实时性所做的一些考量。

论文解读

VINS-Mono视觉SLAM总体设计框架解读_第1张图片

vins-mono 概述

解读vins-mono

  • 首先 Measurement Preprocessing (Vision Processing Front End + IMU Preintegration Processing)开始 ;

  • 然后通过一个松耦合的方式来做初始化;

  • 再通过一个紧耦合的方式来做 Local Visual-inertial Odometry;

1. Measurement Preprocessing 过程

  • Visual Preprocessing 每一帧图像特征点提取和 KLT稀疏光流追踪
  • IMU Preprocessing 两帧图像之间IMU预积分
  • Keyframe Selection

2. Estimator Initialization 过程

  • 首先是 Monocular Vision-Only SfM in Sliding Window 得到一个初步的平移和旋转
  • Camera - IMU rotation calibration
  • Visual-inertial alignment 对齐

3. Tightly Computed Monocular VIO

Nonlinear graph optimization-based, tightly-coupled, sliding windows, visual-inertial bundle adjustment

代码解读

各文件夹功能解读

code 功能
ar_demo 视觉定位的一个小应用demo
benchmark_publisher 订阅估计的estimated_odometry, 然后与CVS中的groundtruth对比
calibration_images 订阅相机的话题,保存成图片,用于相机校准,支持鱼眼相机,针孔相机
camera_model 各种相机模型的校准,入口函数
config 配置参数文件
feature_tracker 使用光流法追踪特征点
pose_graph 后端优化
vins_estimator 状态估计

从CMakeLists.txt分析

CMake files function
vins_estimator/CmakeLists.txt 生成 vins_estimator Node
feature_tracker/CmakeLists.txt 生成 feature_tracker Node
pose_graph/CmakeLists.txt 生成 pose_graph Node
camera_model/CmakeLists.txt 生成Calibration可执行程序 和camera_model库

vins_estimator

  • 入口函数为 estimator_node.cpp/main()

  • readParameters(n); 读取优化参数,IMU噪声和偏置,IMU-camera内参等

  • estimator.setParameter(); tic ric

  • 订阅 imu_callback feature_callback restart_callback relocalization_callback

  • 发布 Odometry path point-cloud

  • 订阅话题的回调函数只是数据缓存到 buf

  • 真正的处理在线程 std::thread measurement_process{process};中

    getMeasurements 通过时间戳,简单地对齐 IMU 和 feature point
    对于每一个IMU数据: estimator.processIMU(dt, Vector3d(dx, dy, dz), Vector3d(rx, ry, rz));
    对于每一帧CAM数据: estimator.processImage(image, img_msg->header);
    publish Odometry/KeyPoses/CameraPose/PointCloud/TF/Keyframe

vins-estimator 主要程序,
pose_garph
feature_tracker 使用光流法追踪特征点
intrinsic_calib.cc 从其他的库复制过来的

从多线程角度分析

功能类的问题

附录:

参数/变量 名称

参数名称 类型 来源 功能
IMAGE_TOPIC string yaml config file/image_topic 订阅图像话题名称
IMU_TOPIC string yaml config file/imu_topic 订阅IMU话题名称
MAX_CNT int yaml config file/max_cnt max feature number in feature tracking
MIN_DIST int yaml config file/min_dist min distance between two features
ROW int yaml config file/image_height 像素行数-图像高度
COL int yaml config file/image_width 像素列数-图像宽度
FREQ int yaml config file/freq frequence (Hz) of publish tracking result. At least 10Hz for good estimation. If set 0, the frequence will be same as raw image
F_THRESHOLD double yaml config file/F_threshold ransac threshold (pixel)
SHOW_TRACK int yaml config file/show_track 是否发布 tracking image话题
EQUALIZE int yaml config file/equalize 当图像太亮/暗,是否打开均衡补偿
FISHEYE int yaml config file/fisheye 是否使用鱼眼相机
FISHEYE_MASK string yaml config file/fisheye=1 fisheye_mask.jpg路径
CAM_NAMES std::vector parameter.cpp全局变量 像素列数-图像宽度
WINDOW_SIZE int parameter.cpp全局变量 20 滑动窗口的大小
STEREO_TRACK int parameter.cpp全局变量 false 是否使用双目追踪
FOCAL_LENGTH int parameter.cpp全局变量 460 焦距
PUB_THIS_FRAME int parameter.cpp全局变量 false 不发布这帧
NUM_OF_CAM int parameter.h 1 camera的数量
modelType Camera::ModelType yaml config file/model_type kannala_brandt/mei/scaramuzza/pinhole camera的模型
SOLVER_TIME double max_solver_time 确保实时性,最大求解时间 0.04ms
NUM_ITERATIONS int max_num_iterations 确保实时性,最大迭代次数 8,避免冗余计算
MIN_PARALLAX double keyframe_parallax 关键帧选择的视差阈值 10 pixel
VINS_RESULT_PATH int output_path/vins_result_no_loop.csv 不加回环的输出结果
ESTIMATE_EXTRINSIC int estimate_extrinsic IMU和cam相对外参的方式选择,0-有准确可信的参数;1-有一组初始值,后面将基于此再优化,2-完全不知道相对外参,启动之初进行在线校准(注意开始的时候要有旋转) 保存在 output_path/extrinsic_parameter.csv中
RIC[0] cv_R eigen_R Eigen::Matrix3d extrinsicRotation IMU与camera的旋转
TIC[0] cv_T eigen_T Eigen::Vector3d extrinsicRotation IMU与camera的平移
INIT_DEPTH double vins_estimator/parameters.h camera的数量
BIAS_ACC_THRESHOLD double vins_estimator/parameters.h 1 acc偏置的阈值
BIAS_GYR_THRESHOLD double vins_estimator/parameters.h 1 陀螺仪偏置的阈值
TD int config/td IMU与camera的固有时钟差
ESTIMATE_TD int config/estimate_td 置位online estimate time offset between camera and imu
ROLLING_SHUTTER int rolling_shutter: 0 0-全局快门;1-卷帘快门

NUM_OF_CAM | int | parameter.h 1 | camera的数量

class 名称

FeatureTracker 特征点追踪类

  • FeatureTracker trackerData[NUM_OF_CAM];

CameraFactory 不同的相机类型和校准模型

  • static boost::shared_ptr instance(void);

TicToc 计算时间差的功能类

Estimator

参考文档:

你可能感兴趣的:(视觉SLAM实战进阶开发)