雷达相机标定(ROS)

环境

Ubuntu 18.04 ros-melodic

一、ROS安装

参考链接:https://blog.csdn.net/weixin_45702256/article/details/109329644

二、autoware安装(1.12.0)

参考链接:https://github.com/Autoware-AI/autoware.ai/wiki/Source-Build

1:环境依赖

sudo apt update
sudo apt install -y python-catkin-pkg python-rosdep ros-$ROS_DISTRO-catkin
sudo apt install -y python3-pip python3-colcon-common-extensions python3-setuptools python3-vcstool
pip3 install -U setuptools

2:CUDA支持的其他依赖

有关CUDA 10.0的安装说明,请参阅https://docs.nvidia.com/cuda/archive/10.0/cuda-installation-guide-linux/index.html。
有关CUDA 9.0的安装说明,请参阅https://docs.nvidia.com/cuda/archive/9.0/cuda-installation-guide-linux/index.html。
有关CUDA 8.0GA的安装说明,请参阅https://docs.nvidia.com/cuda/archive/8.0/cuda-installation-guide-linux/index.html。

注意:在melodic上启用CUDA,需更新Eigen

$ cd && wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz #Download Eigen
$ mkdir eigen && tar --strip-components=1 -xzvf 3.3.7.tar.gz -C eigen #Decompress
$ cd eigen && mkdir build && cd build && cmake .. && make && make install #Build and install
$ cd && rm -rf 3.3.7.tar.gz && rm -rf eigen #Remove downloaded and temporary files

3:安装 1.12.0及以上

a: 创建工作区

mkdir -p autoware.ai/src
cd autoware.ai

b: 下载Autoware.AI的工作区配置
对于1.12.0版本

wget -O autoware.ai.repos "https://raw.githubusercontent.com/Autoware-AI/autoware.ai/1.12.0/autoware.ai.repos"

更换更高版本,将上述链接1.12.0改为相应的版本
主版本:

wget -O autoware.ai.repos "https://raw.githubusercontent.com/Autoware-AI/autoware.ai/master/autoware.ai.repos"

c:将Autoware.AI下载到工作区中

vcs import src < autoware.ai.repos

d:使用安装依赖rosdep

rosdep update
rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO

e:编译工作区
带有CUDA:

AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

没有CUDA支持

colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

f: 解决编译问题,
f.1安装autoware依赖:

sudo apt-get install ros-melodic-grid-map-ros
sudo apt-get install ros-melodic-nmea-msgs

f.2 Could NOT find GLEW

sudo apt-get install libglew-dev
sudo apt-get install ros-melodic-autoware-msgs
sudo apt-get install ros-melodic-automotive-platform-msgs
sudo apt-get install ros-melodic-automotive-navigation-msgs
sudo apt-get install ros-melodic-velodyne-pointcloud
sudo apt-get install ros-melodic-gps-common
sudo apt install libopenblas-dev liblapack-dev

g: 编译后运行

cd autoware.ai
source install/setup.bash
roslaunch runtime_manager runtime_manager.launch

显示界面

4 适用于1.11.1及更高版本

a:克隆GitHub存储库。

$ cd $HOME
$ git clone https://github.com/Autoware-AI/autoware.ai.git
$ cd autoware

b:签出相应版本的标签。要查看版本列表,请键入git tag。

$ git checkout 1.11.1
$ cd ros

c:安装依赖rosdep。

$ rosdep update
$ rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO

d:编译工作区,版本1.11.0或1.11.1使用colcon

$ ./colcon_release

e:1.10版或更低版本使用catkin

$ ./catkin_make_release

5、demo演示
参考链接:https://github.com/Autoware-AI/autoware.ai/wiki/ROSBAG-Demo

三、autoware1.10.0版本中的标定工具单独编译安装

3.1安装nlopt

官网链接:https://github.com/stevengj/nlopt

git clone git://github.com/stevengj/nlopt
cd nlopt
mkdir build
cd build
cmake ..
make
sudo make install

3.2 autoware标定工具箱

链接:https://github.com/XidianLemon/calibration_camera_lidar
a: 将该包下载到ros工作空间中

git clone https://github.com/XidianLemon/calibration_camera_lidar.git

b:在catkin_ws编译:

catkin_make
source devel/setup.bash

注意:编译出错
1)could not find the required component ‘jsk_recognition_msgs’
2)打开工具箱执行 rosrun calibration_camera_lidar calibration_toolkit报错内容:
home/x/catkin_ws/devel/lib/calibration_camera_lidar/calibration_toolkit: error while loading shared libraries: libnlopt.so.0: cannot open shared object file: No such file or directory
解决:
1)
$ sudo apt-get install ros-kinetic-jsk-recognition-msgs
2)

cd /etc/ld.so.conf.d
sudo touch libnlopt.conf
gedit libnlopt.conf 

在libnlopt.conf文件中添加内容为:/usr/local/lib

sudo ldconfig

c:运行

roscore
rosrun calibration_camera_lidar calibration_toolkit

三、相机内参标定

内参是使用autoware_camera_calibration脚本获得的,该脚本是官方ROS标定工具的一个分支(即ROS Camera Calibration Tools)

1、双目标定

1.1 标定板下载

尺寸已知的大型棋盘(8x6)或棋盘(7x6)。

1.2 编译:获取依赖项并编译驱动程序。

rosdep install camera_calibration
rosmake camera_calibration

可能出现错误:

ERROR: Rosdep cannot find all required resources to answer your query
Missing resource camera_calibration

解决:安装camera_calibration

sudo apt install ros-melodic-camera-calibration

1.3 相机发布信息

rostopic list

检查是否存在image_raw
官网:雷达相机标定(ROS)_第1张图片
1.4 校准

rosrun camera_calibration cameracalibrator.py --approximate 0.1 --size 8x6 --square 0.108 right:=/my_stereo/right/image_raw left:=/my_stereo/left/image_raw right_camera:=/my_stereo/right left_camera:=/my_stereo/left

注意:
(1)–size 8x6 为当前标定板的大小
(2)–square 0.108为每个棋盘格的边长
(3)image:=/camera/image_raw标定当前订阅图像来源自名为/camera/image_raw的topic
(4)camera:=/camera为摄像机名

1.5 移动标定板,
(1)移动标定板到画面的最左、右,最上、下方。
(2)移动标定板到视野的最近和最远处。
(3)移动标定板使其充满整个画面。
(4)保持标定板倾斜状态并使其移动到画面的最左、右,最上、下方
根据界面显示点击,保存结果,如果要保存校准参数和用于校准的图像,请点击保存。一切都将在压缩文件夹/tmp/calibrationdata.tar.gz中提供。

2、单目标定

参考链接:官网连接:http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration

3、auto标定

3.1 启动,在source过的终端启动

rosrun autoware_camera_lidar_calibrator cameracalibrator.py --square SQUARE_SIZE --size MxN image:=/image_topic

(2.打开相机播放视频流,或者录制的rosbag,保证相机发布的topic与以上命令中的/image_topic一致。
(3.在相机视野内移动棋盘,直到条形变为绿色。
(4.按CALIBRATE按钮。
(5.标定的输出和结果将显示在终端中。
(6.按SAVE按钮。
(7.文件将保存在home目录中,名称为YYYYmmdd_HHMM_autoware_camera_calibration.yaml。
参考连接:https://wiki.ros.org/camera_calibration

四、雷达相机外参标定

4.1 环境安装包:

4.2 标定

4.2.1 进行source,利用autoware_camera_lidar_calibrator联合标定,先获取相机内参,再获取相机与lidar的外参
4.2.2 标定相机内参,与上述标定相似
标定单目:

 rosrun autoware_camera_lidar_calibrator cameracalibrator.py --square 0.028 --size 7x6 image:=/camera/color/image_raw

标定双目:

rosrun autoware_camera_lidar_calibrator cameracalibrator.py --square SQUARE_SIZE  --size MxN right:=/image_topic left:=/image_topic

注:
--square :棋盘格中的每个方格的边长大小。单位为m
--size :棋盘格的尺寸是几乘几。注意是 inner ,也就是出去边长最外圈方格数-1。如果这个参数设置不对的话会在下面的标定步骤中发现标定程序毫无反应
image :发布图像的话题名
right,left : 左右眼图像的话题名
标定流程与上述双目与单目标定一致。

4.3 利用上部获取的相机参数:

roslaunch autoware_camera_lidar_calibrator camera_lidar_calibration.launch intrinsics_file:=/PATH/TO/YYYYmmdd_HHMM_autoware_camera_calibration.yaml image_src:=/image

1)intrinsics_file :相机内参标定结果的yaml文件
2)image_src :为发布图像信息的话题
3)在图像中找到可以匹配点云中对应的点
4)点击图像中点的像素
5)使用Publish Point工具单击Rviz中的相应3D点
6)
7)

你可能感兴趣的:(ROS,深度相机D435i)