D435i相机的标定
D435i相机标定
IMU标定
- 安装imu_utils、code_utils、realsense-ros
- 使用imu_utils录制imu_calibration.bag
#1. 运行相机d435i
roslaunch realsense2_camera rs_camera.launch unite_imu_method:="linear_interpolation" enable_gyro:=true enable_accel:=true
#2.录制IMU数据包
rosbag record -O imu_calibration /camera/imu
#3.使用imu_utils进行标定,首先需要新建一个imu_utils的launch文件,内容如下所示
<launch>
<node pkg="imu_utils" type="imu_an" name="imu_an" output="screen">
<!--IMU的话题-->
<param name="imu_topic" type="string" value= "/camera/imu"/>
<!--这个和最后保存的文件名有关,最后的文件名为D435i_imu_param.yaml-->
<param name="imu_name" type="string" value= "D435i"/>
<!--标定结果存放的文件目录-->
<param name="data_save_path" type="string" value= "$(find imu_utils)/data/"/>
<!--修改标定时间,单位是分钟,需要根据数据包的时长来调整-->
<param name="max_time_min" type="int" value= "120"/>
<param name="max_cluster" type="int" value= "100"/>
</node>
</launch>
#4.我们把新建的launch文件命名为d435i_imu_calibration.launch ,然后通过如下的命令就可以运行了:
roslaunch imu_utils d435i_imu_calibration.launch
#5. 播放之前录制的数据包,找到录制的数据包,运行下面的命令
rosbag play -r 200 imu_calibration.bag
#6.这一部分的工作都完成之后,我们会得到D435i相机IMU的标定文件D435i_imu_param.yaml
使用Kalibr进行相机和IMU联合标定
- 安装kalibr
# 创建kalibr的ros工作空间
mkdir -p kalibr_ws/src && cd kalibr_ws/src
git clone https://github.com/ethz-asl/Kalibr.git
cd ..
catkin_make
- 运行kalibr生成标定板
rosrun kalibr kalibr_create_target_pdf --type apriltag --nx 6 --ny 6
--tsize 0.03 --tspace 0.3
或者
rosrun kalibr kalibr_create_target_pdf --type checkerboard --nx 6 --ny 7
--csx 0.05 --csy 0.05
- 可能会出现的错误的解决方法:
出现ModuleNotFoundError: No module named 'pyx'时,如果使用pip安装无法解决,则需要使
用sudo apt-get install python3-pyx进行安装.或者sudo apt-get install python-pyx安装
上面的命令会生成6x6、格子大小为3cm的标定板(后者是棋盘格子),并将下述参数写入Kalibr/data/checkerboader.yaml文件:
tagCols: 6 #number of apriltags
tagRows: 6 #number of apriltags
tagSize: 0.03 #size of apriltag, edge to edge [m]
tagSpacing: 0.3 #ratio of space between tags to tagSize
棋盘格的参数对应为:
arget_type: 'checkerboard'
targetCols: 6 # 横向的角点数
targetRows: 7
rowSpacingMeters: 0.03 # 每个格子的宽度
colSpacingMeters: 0.03
- 采集相机标定数据
- 开启相机节点:
roslaunch realsense2_camera rs_camera.launch
- 打开可视化窗口,随时查看相机拍摄情况:
rviz //坐标系选camera_link,然后添加相机话题即可实时可视化图像
- 调整采集图片分辨率,重新发布一个话题:
rosrun topic_tools throttle messages /camera/color/image_raw 6.0 /calib_image
- 录制标定数据bag包
rosbag record -o d435i_calib_rgbimage /calib_image
- 开始利用Kalibr标定
rosrun kalibr kalibr_calibrate_cameras --target ./src/Kalibr/data/target.yaml --bag ./src/Kalibr/data/d435i_calib_rgbimage_2022-11-03-09-14-20.bag --models pinhole-equi --topics /calib_image
ModuleNotFoundError: No module named ‘wx’: 在使用python的时候使用的是/usr/bin中的python,并不是conda环境中的python,所以需要使用sudo pip安装wx包.
- igraph的版本问题,可以安装第版本的igraph
sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple igraph==0.1.1
如果igraph出现无.Graph对象,则卸载igraph安装python_igraph
#卸载igraph
pip uninstall igraph
#先安装如下包,否则无法编译python_igraph包
sudo apt-get install -y libigraph0-dev
sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python_graph==0.7.1.post6
标定时出现 Attempt to unlock mutex that was not locked 已放弃 (核心已转储)错误时,将标定命令的show参数去除
rosrun kalibr kalibr_calibrate_cameras --target ./src/Kalibr/data/target.yaml --bag ./src/Kalibr/data/d435i_calib_rgbimage_2022-11-03-09-14-20.bag --models pinhole-equi --topics /calib_image
参考:https://blog.youkuaiyun.com/weixin_50508111/article/details/123985154
- IMU+相机联合标定
- 录制标定数据
# 仍然使用之前的标定板,运行下面的命令发布图像和IMU话题
roslaunch realsense2_camera rs_camera.launch unite_imu_method:="linear_interpolation"
#将图像频率设置为20Hz,IMU频率设置为200Hz:
rosrun topic_tools throttle messages /camera/color/image_raw 20.0 /color
rosrun topic_tools throttle messages /camera/imu 200.0 /imu
#开始录制
rosbag record -O dynamic /color /imu
- 开始标定
rosrun kalibr kalibr_calibrate_imu_camera --target ./src/Kalibr/data/target.yaml --cam ./src/Kalibr/data/camchain.yaml --imu ./src/Kalibr/data/imu.yaml --bag ./src/Kalibr/data/dynamic.bag