为什么写这篇博客
- ALOAM是slamer的必经之路,official提供的基础环境推荐ubuntu16.04或者18.04,而我用20.04已经有一段时间了,不方便换,但由于其他原因也不得不去配置。过程中出现了几个问题,在这里也就20分钟,在这里记录下来。
基础环境
- ubuntu 20.04;
- opencv == 4.2.0;(查询命令:opencv_version)
- Ceres solver已经配置过了;
- pcl == 1.10.0;(查询命令:apt-cache show libpcl-dev)
ALOAM 编译过程
- git速度太慢,这里用手机开了热点,按照下面的命令,10s解决
xml
cd ~/catkin_ws/src
git clone https://github.com/HKUST-Aerial-Robotics/A-LOAM.git
cd ../
catkin_make
source ~/catkin_ws/devel/setup.bash
过程中的错误
- 报错1 ------ python里面缺少"empy"
xml
-- Could NOT find PY_em (missing: PY_EM)
CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message):
Unable to find either executable 'empy' or Python module 'em'... try
installing the package 'python3-empy'
Call Stack (most recent call first):
/opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include)
/opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:58 (find_package)
- 解决方案里面的原话:
xml
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
- 报错2 ------ c++的错误
xml
const int NrDims = pcl::traits::datatype<PointDefault, Key>::size;
| ^~~~~~
/usr/include/pcl-1.10/pcl/point_representation.h:252:48: note: in template argument for type 'int'

xml
- 在CMakeLists当中,改成C++17。【我看你用了pcl1.10,估计要用c++ 17编译吧,改下cmakelist,这是下面解决方案的原话】
- 报错3 ------ opencv的错误
xml
error: 'CV_LOAD_IMAGE_GRAYSCALE' was not declared in this scope 91 |
cv::Mat left_image = cv::imread(left_image_path.str(), CV_LOAD_IMAGE_GRAYSCALE);
- 解决
- 这里直接改个函数就好了,很简单
- 这个错误提示表明在你的代码中使用了CV_LOAD_IMAGE_GRAYSCALE,但编译器无法识别这个符号。这是因为OpenCV的旧版本中使用了CV_LOAD_IMAGE_GRAYSCALE,但在新版本中已经更改为cv::IMREAD_GRAYSCALE。

- 报错4 ------ 导入opencv的错误
xml
fatal error: opencv/cv.h: 没有那个文件或目录
44 | #include <opencv/cv.h>
- 解决方法:将报错的整行都删掉,替换成下面这个
xml
#include <opencv2/opencv.hpp>
小结:基本上就是上面这几个错误,编译成功见下图。顺序可能跟当时遇到的不一致,但是一定都出现了。
