ubuntu20.04 实测 机械式激光雷达与相机联合标定
安装功能包功能包测试利用功能包标定自己的激光雷达和相机设置参数启动相机和激光雷达启动功能包安装功能包
实测 ubuntu20.04 本地安装
安装步骤如下:
下载功能包
git clone -c http.sslverify=false https://gitlab.acfr.usyd.edu.au/its/cam_lidar_calibration.git
成功提示:
正克隆到 ‘cam_lidar_calibration’…
remote: Enumerating objects: 762, done.
remote: Total 762 (delta 0), reused 0 (delta 0), pack-reused 762
接收对象中: 100% (762/762), 76.65 MiB | 449.00 KiB/s, 完成.
处理 delta 中: 100% (340/340), 完成.
安装依赖
sudo apt update && sudo apt-get install -y ros-noetic-pcl-conversions ros-noetic-pcl-ros ros-noetic-tf2-sensor-msgs
成功提示
下列【新】软件包将被安装:
ros-noetic-tf2-sensor-msgs
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 142 个软件包未被升级。
需要下载 9,400 B 的归档。
解压缩后会消耗 52.2 kB 的额外空间。
获取:1 /ros/ubuntu focal/main amd64 ros-noetic-tf2-sensor-msgs amd64 0.7.5-1focal.2027.002056 [9,400 B]
已下载 9,400 B,耗时 1秒 (12.6 kB/s)
正在选中未选择的软件包 ros-noetic-tf2-sensor-msgs。
(正在读取数据库 … 系统当前共安装有 277707 个文件和目录。)
准备解压 …/ros-noetic-tf2-sensor-msgs_0.7.5-1focal.2027.002056_amd64.deb …
正在解压 ros-noetic-tf2-sensor-msgs (0.7.5-1focal.2027.002056) …
正在设置 ros-noetic-tf2-sensor-msgs (0.7.5-1focal.2027.002056) …
安装pandas 和 scipy
pip install pandas scipy
将功能包拷入ros的工作空间
然后编译
catkin_make
不出意外会报错误
In file included from /home/jone/jone_ws/src/cam_lidar_calibration/src/optimiser.cpp:3:
/home/jone/jone_ws/src/cam_lidar_calibration/include/cam_lidar_calibration/optimiser.h:10:10: fatal error: opencv/cv.hpp: 没有那个文件或目录
10 | #include <opencv/cv.hpp>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [cam_lidar_calibration/CMakeFiles/cam_lidar_calibration.dir/build.make:115:cam_lidar_calibration/CMakeFiles/cam_lidar_calibration.dir/src/optimiser.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务…
仍然是 ubuntu20.04 opencv 的 版本问题
错位解决办法:
打开include文件夹下的 optimise.h文件
将第10行
#include <opencv/cv.hpp>
改为
#include <opencv2/opencv.hpp>
再次编译报错:
error: ‘CV_REDUCE_SUM’ was not declared in this scope
427 | cv::reduce(trans_diff, summed_diff, 1, CV_REDUCE_SUM, CV_64F);
| ^~~~~~~~~~~~~
make[2]: *** [cam_lidar_calibration/CMakeFiles/cam_lidar_calibration.dir/build.make:115:cam_lidar_calibration/CMakeFiles/cam_lidar_calibration.dir/src/optimiser.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务…
CV_REDUCE_SUM 这个变量没定义,opencv3到opencv4切换带来的错误
在 optimise.h文件中加入下面的包含文件
#include<opencv2/core/core_c.h>
编译通过
功能包测试
作者在功能包中放了测试数据,提供测试
roslaunch cam_lidar_calibration run_optimiser.launch import_samples:=true
该程序根据cam_lidar_calibration/data/vlp/文件夹下的pose.csv标定,在该文件夹生成一个标定camera和lidar外参文件
终端输出
[ INFO] [1662433388.628563347]: ====== START CALIBRATION ======
Computing calibration results (roll,pitch,yaw,x,y,z) for each of the 50 lowest voq sets
1/50 | voq: 20.059 | -1.684, 0.002,-1.485, 0.068,-0.017,-0.223 | t: 0.853s
2/50 | voq: 21.132 | -1.691,-0.023,-1.498, 0.059, 0.017,-0.196 | t: 0.824s
3/50 | voq: 21.213 | -1.671,-0.004,-1.490, 0.065,-0.005,-0.253 | t: 1.500s
4/50 | voq: 21.997 | -1.695,-0.022,-1.491, 0.059,-0.001,-0.198 | t: 1.350s
5/50 | voq: 22.191 | -1.699,-0.026,-1.496, 0.059, 0.014,-0.187 | t: 1.278s
6/50 | voq: 22.202 | -1.695,-0.019,-1.492, 0.060, 0.001,-0.191 | t: 0.802s
7/50 | voq: 22.354 | -1.680,-0.007,-1.488, 0.065,-0.012,-0.238 | t: 4.565s
8/50 | voq: 22.689 | -1.685, 0.005,-1.483, 0.068,-0.021,-0.219 | t: 1.509s
9/50 | voq: 22.703 | -1.715,-0.018,-1.489, 0.059,-0.007,-0.147 | t: 1.560s
10/50 | voq: 22.710 | -1.703,-0.018,-1.492, 0.058, 0.003,-0.172 | t: 0.833s
11/50 | voq: 23.094 | -1.697,-0.031,-1.494, 0.063, 0.006,-0.192 | t: 0.879s
每一行则是迭代后的结果
终端输出这个的时候
[ INFO] [1662433466.965540013]: ====== END ======
表示迭代完了
然后获取评估校准结果
终端输出
Calibration params (roll,pitch,yaw,x,y,z): -1.6963,-0.0234,-1.4927,0.0622,0.0033,-0.1908
Mean reprojection error across 40 samples
Error (pix) = 4.560 pix, stdev = 2.928
Error (mm) = 9.006 mm , stdev = 4.697
[ INFO] [1662433590.250502423]: Projecting points onto image for pose #16
生成一个雷达投射到图片上的图片
利用功能包标定自己的激光雷达和相机
设置参数
主要修改cam_lidar_calibration/cfg/camera_info.yaml
和params.yaml
cam_lidar_calibration/cfg/camera_info.yaml
文件设置如下:
distortion_model: "non-fisheye"width: 1440height: 1080D: [-0.106460,0.103712,-0.000019,0.003994]K: [1213.343583,0.0,744.150520,0.0,1217.236982,586.154363,0.0,0.0,1]
设置是:
否为鱼眼相机像素宽和高内参矩阵失真系数
相机的内参标定方法可以参考这篇博客:
params.yaml
文件设置如下:
# Topicscamera_topic: "/camera_array/cam0/image_raw"camera_info: "/camera_array/cam0/camera_info"lidar_topic: "/velodyne_points"
分别是:
相机消息名称相机信息激光雷达消息名称
feature_extraction:x_min: -10.0x_max: 10.0y_min: -8.0y_max: 8.0z_min: -5.0z_max: 5.0
点云的选取范围,用默认的就是,之后可以在线调
chessboard:pattern_size:height: 14width: 9 square_length: 11board_dimension:width: 390height: 596translation_error:x: 0y: 0
标定棋盘的相关参数
和背板的相关参数
距离都是mm为单位
启动相机和激光雷达
启动相机
roslaunch spinnaker_sdk_camera_driver acquisition.launch
启动激光雷达
roslaunch velodyne_pointcloud VLP16_points.launch
启动功能包
开启程序采集表定数据,运行命令:
roslaunch cam_lidar_calibration run_optimiser.launch import_samples:=false
会出现RVIZ和rqt_reconfigure窗口,在RVIZ中panels->display修改相机的话题和激光雷达点云对应的frame_id。
调整rqt_reconfigure /feature_extraction的xyz最大值最小值以使得标定板的点云和周围环境分开,使其仅显示棋盘。如果棋盘没有完全隔离,可能会影响棋盘的平面拟合,还会导致棋盘尺寸误差较大。下图是过滤点云前后效果:
在过滤周围环境点云后,在rviz中点击Capture sample采集样本,会出线绿色框代表根据点云拟合出来的标定板平面
终端会打印出来添加的样本信息
— Sample 1 —
Measured board has: dimensions = 390x596 mm; area = 0.23244 m^2
Distance = 2.11 m
Board angles = 94.19,91.96,93.95,92.20 degrees
Board area = 0.25006 m^2 (+0.01762 m^2)
Board avg height = 614.17mm (+18.17mm)
Board avg width = 407.12mm (+17.12mm)
Board dim = 396.39,612.74,615.60,417.86 mm
Board dim error = 70.59
— Sample 9 —
Measured board has: dimensions = 390x596 mm; area = 0.23244 m^2
Distance = 2.59 m
Board angles = 92.69,98.29,98.38,92.60 degrees
Board area = 0.25282 m^2 (+0.02038 m^2)
Board avg height = 612.57mm (+16.57mm)
Board avg width = 412.68mm (+22.68mm)
Board dim = 411.17,592.04,633.10,414.18 mm
Board dim error = 86.41
最好采集10个样本以上,再点击rviz中的optimise进行标定,在优化过程中将会在cam_lidar_calibration/data生成当前时间日期的文件夹,存放采集的图像、点云pcd、位姿,标定后camer和lidar外参文件。
终端输出开始校准:
[ INFO] [1662448387.086142265]: ====== START CALIBRATION ======
Computing calibration results (roll,pitch,yaw,x,y,z) for each of the 50 lowest voq sets
1/50 | voq: 162.919 | 3.423,-0.282,-1.383, 2.057,-0.200, 0.744 | t: 1.612s
2/50 | voq: 187.519 | 3.391,-0.343,-1.390, 2.016,-0.061, 0.742 | t: 2.103s
3/50 | voq: 190.635 | 3.473,-0.351,-1.391, 1.940,-0.083, 0.718 | t: 4.604s
4/50 | voq: 194.325 | -2.563,-0.339,-1.429, 1.772,-0.185, 0.633 | t: 2.882s
校准结束后输出:
47/50 | voq: 573.420 | -1.587, 0.027,-1.613, 1.085,-0.084, 0.015 | t: 5.416s
48/50 | voq: 587.555 | -1.571,-0.155,-1.533, 1.387,-0.441,-0.145 | t: 1.097s
49/50 | voq: 588.285 | -1.676, 0.170,-1.696, 1.422, 0.001,-0.045 | t: 1.726s
50/50 | voq: 593.720 | -1.609, 0.088,-1.660, 1.087,-0.244, 0.034 | t: 1.787s
Optimisation Completed in 123.578s
[ INFO] [1662448510.660340676]: ====== END ======
评估参数和重投影误差:
roslaunch cam_lidar_calibration assess_results.launch csv:="$(rospack find cam_lidar_calibration)/data/-09-06_14-48-42/calibration_-09-06_15-13-07.csv" visualise:=true
注意这里默认加载第16个图像,如果没有那么大的标定样本,要修改launch文件中的加载序列
出现重投影效果图像:
终端出现标定参数和重投影误差: