HBA是一个激光点云层级式的全局优化的程序,他的论文题目是:HBA: A Globally Consistent and Efficient Large-Scale LiDAR Mapping Module,对应的github地址是:HKU-Mars-Lab · GitHub
学习本博客,可以学到gtsam安装,cmake高版本安装,ceres2.2.0的安装,以及一个HBA编译问题的解决,最后把HBA给编译成功.
(1)安装gtsam
1.首先安装 依赖
sudo apt-get install libtbb-dev
sudo apt-get install libeigen3-dev
2.然后下载源代码
git clone https://bitbucket.org/gtborg/gtsam.git
3.编译安装
cd gtsam
mkdir build && cd build
cmake ..
make
sudo make install
(2)安装cmake 大于3.10版本
安装ceres的时候,必须要求cmake在3.16-3.28之间,但是ros的cmake是3.10版本,因此需要单独安装cmake。参考网上教程可以发现,很多cmake安装 的第一行命令中,有autoremove,这是一个天坑安装cmake的方法,因为它会直接把ros给卸载了。
正确的安装方法如下:
1.下载cmake-3.18.5.tar.gz
Index of /files/v3.18
2. 解压并进入目录中
tar -xf cmake-3.18.5.tar.gz
cd cmake-3.18.5/
3.执行配置、编译和安装命令
./configure --prefix=/usr/local/cmake
make
sudo make install
5.设置软连接
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
如果执行上述命令报“ln: failed to create symbolic link ‘/usr/bin/cmake’: File exists”错误,显示已有软连接(‘/usr/bin/cmake’),则执行如下命令删除软链接(软连接’/usr/bin/cmake’仅为示例,请用户以实际情况为准):
rm -rf /usr/bin/cmake
6.检查cmake的版本
cmake --version
详细可参考 :ubuntu18.04安装cmake3.12.0步骤_ubuntu安装cmake3.12-CSDN博客
(3)安装ceres2.2.0
1.下载
GitHub - ceres-solver/ceres-solver: A large scale non-linear optimization library
2.安装官网教程
官网:Installation — Ceres Solver
2.1首先配置环境
sudo apt-get install libgoogle-glog-dev libgflags-dev
# Use ATLAS for BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# SuiteSparse (optional)
sudo apt-get install libsuitesparse-dev
2.2然后构建和编译以及安装
tar zxf ceres-solver-2.2.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-2.2.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
2.3最后可以用一个例子进行测试
bin/simple_bundle_adjuster ../ceres-solver-2.2.0/data/problem-16-22106-pre.txt
这样就安装好了ceres2.2.0
(4)解决编译问题typedef struct LZ4_stream_t LZ4_stream_t’
在ceres也通过编译之后,会遇到:
/usr/include/lz4.h:196:57: error: conflicting declaration ‘typedef struct LZ4_stream_t LZ4_stream_t’
这时候使用
sudo mv /usr/include/flann/ext/lz4.h /usr/include/flann/ext/lz4.h.bak
sudo mv /usr/include/flann/ext/lz4hc.h /usr/include/flann/ext/lz4hc.h.baksudo ln -s /usr/include/lz4.h /usr/include/flann/ext/lz4.h
sudo ln -s /usr/include/lz4hc.h /usr/include/flann/ext/lz4hc.h
(5)编译HBA程序
然后进入HBA的ws环境,进行catkin_make就可以编译成功.