ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定

一、安装opencv

此处的opencv的版本不建议安装opencv4,opencv4会导致在编译autoware过程中出现一大堆问题,血的教训,比如:

ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第1张图片

 然后你开始按照网上的各种方法解决问题(添加头文件、将CV_LOAD_IMAGE_UNCHANGED改为IMAGE_UNCHANGED)你会发现还是报错:

ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第2张图片

 ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第3张图片所以我就把opencv4卸载了,卸载可以参考这篇博客:

https://blog.csdn.net/wss794/article/details/124932353
 

然后开始安装opencv3,安装opencv3可以参考这篇博客:

https://blog.csdn.net/qq_41080854/article/details/88609795
 

二、安装autoware1.12.0

这里直接参考autoware官网安装即可:https://gitlab.com/autowarefoundation/autoware.ai/autoware/-/wikis/Source-Build

1)安装依赖项 System dependencies for Ubuntu 18.04 / Melodic

$ 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,不安装cuda也不影响

Additional system dependencies for CUDA support

See Requirements above for which CUDA version to use with your OS.

  • For installation instructions for CUDA 10.0, see Installation Guide Linux :: CUDA Toolkit Documentation.
  • For installation instructions for CUDA 9.0, see Installation Guide Linux :: CUDA Toolkit Documentation.
  • For installation instructions for CUDA 8.0GA, see Installation Guide Linux :: CUDA Toolkit Documentation.

NOTE: To enable CUDA support on Melodic, Eigen is required to be updated.
WARNING: This might break your system, or the compilation of other programs

$ 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

2)创建目录
$ mkdir -p autoware.ai/src
$ cd autoware.ai

3) 下载autoware.ai的工作空间的配置

$ wget -O autoware.ai.repos "https://gitlab.com/autowarefoundation/autoware.ai/autoware/raw/1.12.0/autoware.ai.repos?inline=false"

4)下载autoware.ai到工作区

$ vcs import src < autoware.ai.repos

这一步会需要等待一段时间,有可能还会报错,报错就多重复几次上面这条语句可以解决
5)使用rosdep安装依赖项

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

6)编译工作区若已经配置好了 CUDA:
$ AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

若没有 CUDA支持,只使用 CPU:
$ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

这一步耗时比较久

理论上经过以上能安装上,但实际还是会遇到一些问题的,比如:

问题1:

CNake Error at /opt/ros/melodic/share/grid_nap_cv/cmake/grid_nap_cvConfig.cnake:113 (nessage):Project 'grid_nap_cv'specifies '/usr/include/opencv' as an include dir,
which is not found. It does neither exist as an absolute directory nor in's{prefix} //usr/include/opencv'. check the issue tracker
'http://github.con/anybotics/grid_nap/issues' and consider creating aticket if the probien has not been reported yet.

ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第4张图片

 解决办法:

修改grid_nap_cvConfig.cnake

vim /opt/ros/melodic/share/grid_nap_cv/cmake/grid_nap_cvConfig.cnake

将/usr/include/opencv改为/usr/include/boost/compute/interop/opencv

每个人的路径可能会不同,可以在终端输入以下命令来查看自己的路径:

locate highgui.hpp

ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第5张图片

 ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第6张图片

 问题2:

CNakeFiles/calibration_publisher .dir/src/calibration_publisher.cpp.o: In function 'main':
calibration_publisher.cpp:(.text.startup+0xb8e): undefined reference to 'cv::read(cv::FileNode const&,std::__Cxx11::basic_stringechar, std::char_traits, std::allocator >&,std::_cxx1.1::basic_string, std::allocatorechar> > const&)'
collect2: error: ld returned 1 exit status
make[2]: ***[devel/lib/calibration_publisher /calibration_publisher ] Error 1ake[1]: ***[CMakeFiles/calibration_publisher.dir/all] Error 2
make:***[all] Error 2
ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第7张图片

解决办法:

修改文件1:

/home/xxx/autoware.ai/src/autoware/utilities/calibration_publisher/CMakeLists.txt
在后面加上${OpenCV_LIBS}即可;

 修改文件2:

/home/xxx/autoware.ai/src/autoware/utilities/calibration_publisher/package.xml
在后面加上libopencv-dev即可

至此autoware编译终于成功了

ubuntu18.04安装autoware1.12.0之相机和激光雷达的标定_第8张图片

可以使用官方给出的 demo 测试下软件

ROSBAG Demo · Wiki · Autoware Foundation / MovedToGitHub / autoware · GitLab

三、相机的内参的标定

可以用录制好的rosbag离线标定,也可以在线标定,建议在线标定,因为离线标定不太好把控录制多长时间可以完成相机内参标定

1、离线标定

注:所有有关路径和激光雷达、相机驱动路径、话题名称都需要根据自己的来输入对应的命令
1)录制rosbag
cd ~/catkin_ws/
source devel/setup.bash
roslaunch rslidar_sdk start.launch
roslaunch usb_cam usb_cam-test.launch
cd /home/nnnn/lidar_cam_date_pro/bag   //bag保存路径
rosbag record -b 4096 -o calibration.bag /rslidar_points /usb_cam/image_raw

2)
roscore 
cd autoware.ai  //新的终端
source install/setup.bash
rosrun autoware_camera_lidar_calibrator cameracalibrator.py --square 0.0245 --size 6x8 image:=/usb_cam/image_raw

3)播放录制好的bag包(在线标定不需要这一步)
cd /home/nnnn/lidar_cam_date_pro/bag  
rosbag play xx.bag
//CALIBRATE按钮亮时点击,然后点击SAVE即可得到相机内参。

2、在线标定 
1)启动相机
cd ~/catkin_ws/
source devel/setup.bash
roslaunch usb_cam usb_cam-test.launch


2)
cd autoware.ai  //新的终端
source install/setup.bash
rosrun autoware_camera_lidar_calibrator cameracalibrator.py --square 0.0245 --size 6x8 image:=/usb_cam/image_raw
//移动棋盘格近距离:左右、上下;远距离:左右、上下;倾斜:左右、上下
//CALIBRATE按钮亮时点击,然后点击SAVE即可得到相机内参,内参保存在/home/nnnn


2、相机和激光雷达外参的标定
1.得到内参后,我们在autoware中的终端使用如下命令:
roslaunch autoware_camera_lidar_calibrator camera_lidar_calibration.launch intrinsics_file:=/home/nnnn/20220808_1002_autoware_camera_calibration.yaml image_src:=/usb_cam/image_raw

2.启动相机和激光雷达 (也可以用录制好rosbag离线标定)
cd ~/catkin_ws/
source devel/setup.bash
roslaunch rslidar_sdk start.launch
roslaunch usb_cam usb_cam-test.launch

3.在新的终端启动rviz
cd autoware.ai  //新的终端
source install/setup.bash
rosrun rviz rviz 
//订阅点云话题,注意将fixed frame改为rslidar
//在图像中找到一个可以匹配点云中对应点的点
//单击图像中点的像素
//使用Publish Point工具单击Rviz中的相应3D点
//用至少9个不同点重复此操作
//完成后,文件将保存在home目录中,名称为YYYYmmdd_HHMM_autoware_lidar_camera_calibration.yaml,此文件可与Autoware的Calibration Publisher一起使用,以发布和对齐LiDAR与相机之间的转换。该文件包含内参和外参。

相机和激光雷达的标定可以参考这篇博客:

https://blog.csdn.net/learning_tortosie/article/details/82347694
 

你可能感兴趣的:(opencv,计算机视觉,人工智能)