本文仅供解决运行问题,不做详细教程
运行环境:ubuntu20.04
gtasm4.0.0与ubuntu20.04不太兼容,改装gtasm4.1.1(按照下述代码就可,已更正)
1.按照文档中附的readme.md安装依赖(默认ROS已安装完毕,否则遵照LOAM教程)
wget -O ~/Downloads/gtsam.zip https://github.com/borglab/gtsam/archive/refs/tags/4.1.1.zip
cd ~/Downloads/ && unzip gtsam.zip -d ~/Downloads/
cd ~/Downloads/gtsam-4.1.1/
mkdir build && cd build
cmake ..
sudo make install
2.编译
替换lego-loam中的CMakeLists.txt文件为下:
cmake_minimum_required(VERSION 2.8.3)
project(lego_loam)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lboost_system -DGTSAM_USE_SYSTEM_EIGEN=ON")
find_package(catkin REQUIRED COMPONENTS
tf
roscpp
rospy
cv_bridge
image_transport
pcl_ros
pcl_conversions
std_msgs
sensor_msgs
geometry_msgs
nav_msgs
cloud_msgs
)
find_package(GTSAM REQUIRED QUIET)
find_package(PCL REQUIRED QUIET)
find_package(OpenCV REQUIRED QUIET)
find_package(Boost REQUIRED COMPONENTS system timer thread serialization chrono)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS cloud_msgs
DEPENDS PCL
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${GTSAM_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
link_directories(
include
${OpenCV_LIBRARY_DIRS}
${PCL_LIBRARY_DIRS}
${GTSAM_LIBRARY_DIRS}
${Boost_LIBRARY_DIRS}
)
add_executable(imageProjection src/imageProjection.cpp)
add_dependencies(imageProjection ${catkin_EXPORTED_TARGETS} cloud_msgs_gencpp)
target_link_libraries(imageProjection ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
add_executable(featureAssociation src/featureAssociation.cpp)
add_dependencies(featureAssociation ${catkin_EXPORTED_TARGETS} cloud_msgs_gencpp)
target_link_libraries(featureAssociation ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
add_executable(mapOptmization src/mapOptmization.cpp)
target_link_libraries(mapOptmization ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} gtsam)
add_executable(transformFusion src/transformFusion.cpp)
target_link_libraries(transformFusion ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
3.继续按照lego-loam要求运行如下:
cd ~/catkin_ws/src
git clone https://github.com/RobustFieldAutonomyLab/LeGO-LOAM.git
cd ..
catkin_make -j1