做无人机避障相关工作,3D毫米波避障测试顺利后,开始做4D毫米波雷达无人机避障遇到4D雷达点云需要进行处理的问题,查阅文献,发现以下这篇文章中的建图方法应该为后续思考的方向,特此将这个开源项目进行复现和学习:
A 4D Imaging Radar SLAM System for Large-scale Environments based on Pose Graph Optimization
代码地址:
GitHub - zhuge2333/4DRadarSLAM
Ubuntu版本:
1、安装准备阶段的库文件
// Eigen3安装:
sudo apt update
sudo apt install libeigen3-dev
// OpenMP安装:
sudo apt install build-essential
// PCL安装:
sudo apt install libpcl-dev
// g2o安装
// 安装依赖项
sudo apt-get install qt5-qmake qt5-default libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3
g2o库文件下载:
GitHub - RainerKuemmerle/g2o: g2o: A General Framework for Graph Optimization
Ubuntu20.04LTS上运行4Dradar_slam_20.04 4dradar-CSDN博客
4DRadarSLAM 方案部署_4d radarslam-CSDN博客
// 在g2o-master文件目录下,把g2o-master文件夹名字改成g2o
mkdir build
cd build
cmake ..
make -j4 #-j8会快一点
sudo make install
下载下来以后是将g2o-master文件名修改为g2o文件名,而不是在g2o-master下面的文件夹中进行操作,会报错,这个可以看第二篇文章比较详细,第一篇可能会误导。
报错:
/home/nvidia/g2o/g2o/stuff/filesys_tools.cpp:29:10: fatal error: filesystem: 没有那个文件或目录
#include <filesystem>
^~~~~~~~~~~~
compilation terminated.
g2o/stuff/CMakeFiles/stuff.dir/build.make:117: recipe for target 'g2o/stuff/CMakeFiles/stuff.dir/filesys_tools.cpp.o' failed
make[2]: *** [g2o/stuff/CMakeFiles/stuff.dir/filesys_tools.cpp.o] Error 1
CMakeFiles/Makefile2:1123: recipe for target 'g2o/stuff/CMakeFiles/stuff.dir/all' failed
make[1]: *** [g2o/stuff/CMakeFiles/stuff.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2
原因:
当前安装的GCC版本是7.5.0,这是Ubuntu 18.04 LTS版本自带的默认GCC版本。虽然GCC 7支持大部分C++17特性,但不是全部。为了完全支持C++17,建议至少使用GCC 8或更高版本。
尝试了很多办法,发现更新g++比较好:
# 查看当前版本
g++ --version
版本是7.5,不太行
安装新版本
// Toolchain测试PPA提供了最新版本的GCC编译器
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
// 安装GCC 9或更高版本,这里以GCC 9为例:
sudo apt install gcc-9 g++-9
// 如果你已经尝试了更新GCC到新版本,但系统仍然显示旧版本(如7.5.0)
g++ --version
// 确认新版本是否已安装
g++-9 --version
发现已经安装了
如果新版本的GCC已经安装,但默认的g++
命令仍然指向旧版本,你可以使用update-alternatives
来更新默认设置:
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 60
sudo update-alternatives --config g++
设置成功
重新编译:编译通过
安装
sudo make install
安装完显示:
2、ROS软件包的安装
Ubuntu20.04 用
sudo apt-get install ros-noetic-geodesy ros-noetic-pcl-ros ros-noetic-nmea-msgs ros-noetic-libg2o
Ubuntu18.04用
sudo apt-get install ros-melodic-geodesy ros-melodic-pcl-ros ros-melodic-nmea-msgs ros-melodic-libg2o
把fast_apdgicp、barometer_bmp388、ndt_omp源码下载下来,等下catkin_make需要用到。
fast_apdgicp下载: https://github.com/zhuge2333/fast_apdgicp
barometer_bmp388下载: https://github.com/zhuge2333/barometer_bmp388
ndt_omp下载:https://github.com/koide3/ndt_omp
3、对4D毫米波雷达文件进行编译
创建工作空间:
将刚刚的压缩包解压放入到src文件夹中
再把核心的SLAM代码压缩包也解压到src文件中:
GitHub - zhuge2333/4DRadarSLAM
最后的情况就是:
编译报错01:
c++: error: unrecognized command line option ‘-msse’
c++: error: unrecognized command line option ‘-msse’
c++: error: unrecognized command line option ‘-msse2’
c++: error: unrecognized command line option ‘-msse3’
c++: error: unrecognized command line option ‘-msse4’
c++: error: unrecognized command line option ‘-msse4.1’
c++: error: unrecognized command line option ‘-msse4.2’
c++: error: unrecognized command line option ‘-msse’
c++: error: unrecognized command line option ‘-msse2’
c++: error: unrecognized command line option ‘-msse3’
c++: error: unrecognized command line option ‘-msse4’
c++: error: unrecognized command line option ‘-msse4.1’
c++: error: unrecognized command line option ‘-msse4.2’
ndt_omp-master/CMakeFiles/ndt_omp.dir/build.make:75: recipe for target 'ndt_omp-master/CMakeFiles/ndt_omp.dir/src/pclomp/voxel_grid_covariance_omp.cpp.o' failed
make[2]: *** [ndt_omp-master/CMakeFiles/ndt_omp.dir/src/pclomp/voxel_grid_covariance_omp.cpp.o] Error 1
CMakeFiles/Makefile2:3034: recipe for target 'ndt_omp-master/CMakeFiles/ndt_omp.dir/all' failed
make[1]: *** [ndt_omp-master/CMakeFiles/ndt_omp.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
原因:
x86系统架构下的linux系统与arm64位架构的linux系统区别。
[注意] :上面的错误,理论上只会在arm64系统编译的情况下才会出现。
解决方法:
将4DRadarSLAM与ndt_omp-master中的CMakeLists.txt文件中的有关于msse相关的注释掉
4DRadarSLAM:
ndt_omp-master:
编译报错02:
4DRadarSLAM/apps/scan_matching_odometry_nodelet.cpp:21:10: fatal error: tf_conversions/tf_eigen.h: 没有那个文件或目录
/home/nvidia/4Dradar_slam_test/src/4DRadarSLAM/apps/scan_matching_odometry_nodelet.cpp:21:10: fatal error: tf_conversions/tf_eigen.h: 没有那个文件或目录21 | #include <tf_conversions/tf_eigen.h>| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
4DRadarSLAM/CMakeFiles/scan_matching_odometry_nodelet.dir/build.make:75: recipe for target '4DRadarSLAM/CMakeFiles/scan_matching_odometry_nodelet.dir/apps/scan_matching_odometry_nodelet.cpp.o' failed
make[2]: *** [4DRadarSLAM/CMakeFiles/scan_matching_odometry_nodelet.dir/apps/scan_matching_odometry_nodelet.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
/home/nvidia/4Dradar_slam_test/src/4DRadarSLAM/apps/radar_graph_slam_nodelet.cpp:28:10: fatal error: tf_conversions/tf_eigen.h: 没有那个文件或目录28 | #include <tf_conversions/tf_eigen.h>| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
4DRadarSLAM/CMakeFiles/radar_graph_slam_nodelet.dir/build.make:75: recipe for target '4DRadarSLAM/CMakeFiles/radar_graph_slam_nodelet.dir/apps/radar_graph_slam_nodelet.cpp.o' failed
make[2]: *** [4DRadarSLAM/CMakeFiles/radar_graph_slam_nodelet.dir/apps/radar_graph_slam_nodelet.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
原因:
在 ROS Melodic 中,tf_conversions
包已经被集成到 geometry
包中,因此你不需要单独安装 tf_conversions
。如果你在编译时遇到了找不到 tf_conversions/tf_eigen.h
文件的错误,你应该确保已经安装了 geometry
包。
解决方法:
安装完geometry
包再编译
sudo apt-get install ros-melodic-geometry
编译通过
数据集下载:
https://drive.google.com/drive/folders/14jVa_dzmckVMDdfELmY32fJlKrZG1Afv
把下载的数据集放入到新建的一个文件夹名为carpark_400下
4、运行
将刚刚的数据集名重新命名对应launch文件;
路径也需要进行修改。使得home/nvidia/carpark_400/下面的路径能够引用到
运行:
nvidia@Xavier-NX:~/4Dradar_slam_test$ source devel/setup.bash
nvidia@Xavier-NX:~/4Dradar_slam_test$ roslaunch radar_graph_slam radar_graph_slam.launch
运行报错:
[FATAL] [1727090098.886460184, 1645868413.487595858]: Failed to load nodelet '/scan_matching_odometry_nodelet` of type `radar_graph_slam/ScanMatchingOdometryNodelet` to manager `radarslam_nodelet_manager'
[FATAL] [1727090098.886614074, 1645868413.487595858]: Failed to load nodelet '/radar_preprocessing_nodelet` of type `radar_graph_slam/PreprocessingNodelet` to manager `radarslam_nodelet_manager'
[radarslam_nodelet_manager-2] process has died [pid 21373, exit code 127, cmd /opt/ros/melodic/lib/nodelet/nodelet manager __name:=radarslam_nodelet_manager __log:=/home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/radarslam_nodelet_manager-2.log].
log file: /home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/radarslam_nodelet_manager-2*.log
[radar_preprocessing_nodelet-3] process has died [pid 21375, exit code 255, cmd /opt/ros/melodic/lib/nodelet/nodelet load radar_graph_slam/PreprocessingNodelet radarslam_nodelet_manager __name:=radar_preprocessing_nodelet __log:=/home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/radar_preprocessing_nodelet-3.log].
log file: /home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/radar_preprocessing_nodelet-3*.log
[scan_matching_odometry_nodelet-4] process has died [pid 21376, exit code 255, cmd /opt/ros/melodic/lib/nodelet/nodelet load radar_graph_slam/ScanMatchingOdometryNodelet radarslam_nodelet_manager __name:=scan_matching_odometry_nodelet __log:=/home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/scan_matching_odometry_nodelet-4.log].
log file: /home/nvidia/.ros/log/0edf6d1a-799d-11ef-8a78-48b02d3d6e4a/scan_matching_odometry_nodelet-4*.log
结果:
不显示点云的图像,只有左下角的区域在动