JokerJohn / PALoc

[TMECH'2024] Official codes of the paper. PALoc: Advancing SLAM Benchmarking with Prior-Assisted 6-DoF Trajectory Generation and Uncertainty Estimation
https://ieeexplore.ieee.org/document/10480308
165 stars 2 forks source link

您好,前辈,我一直都在follow您的工作,我想请教您一个运行算法中的编译问题! #9

Closed KJ-Falloutlast closed 1 day ago

KJ-Falloutlast commented 5 days ago

前辈您好,我关注您的工作很久了,感谢您开源您的工作,向您致敬。我目前在运行您的算法的时候,遇到了如下问题: 首先说下我的机器配置:

  1. ubuntu18.04
  2. 库版本:pcl 1.8, Open3D 0.17.0,gtsam 4.2,其他库都是ubuntu18.04默认版本
  3. cmakelists.txt如下
    
    cmake_minimum_required(VERSION 3.0.2)
    project(paloc)

Compile as C++11, supported in ROS Kinetic and newer

set(CMAKE_BUILD_TYPE "Release") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")

Clang compiler in macOS only accepts std::random_shuffle in C++14

# DBOW3 also need the version of c++ below 17
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_STANDARD 14)

else () set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_STANDARD 14) # WE CAN REMOVE THIS endif ()

message("Current CPU archtecture: ${CMAKE_SYSTEM_PROCESSOR}") if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") include(ProcessorCount) ProcessorCount(N) message("Processer number: ${N}") if (N GREATER 4) add_definitions(-DMP_EN) add_definitions(-DMP_PROC_NUM=3) message("core for MP: 3") elseif (N GREATER 3) add_definitions(-DMP_EN) add_definitions(-DMP_PROC_NUM=2) message("core for MP: 2") else () add_definitions(-DMP_PROC_NUM=1) endif () else () add_definitions(-DMP_PROC_NUM=1) endif () find_package(OpenMP QUIET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")

from fastlio

SET(CMAKE_BUILD_TYPE "Debug")

ADD_COMPILE_OPTIONS(-std=c++14 )

ADD_COMPILE_OPTIONS(-std=c++11 )

set( CMAKE_CXX_FLAGS "-std=c++14 -O3" )

set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )

add_definitions(-w)

add_definitions(-DROOT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_CXX_STANDARD 11)

set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -std=c++0x -std=c++14 -fexceptions")

message("Current CPU archtecture: ${CMAKE_SYSTEM_PROCESSOR}")

if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" )

include(ProcessorCount)

ProcessorCount(N)

message("Processer number: ${N}")

if(N GREATER 4)

add_definitions(-DMP_EN)

add_definitions(-DMP_PROC_NUM=3)

message("core for MP: 3")

elseif(N GREATER 3)

add_definitions(-DMP_EN)

add_definitions(-DMP_PROC_NUM=2)

message("core for MP: 2")

else()

add_definitions(-DMP_PROC_NUM=1)

endif()

else()

add_definitions(-DMP_PROC_NUM=1)

endif()

find_package(OpenMP QUIET)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")

from fastlio

for fastlio

add_definitions(-DROOT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\") find_package(PythonLibs REQUIRED) find_path(MATPLOTLIB_CPP_INCLUDE_DIRS "matplotlibcpp.h")

open3d

find_package(Open3D REQUIRED)

eigen

find_package(Eigen3 REQUIRED)

pcl

find_package(PCL 1.8 REQUIRED)

GTSAM

find_package(GTSAM REQUIRED QUIET)

add ceres and openCV GeographicLib

find_package(Ceres REQUIRED) find_package(OpenCV REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/share/cmake/geographiclib/") find_package (GeographicLib REQUIRED)

###########################################################################

Find Boost

find_package(Boost REQUIRED COMPONENTS filesystem regex timer date_time program_options) if (NOT TARGET Boost::boost) add_library(Boost::boost INTERFACE IMPORTED include/factors/gravity_factor.h include/factors/gravity_estimator.h include/factors/gravity_kalman_filter.h) set_target_properties(Boost::boost PROPERTIES INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}") endif () ###########################################################################

find_package(catkin REQUIRED COMPONENTS geometry_msgs visualization_msgs nav_msgs sensor_msgs roscpp rospy rosbag std_msgs pcl_ros tf tf_conversions message_generation eigen_conversions rosconsole # 确保包含这个库 )

generate_messages( DEPENDENCIES geometry_msgs )

catkin_package( INCLUDE_DIRS include CATKIN_DEPENDS tf geometry_msgs nav_msgs roscpp rospy std_msgs rosconsole message_runtime DEPENDS

DEPENDS EIGEN3 PCL

)

include_directories( ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${PCL_INCLUDE_DIRS} ${GTSAM_INCLUDE_DIR} ${Y_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${GeographicLib_INCLUDE_DIRS} ${Open3D_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} # add boost include )

fastlio

add_executable(fastlio include/fast_lio/ikd-Tree/ikd_Tree.cpp src/fastlio/laserMapping.cpp src/fastlio/preprocess.cpp)

不需要add_dependencies,它是为了msg, srv而设计

target_link_libraries(fastlio ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${PYTHON_LIBRARIES}) target_include_directories(fastlio PRIVATE ${PYTHON_INCLUDE_DIRS})

pgo_localization

add_executable(pgo_localization src/paloc/paloc.cpp src/paloc/cloud_process.cpp src/paloc/data_saver.cpp include/factors/gravity_factor.h include/factors/gravity_kalman_filter.h include/base_type.cpp )

target_link_libraries(pgo_localization ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${PYTHON_LIBRARIES} ${Open3D_LIBRARIES} ${Boost_LIBRARIES} # add boost ${OpenCV_LIBS} #OpenCV为LIBS ${GeographicLib_LIBRARIES} ${CERES_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam )


我的问题如下:
1. 出现了:“ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)’未定义的引用”
2. 出现了:“/usr/local/include/gtsam/base/Testable.h:157:对‘gtsam::imuBias::ConstantBias::print(std::string const&) const’未定义的引用”
3. 出现了:“/usr/local/include/gtsam/base/Testable.h:157:对‘gtsam::Pose3::print(std::string const&) const’未定义的引用”等等问题,我的程序能够100%编译通过,最后卡在了链接库上面。
通过不断调试,我目前可以证明:
1. 不是系统环境的问题,目前我的机器能够成功编译Liosam, fastlio2, dlio, ig-lio等算法
2. cmake和xml中,把所有的库都链接到可执行文件中
3. 在cloud_process.h, paloc.h, data_saver.h中,把所有的应该Include的库的头文件也包含进去。
目前问题的截图如下:
![image](https://github.com/user-attachments/assets/989a862f-4d4c-4a45-828d-87cf507e0b08)
最终总结:
1. 问题只能指向程序本身,而非系统环境问题,因为其他算法都能成功编译。
2. 在其他方面是否有可能发生的问题,请问下您这个问题您有出现过吗?有无解决方法呢?谢谢!
JokerJohn commented 5 days ago

@KJ-Falloutlast 这个问题我遇到过的,我记得是open3D的问题,open3D的安装没那么简单。严格按照官网的install教程来,按照好后,检测写个ros的测试节点,看看项目能否正确rosrun,没问题的话,paloc这个也没问题。具体的解决方法我忘记了,得找一下。你要不看看我的CloudMapEvaluation这个cmake仓库能否正常编译使用,这个可以的话,我猜paloc也可以。

KJ-Falloutlast commented 5 days ago

非常感谢前辈的建议,就在1个小时前,我也意外地在Open3D的github链接中发现了这个问题,我的解决思路是这样的:

  1. 重新安装Open3D: git clone https://github.com/isl-org/Open3D
  2. 进入v0.17.0: git checkout v0.17.0
  3. 安装依赖:cd util && sudo ./install_deps_ubuntu.sh
  4. mkdir build && cd build
  5. cmake执行不要直接cmake .., 否则会导致Open3D与ROS冲突(这点至关重要!): cmake -DBUILD_EIGEN3=ON -DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JSONCPP=ON -DBUILD_PNG=ON -DGLIBCXX_USE_CXX11_ABI=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DBUILD_UNIT_TESTS=ON ..
  6. make
  7. sudo make install
  8. 进入算法中rm build devel后重新编译 目前为止,我的问题已经解决,第一次遇到因为cmake不对而导致catkin_make失败的问题,也是想当然cmake ..了,以后会注意这个问题。 再次感谢胡博的宝贵建议!respect!
JokerJohn commented 5 days ago

@KJ-Falloutlast 解决就好。我后面整个docker就好了,目前还没有时间整理这些。

KJ-Falloutlast commented 4 days ago

∠(°ゝ°)