目录
学习相机与激光雷达联合标定使用的开源算法:https://github.com/koide3/direct_visual_lidar_calibration/tree/main/thirdparty
0.在使用开源算法之前,需要有提前录制好的rosbag,因为暂时学习中,我使用的是速腾M1激光雷达和gmsl相机,录制了一个bag
1.项目
18.04会有一些错误,最好用20.04,其他依赖的第三方库建议使用ros自带的,不然后面在运行时可能会报段错误,我是在电脑重新装了20.04,然后用小鱼ros一件安装noetic版本ros,没有安装其他库
wget http://fishros.com/install -O fishros && bash fishros
2.安装
参照作者给的文档:https://koide3.github.io/direct_visual_lidar_calibration/
# Install dependencies
sudo apt install libomp-dev libboost-all-dev libglm-dev libglfw3-dev libpng-dev libjpeg-dev
# Install GTSAM
git clone https://github.com/borglab/gtsam
cd gtsam && git checkout 4.2a9
mkdir build && cd build
# For Ubuntu 22.04, add -DGTSAM_USE_SYSTEM_EIGEN=ON
cmake .. -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
-DGTSAM_BUILD_TESTS=OFF \
-DGTSAM_WITH_TBB=OFF \
-DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF
make -j$(nproc)
sudo make install
# Install Ceres
git clone https://github.com/ceres-solver/ceres-solver
mkdir ceres-solver/build && cd ceres-solver/build
cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DUSE_CUDA=OFF
make -j$(nproc)
sudo make install
# Install Iridescence for visualization
git clone https://github.com/koide3/iridescence --recursive
mkdir iridescence/build && cd iridescence/build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
如果需要Initial guess (Automatic),要SuperGlue
pip3 install numpy opencv-python torch matplotlib
git clone https://github.com/magicleap/SuperGluePretrainedNetwork.git
echo 'export PYTHONPATH=$PYTHONPATH:/path/to/SuperGluePretrainedNetwork' >> ~/.bashrc
source ~/.bashrc
3.编译
# ROS1
cd ~/catkin_ws/src
git clone https://github.com/koide3/direct_visual_lidar_calibration.git --recursive
cd .. && catkin_make
4.运行
(1)预处理
rosrun direct_visual_lidar_calibration preprocess -av --camera_model=plumb_bob --camera_intrinsics=1452.71176245628,1455.87753161946,1265.25895179213,1045.8185936641 --camera_distortion_coeffs=-0.042035649,0.087317098,0.002386382,0.005629701,-0.042511493 /home/jwb/libox/ /home/jwb/pre
camera_intrinsics为相机内参,camera_distortion_coeffs为畸变系数
/home/jwb/libox为存放rosbag包位置,/home/jwb/pre :自动创建文件夹存放
Initial guess (Automatic)
以下代码中最后一个参数livox_preprocessed是生成预处理文件夹的路径
(1)
rosrun direct_visual_lidar_calibration find_matches_superglue.py /home/jwb/pre/ --rotate_camera 0
rosrun direct_visual_lidar_calibration initial_guess_auto livox_preprocessed
(2)
Initial guess (Manual)
rosrun direct_visual_lidar_calibration initial_guess_manual livox_preprocessed
Calibration result inspection
rosrun direct_visual_lidar_calibration calibrate livox_preprocessed
5.问题
问题1:在上面的安装过程中,除了ceres库,其他安装都没有问题
在编译ceres2.2版本时遇到 没有absl和另一个第三方库
在ceres github下发现也有人最近遇见该问题,https://github.com/ceres-solver/ceres-solver/issues/1089
使用:
git clone --recurse-submodules https://github.com/ceres-solver/ceres-solver
问题2:
CMake Error at direct_visual_lidar_calibration/CMakeLists.txt:24 (find_package):
Found package configuration file:
/usr/local/lib/cmake/Ceres/CeresConfig.cmake
but it set Ceres_FOUND to FALSE so package "Ceres" is considered to be NOT
FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
absl::log_flags absl::log absl::check absl::fixed_array absl::strings
absl::time
找到两个帖子,ros-neodic安装ALOAM_the following imported targets are referenced, but-CSDN博客
(1)
打开报错的文件
sudo gedit /usr/local/lib/cmake/Ceres/CeresConfig.cmake
将ceres_found false改为true
(2)在direct_visual_lidar_calibration文件夹的cmakelists中加入
set(ABSEIL_DIR "home/jwb/ThirdParty/ceres-solver/third_party/abseil-cpp" CACHE PATH "Path to Abseil libraries")(abseil在ceres库中安装位置)
find_package(absl REQUIRED HINITS ${ABSEIL_DIR})
问题3: /usr/bin/ld: 找不到 -lfmt
collect2: error: ld returned 1 exit status
make[2]: *** [direct_visual_lidar_calibration/CMakeFiles/direct_visual_lidar_calibration.dir/build.make:567:/home/jwb/catkin_ws/devel/lib/libdirect_visual_lidar_calibration.so] 错误 1
解决:需要安装8.1.1版本,安装其他版本之后会报错
参考https://blog.csdn.net/qq_44849479/article/details/125186678
与https://blog.csdn.net/HozenChe/article/details/124979631
先到https://fmt.dev/8.1.1/index.html下载8.1.1版,注意不要git也不要下最新版,都会报错。
cd fmt-8.1.1
mkdir build
cd build
cmake ..
make
sudo make install
问题4
error: initial guess of T_lidar_camera must be computed before calibration!!
已放弃 (核心已转储)
https://github.com/koide3/direct_visual_lidar_calibration/issues/60
运行代码少输了一步,结果没有保存,calib.json中没有T_lidar_camera信息,会看运行Initial guess (Automatic)第二步
问题5:rospack: error while loading shared libraries: librospack.so: cannot open shared object file
参考一些帖子,应该是安装cuda时候的问题rospack: error while loading shared libraries: librospack.so: cannot open shared object file:-CSDN博客
export LD_LIBRARY_PATH=/opt/ros/noetic/lib:/usr/local/cuda/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda/bin
我是这样改的,把之前cuda部分注释掉,后续把source之后重开终端发现没有问题了