Advertisement

Ubuntu20.04编译运行LIO-SAM

阅读量:

Ubuntu20.04编译运行LIO-SAM

目录

    • 获取源代码
  • 使用依赖库程序
  • 编译步骤包括:
    • CMakeLists.txt以及源码中的更改

    • 遇到的问题与解决方案

    • 4.运行

论文地址:LIO-SAM
源码地址:LIO-SAM code
LIO-SAM在Ubuntu 16.04和Ubuntu 18.04上的编译较为顺畅,然而在Ubuntu 20.04上却出现了显著差异而导致出现异常问题,并对此进行了详细记录

1.下载源码

建议直接下载源码编译,不要用其他的版本。

2.依赖库

  • ros-noetic
    参考其他blog
    ros安装完成后,再安装定位包
复制代码
    sudo apt-get install ros-noetic-fake-localization
    sudo apt-get install ros-noetic-robot-localization
  • 其他依赖包
    本地安装的依赖库版本支持其他平台上的相应版本运行。
    Boost 1.71版
    Point Cloud Library 1.10版
    Fast Library for Approximate Nearest Neighbor Search 1.9版
    OpenCV 4.3版
    GTSAM 4.2a7版
复制代码
    sudo apt install libboost-all-dev #1.71
    sudo apt install libflann-dev #1.9
    pcl-1.10 #使用源码编译安装
    opencv-4.3 #使用源码编译安装
    gtsam-4.2a7 #使用源码编译安装

3.编译

3.1 CMakeLists.txt和源码上的修改

复制代码
    set(CMAKE_BUILD_TYPE "Release")
    set(CMAKE_CXX_FLAGS "-std=c++14")

src->include->utility.h:18

复制代码
    // #include <opencv/cv.h>
    #include <opencv2/opencv.hpp>
    #include <opencv2/imgproc.hpp>

3.2 遇到的问题及解决

  • 问题1.flann和opencv冲突问题
复制代码
    /usr/include/flann/util/serialization.h:56:33:   required from ‘static void flann::serialization::Serializer<T>::save(OutputArchive&, const T&) [with OutputArchive = flann::serialization::SaveArchive; T = flann::LshIndex<flann::L2_Simple<float> >]’
    /usr/include/flann/util/serialization.h:316:28:   required from ‘Archive& flann::serialization::OutputArchive<Archive>::operator&(const T&) [with T = flann::LshIndex<flann::L2_Simple<float> >; Archive = flann::serialization::SaveArchive]’
    /usr/include/flann/algorithms/lsh_index.h:198:9:   required from ‘void flann::LshIndex<Distance>::saveIndex(FILE*) [with Distance = flann::L2_Simple<float>; FILE = _IO_FILE]’
    /usr/include/flann/algorithms/lsh_index.h:195:10:   required from here
    /usr/include/flann/util/serialization.h:34:14: error: ‘class std::unordered_map<unsigned int, std::vector<unsigned int> >’ has no member named ‘serialize’
    make[2]: *** [LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/build.make:63: LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/src/mapOptmization.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:545: LIO-SAM/CMakeFiles/lio_sam_mapOptmization.dir/all] Error 2
    make: *** [Makefile:141: all] Error 2
    Invoking "make -j16 -l16" failed

核心问题在于OpenCV与FLANN在使用UnorderedMap时产生的矛盾,源自stackflow

复制代码
    sudo vi /usr/include/flann/util/lsh_table.h
    line:43
    line:131
    line:191
    这三行位置修改
     // #if USE_UNORDERED_MAP
    #if FLANN_USE_UNORDERED_MAP
  • 问题2 :pcl和boost问题
复制代码
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl7PCLBaseINS_9PointXYZIEEE[_ZTVN3pcl7PCLBaseINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl6FilterINS_9PointXYZIEEE[_ZTVN3pcl6FilterINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x20): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setInputCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x28): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > > const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x30): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
    /usr/bin/ld: CMakeFiles/lio_sam_featureExtraction.dir/src/featureExtraction.cpp.o:(.data.rel.ro._ZTVN3pcl9VoxelGridINS_9PointXYZIEEE[_ZTVN3pcl9VoxelGridINS_9PointXYZIEEE]+0x38): undefined reference to `pcl::PCLBase<pcl::PointXYZI>::setIndices(boost::shared_ptr<pcl::PointIndices const> const&)'
    collect2: error: ld returned 1 exit status
    make[2]: *** [LIO-SAM-DetailedNote/CMakeFiles/lio_sam_featureExtraction.dir/build.make:396: /home/project/LIO-SAM/devel/lib/lio_sam/lio_sam_featureExtraction] Error 1
    make[1]: *** [CMakeFiles/Makefile2:633: LIO-SAM-DetailedNote/CMakeFiles/lio_sam_featureExtraction.dir/all] Error 2

由于在utility.h中包含了ros的pcl转换头文件(#include <pcl_conversions/pcl_conversions.h>),neonic中的默认配置是使用pcli-1.98。但是最初使用的版本是pcli-2.4遇到了性能问题。当修改为源码后,则可以直接使用pcli-3.8解决问题

  • 问题3.运行时的gtsam问题
复制代码
    /home/project/LIO-SAM/devel/lib/lio_sam/lio_sam_imuPreintegration: error while loading shared libraries: libmetis-gtsam.so: cannot open shared object file: No such file or directory
    process[lio_sam_mapOptmization-4]: started with pid [1627042]
    /home//projectLIO-SAM/devel/lib/lio_sam/lio_sam_mapOptmization: error while loading shared libraries: libmetis-gtsam.so: cannot open shared object file: No such file or directory

由于gtsam的安装路径设置为/usr/local/lib中,请确保配置文件已正确配置。若无法找到位于/opt/ros(neo)/lib中的配置文件,请直接复制相应的代码至该目录下完成安装。

复制代码
    sudo cp libmetis-gtsam.so /opt/ros/noetic/lib

编译成功。

4.运行

在这里插入图片描述

全部评论 (0)

还没有任何评论哟~