1.首先前提已经按照上一篇文章已经安装好了ROS(noetci),接下来请跟我一起来跑一下这个算法,
点开这个Github开源地址:https://github.com/HKUST-Aerial-Robotics/A-LOAM
首先根据代码要求,需要提前安装两个,Ceres和PCL。
1.1安装Ceres
ceres相关依赖:
1..1.1 Eigen 3.3 or later required.
使用终端apt命令安装
sudo apt-get install libeigen3-dev
Eigen只包含头文件,因此它不需要实现编译,只需要引入头文件即可编译项目。
Eigen头文件的默认安装位置是:“/usr/local/include/eigen3”
在很多程序中include时经常使用#include <Eigen/Dense>而不是使用#include <eigen3/Eigen/Dense>所以要做下处理(未使用)
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
1.1.2 CMake 3.5 or later required.
1.1.3 glog 0.3.1 or later. Recommended
安装ceres
克隆:
git clone https://ceres-solver.googlesource.com/ceres-solver
点击Ceres,这里会出现其网站,然后你会发现,给的克隆地址一直显示无法连接,这里直接点You can start with the latest stable release ,这样浏览器会直接把包给下载下来。
然后根据下面的代码安装:
# CMake sudo apt-get install cmake # google-glog + gflags sudo apt-get install libgoogle-glog-dev libgflags-dev # BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 sudo apt-get install libeigen3-dev # SuiteSparse and CXSparse (optional) sudo apt-get install libsuitesparse-dev
然后,编译
tar zxf ceres-solver-2.0.0.tar.gz mkdir ceres-bin cd ceres-bin cmake ../ceres-solver-2.0.0 make -j3 make test # Optionally install Ceres, it can also be exported using CMake which # allows Ceres to be used without requiring installation, see the documentation # for the EXPORT_BUILD_DIR option for more information. make install
make install 提示
更换命令
sudo make install
1.2 安装pcl
一条命令搞定
sudo apt install libpcl-dev
ubuntu20.04默认安装的是pcl_1.10 ,过程提示的相关依赖
sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common
sudo apt-get install libflann1.8 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
其他依赖
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install libopenni-dev
sudo apt-get install libopenni2-dev
1.3 build loam的工作空间
cd ~/catkin_ws/src git clone https://github.com/HKUST-Aerial-Robotics/A-LOAM.git cd ../ catkin_make source ~/catkin_ws/devel/setup.bash
如果git不下来,直接下载。
1.4
下载完源码后直接编译是不能通过的,需要进行一些修改才行。
1.4.1修改方法
- 将四个.cpp文件中的
/camera_init
修改为camera_init
- 将
scanRegistration.cpp
中的#include <opencv/cv.h>
修改为#include <opencv2/imgproc.hpp>
- 修改
kittiHelper.cpp
中CV_LOAD_IMAGE_GRAYSCALE
为cv::IMREAD_GRAYSCALE
1.4.2 编译源码
cd ~/catkin_ws/ catkin_make
如果编译过程报错
error: #error PCL requires C++14 or above
解决办法:
请打开catkin_ws->src->a-loam->CMakeLists.txt中添加,如下指令即可成功编译
set( CMAKE_CXX_STANDARD 14)
1.4.3 测试
下载nsh_indooroutdoor.bag 测试数据到你的 DATA文件夹中,然后在lunch文件中打开终端运行如下:
roslaunch aloam_velodyne_VLP_16.launch
再在data文件夹下打开终端:
rosbag play nsh_indoor_outdoor.bag
效果图如下: