标定双目相机内参和IMU内参,以及相机到IMU的外参

1 双目相机标定

相机获取图像帧率设置为4hz,低一点方便计算。然后通过rostopic获取相机topic,再降低发布频率即可。

1.1 开启相机

Run camera mynteye_wrapper_d

cd MYNT-EYE-D-SDK
source wrappers/ros/devel/setup.bash
roslaunch mynteye_wrapper_d display.launch

rostopic list /topic 查看topic
rostopic hz /topic 查看topic发布频率
rostopic info /topic 查看topic信息

1.2 重新发布一个topic,降低帧率

 rosrun topic_tools throttle messages /mynteye/right/image_color 4.0 /img_right
 rosrun topic_tools throttle messages /mynteye/left/image_color 4.0 /img_left

1.3 将相机拍摄的照片流放在一个bag中

rosbag record -O ~/Documents/tmp/kalibr/calibr_bag/stereo_calibra.bag /img_left /img_right

1.4 进行标定

source ~/kalibr_workspace/devel/setup.bash

kalibr_calibrate_cameras \   
--target  	~/Documents/tmp/kalibr/calibr_board/april_6x6_50x50cmmy.yaml \    #标定板的参数文件,需要根据实际情况修改
--bag 	~/Documents/tmp/kalibr/calibr_bag/stereo_calibra.bag \   #刚才打包的照片
--models 	pinhole-radtan pinhole-radtan \ #默认相机模型
--topics 	/img_left  /img_right  #包中照片的topic

2. IMU标定

利用港科大的这个方法
https://github.com/gaowenliang/imu_utils

2.1 安装imu_utils

首先安装imu_utils和code_utils。按照说明将其放置在一个catkin_space下然后catkin_make一下。

注意:

  1. code_utils 依赖 ceres库, 需要先全局安装ceres库,okvis等内部的ceres不行。
  2. imu_utils 依赖 code_utils,故先catkin_make code_utils, 再将imu_utils放入编译。
  3. 编译code_utils 报错, fatal error: backward.hpp: No such file or directory
    解决办法: 在code_utils下面找到sumpixel_test.cpp,修改#include “backward.hpp” 为 #include “code_utils/backward.hpp” 即可编译成功。

2.2 IMU标定

一种是直接开着IMU,从topic中读数据,进行标定

1. imu_topic 
cd MYNT-EYE-D-SDK
source wrappers/ros/devel/setup.bash
roslaunch mynteye_wrapper_d display.launch

2. 运行标定程序
roslaunch imu_utils mynt_imu.launch  # 注意这里的launch文件

一种是先从IMU读到bag中,之后可以play,然后标定

1. 读到bag中
rosbag record -O ~/Documents/tmp/kalibr/calibr_bag/imu.bag   /mynteye/imu/data_raw  /mynteye/imu/data_raw

2. play 
rosbag play -r 200 ~/Documents/tmp/kalibr/calibr_bag/imu.bag     #帧率200

3.  运行标定程序
roslaunch imu_utils mynt_imu.launch  # 注意这里的launch文件

mynt_imu.launch 文件内容


    
            #imu topic 名字
           
        
           #标定时长,到时长才会停止
        
    

2.3 结果转换

最后结果输出到imu_util/data/mynteye_imu_param.yaml

%YAML:1.0
---
type: IMU
name: mynteye
Gyr:
   unit: " rad/s"
   avg-axis:
      gyr_n: 1.9480242194900136e-03
      gyr_w: 2.2620050177053397e-05
   x-axis:
      gyr_n: 1.4943337644865377e-03
      gyr_w: 1.6979123891120051e-05
   y-axis:
      gyr_n: 2.8556505698921365e-03
      gyr_w: 3.8869840774243172e-05
   z-axis:
      gyr_n: 1.4940883240913672e-03
      gyr_w: 1.2011185865796957e-05
Acc:
   unit: " m/s^2"
   avg-axis:
      acc_n: 2.1870816125420644e-02
      acc_w: 3.1961985711386886e-04
   x-axis:
      acc_n: 2.1689606568187404e-02
      acc_w: 3.2513933860140864e-04
   y-axis:
      acc_n: 2.3148960398654196e-02
      acc_w: 3.3709366869493846e-04
   z-axis:
      acc_n: 2.0773881409420332e-02
      acc_w: 2.9662656404525953e-04

输出 imu.yaml, 为后续相机-IMU标定准备文件

rostopic: /mynteye/imu/data_raw
update_rate: 200.0 #Hz

accelerometer_noise_density: 2.1870816125420644e-02   #continous
accelerometer_random_walk: 3.1961985711386886e-04
gyroscope_noise_density: 1.9480242194900136e-03    #continous
gyroscope_random_walk: 2.2620050177053397e-05

3. 标定 Camera-IMU

3.1 采集 images & imu 数据

在 rosbag record /mynteye/imu/data_raw     \
               /mynteye/right/image_color   \
               /mynteye/left/image_color  \
           -O ~/Documents/tmp/kalibr/calibr_bag/img_imu.bag

3.2 标定camera && imu

source ~/kalibr_workspace/devel/setup.bash

kalibr_calibrate_imu_camera \
--target ~/Documents/tmp/kalibr/calibr_board/april_6x6_50x50cm.yaml \
--bag ~/Documents/tmp/kalibr/calibr_bag/img_imu.bag \
--cam ~/Documents/tmp/kalibr/calibr_bag/camchain-stereo_calibra.yaml \      #这里需要修改下img的topic名,不是上文中提到的减频后的topic,而是原来相机的topic, /mynteye/right/image_color
--imu ~/Documents/tmp/kalibr/calibr_bag/mynt_imu.yaml 

3.3 输出 camchain-imucam.yaml

cam0:
  T_cam_imu:
  - [0.9934428889204068, 0.09176493006449765, 0.0681940178002217, 0.052903481394401354]
  - [0.08653757968000322, -0.9933440680628596, 0.07601848293315787, 0.09115974521093512]
  - [0.07471595382919362, -0.06961867604737666, -0.9947717156156015, -0.014714416225472633]
  - [0.0, 0.0, 0.0, 1.0]
  cam_overlaps: [1]
  camera_model: pinhole
  distortion_coeffs: [-0.32726809165652687, 0.11886776669170422, 8.008858395321615e-05,
    0.00016947151975802357]
  distortion_model: radtan
  intrinsics: [709.0327171920417, 709.3502758333848, 608.5490306087884, 347.7484506944358]
  resolution: [1280, 720]
  rostopic: /mynteye/left/image_color
  timeshift_cam_imu: 0.00807023279474932
cam1:
  T_cam_imu:
  - [0.9935583432182118, 0.09152584793268394, 0.06681944164451824, -0.07539252923588326]
  - [0.08647981867396241, -0.9934367456616839, 0.07486436623147993, 0.0912633943754548]
  - [0.07323291325354019, -0.0686035824817173, -0.994952505844914, -0.014984371397893347]
  - [0.0, 0.0, 0.0, 1.0]
  T_cn_cnm1:
  - [0.9999990200252148, 0.00014298875888003304, 0.0013926603401210713, -0.12828850142112913]
  - [-0.000144590668980564, 0.9999993280445829, 0.0011502190744177136, 0.00012828457178189372]
  - [-0.0013924949359175218, -0.0011504193129222653, 0.9999983687452975, -9.143941399551913e-05]
  - [0.0, 0.0, 0.0, 1.0]
  cam_overlaps: [0]
  camera_model: pinhole
  distortion_coeffs: [-0.3255128311208999, 0.11665971550085348, 0.00020637909503995344,
    0.00020627786588678956]
  distortion_model: radtan
  intrinsics: [707.9559596115516, 708.3682390592019, 622.0228830912382, 352.6979725159225]
  resolution: [1280, 720]
  rostopic: /mynteye/right/image_color
  timeshift_cam_imu: -0.007909975103142588

说明:

  1. 推荐为相机帧率20~40hz, IMU 200HZ.
  2. 标定时可以选取rosbag中间的数据,去除首尾的抖动

参靠资料:

你可能感兴趣的:(slam)