gtsam的安装过程及lego-loam问题总结

注意:
不用卸载旧版本的gtsam,只需要下载想要的版本,重新源码编译安装一遍即可,这样会把之前的版本直接覆盖掉。

https://codechina.csdn.net/mirrors/borglab/gtsam/-/tree/4.0.0

mkdir build
cd build
cmake ..

sudo make 
sudo make install  

编译lego-loam可能报错

CMake Error at /usr/share/cmake-3.5/Modules/CMakeFindDependencyMacro.cmake:45 (message):
Invalid arguments to find_dependency
Call Stack (most recent call first):
/usr/local/lib/cmake/GTSAM/GTSAMConfig.cmake:17 (find_dependency)
LeGO-LOAM/LeGO-LOAM/CMakeLists.txt:23 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/fish/catkin_legoLOAM/build/CMakeFiles/CMakeOutput.log”.
See also “/home/fish/catkin_legoLOAM/build/CMakeFiles/CMakeError.log”.
Invoking “cmake” failed

解决方法:
将/usr/local/lib/cmake/GTSAM/GTSAMConfig.cmake:17 行的find_dependency改成find_package。改完后重新catkin_make -j1即可。

编译lego-loam报错

LEGO-LOAM编译出错 :fatal error: cloud_msgs/cloud_info.h: No such file or directory。
gtsam的安装过程及lego-loam问题总结_第1张图片
解决方案:

catkin_make -j1

# 或者
catkin_make -DCATKIN_WHITELIST_PACKAGES="cloud_msgs"

运行lego-loam报错

运行“ roslaunch lego_loam run.launch” 出现了如下图所示的错误:
gtsam的安装过程及lego-loam问题总结_第2张图片
下载官网的gtsam4.0.0版本,重新编译安装gtsam即可。问题解决。。。

经过多次测试,我遇到的这种问题用以下方法可以解决。修改…
/gtsam-4.0.0/cmake/GtsamBuildTypes.cmake

# Clang uses a template depth that is less than standard and is too small
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
    # Apple Clang before 5.0 does not support -ftemplate-depth.
    if(NOT (APPLE AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0"))
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
    endif()
endif()

# 添加以下内容
option(GTSAM_BUILD_WITH_MARCH_NATIVE  "Enable/Disable building with all instructions supported by native architecture (binary may not be portable!)" ON)
if(GTSAM_BUILD_WITH_MARCH_NATIVE)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()

/gtsam-4.0.0/CMakeLists.txt

if(GTSAM_UNSTABLE_AVAILABLE)
    print_config_flag(${GTSAM_BUILD_UNSTABLE}          "Build libgtsam_unstable        ")
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper)

# 添加以下内容
print_config_flag(${GTSAM_BUILD_WITH_MARCH_NATIVE}     "Build for native architecture  ")

此修改仅适用lego-loam,如果编译运行lio-sam,则不需要修改,否则会报错。

参考链接:
[1] Lego-LOAM 运行时出现错误
[2] LeGO-LOAM编译、运行及其错误记录
[3] 试LOAM以及LEGO-LOAM过程中遇到的坑

你可能感兴趣的:(室内机器人专栏,3D,SLAM)