ubuntu16.04安装、编译LSD-SLAM遇到错误及解决

1、

报错:ERROR [gendeps] 1 Finding dependencies for /home/cc/rosbuild_ws/package_dir/lsd_slam/lsd_slam_viewer/cfg/LSDSLAMViewerParams.cfg

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第1张图片

分析:顾名思义,不应该在描述中出现引号(单引号或双引号),可以通过查看错误内容得知需要修改的文件的名称。

解决方法:

1) lsd_slam_viewer/cfg/LSDSLAMViewerParams.cfg 第20行scaledDepthVarTH:单词 point's和keyframe's 中出现了单引号,删除单引号 第21行absDepthVarTH:单词 point's 第24行cutFirstNKf:单词 keyframe's

2) lsd_slam_core/cfg/LSDDebugParams.cfg 第11行plotStereoImages:单词 what's 第12行plotTracking:单词 what's 第48行continuousPCOutput:单词 Keyfram's

2

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第2张图片

解决方法:

export LD_LIBRARY_PATH=$LD_LIBARARY_PATH:/usr/local/lib

打开一个新的终端输入:

sudo ldconfig

3、

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第3张图片

分析:qt中的qreal表示小数,在Ubuntu14.04中qreal就是float,但是Ubuntu16.04中qreal变为了double。错误中的变量x, y, z的类型是float,getPosition函数的形参类型是qreal,也就是double,所有x, y, z的值会自动转型为double,并存储在一个临时变量中,这会导致getPosition函数的实参变为了右值,但是右值不能初始化非const的引用。

解决方法: 1) lsd_slam_viewer/src/PointCloudViewer.h 第135行:将float x, y, z修改为qreal x, y, z或者double x, y, z 2) lsd_slam_viewer/src/PointCloudViewer.cpp 第325行:将float x, y, z修改为qreal x, y, z或者double x, y, z

4、

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第4张图片

分析:这条错误信息可以在文件/opt/ros/kinetic/include/opencv-3.2.0-dev/opencv2/stitching.hpp的58行查看到,信息中已经告诉了如何解决这个问题,即:将这个头文件放到任何X11头文件之前,或者也可以直接将#include "opencv2/opencv.hpp"注释掉

解决方法: 将文件lsd_slam_viewer/src/KeyFrameDisplay.cpp的头文件修改为如下顺序:

#include "opencv2/opencv.hpp"

#include

#include

#include 

或者

#include

#include

#include 

// #include "opencv2/opencv.hpp"/

5、

报错:

main_stitchVideos.cpp:(.text+0xd65c):对‘cv::imshow(cv::String const&, cv::_InputArray const&)’未定义的引用
main_stitchVideos.cpp:(.text+0xd668):对‘cv::String::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xd672):对‘cv::waitKey(int)’未定义的引用
main_stitchVideos.cpp:(.text+0xd715):对‘cv::fastFree(void*)’未定义的引用
main_stitchVideos.cpp:(.text+0xd7b5):对‘cv::fastFree(void*)’未定义的引用
main_stitchVideos.cpp:(.text+0xd84d):对‘cv::fastFree(void*)’未定义的引用
main_stitchVideos.cpp:(.text+0xd8e5):对‘cv::fastFree(void*)’未定义的引用
main_stitchVideos.cpp:(.text+0xd985):对‘cv::fastFree(void*)’未定义的引用
CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o:main_stitchVideos.cpp:(.text+0xda25): 跟着更多未定义的参考到 cv::fastFree(void*)
CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o:在函数‘inlayVid(int, char**)’中:
main_stitchVideos.cpp:(.text+0xdeb4):对‘cv::String::allocate(unsigned long)’未定义的引用
main_stitchVideos.cpp:(.text+0xdedf):对‘cv::Mat::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xdeec):对‘cv::Mat::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xdefd):对‘cv::Mat::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xdf0e):对‘cv::Mat::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xdf1f):对‘cv::Mat::deallocate()’未定义的引用
CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o:main_stitchVideos.cpp:(.text+0xdf30): 跟着更多未定义的参考到 cv::Mat::deallocate()
CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o:在函数‘inlayVid(int, char**)’中:
main_stitchVideos.cpp:(.text+0xdfb7):对‘cv::String::allocate(unsigned long)’未定义的引用
main_stitchVideos.cpp:(.text+0xe212):对‘cv::String::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xe23e):对‘cv::String::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xe26e):对‘cv::String::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xe282):对‘cv::String::deallocate()’未定义的引用
main_stitchVideos.cpp:(.text+0xe2a6):对‘cv::String::deallocate()’未定义的引用

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第5张图片

lsd_slam_viewer cmakelists修改如下:

find_package(Boost REQUIRED COMPONENTS filesystem system)

include_directories(${Boost_INCLUDE_DIRS})

target_link_libraries(viewer boost_system boost_filesystem)

target_link_libraries(videoStitch boost_system boost_filesystem)

lsd_slam_core cmakelists修改如下:

find_package(Boost REQUIRED COMPONENTS filesystem system)

include_directories(${Boost_INCLUDE_DIRS})

target_link_libraries(lsdslamboost_system boost_filesystem) 

target_link_libraries(live_slam boost_system boost_filesystem)

target_link_libraries(dataset_slam lsdslam boost_system boost_filesystem)

 

注意:应将targe_link放在add_executable之后,不然链接不到库。

6、

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第6张图片

 

lsd_slam_viewer cmakelists修改如下:

cmake_minimum_required(VERSION 2.4.6)
set (OpenCV_DIR "/home/vision1/Downloads/opencv-2.4.8/build") #########

project(lsd_slam_viewer)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
############################################
find_package(OpenCV REQUIRED)  
message(STATUS "OpenCV library status:")  
message(STATUS "    version: ${OpenCV_VERSION}")  
message(STATUS "    libraries: ${OpenCV_LIBS}")  
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")  
if(CMAKE_VERSION VERSION_LESS "2.4.6")  
  # Add OpenCV headers location to your include paths  
  include_directories(${OpenCV_INCLUDE_DIRS})  
endif()
###########################################
# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
set(ROS_BUILD_TYPE Release)

rosbuild_init()

ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/thirdparty/Sophus)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

find_package(OpenGL REQUIRED)
set(QT_USE_QTOPENGL TRUE)
set(QT_USE_QTXML TRUE)
find_package(QGLViewer REQUIRED)
find_package(Eigen3 REQUIRED)
include_directories(${QT_INCLUDES} ${EIGEN3_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR})

rosbuild_find_ros_package(dynamic_reconfigure)
include(${dynamic_reconfigure_PACKAGE_PATH}/cmake/cfgbuild.cmake)
gencfg()

 

 

# Messages & Services
rosbuild_genmsg()


# SSE flags
rosbuild_check_for_sse()
set(CMAKE_CXX_FLAGS
   "${SSE_FLAGS}"
)

# SSE Sources files
set(SOURCE_FILES         
  src/PointCloudViewer.cpp
  src/KeyFrameDisplay.cpp
  src/KeyFrameGraphDisplay.cpp
  src/settings.cpp
)

set(HEADER_FILES     
  src/PointCloudViewer.h
  src/KeyFrameDisplay.h
  src/KeyFrameGraphDisplay.h
  src/settings.h
)

include_directories(
  ${PROJECT_SOURCE_DIR}/thirdparty/Sophus
  #${Boost_INCLUDE_DIRS}/usr/lib/x86_64-linux-gnu/libpthread.so
)  
rosbuild_add_executable(viewer src/main_viewer.cpp ${SOURCE_FILES} ${HEADER_FILES})
#LIBS =-lpthread
#LIBS +=-lboost_system
#link_libraries("/usr/lib/x86_64-linux-gnu/libboost_system.so" "/usr/lib/x86_64-linux-gnu/libpthread.so")
target_link_libraries(viewer ${QGLViewer_LIBRARIES} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARY} boost_system GL glut GLU)

rosbuild_link_boost(viewer thread)

rosbuild_add_executable(videoStitch src/main_stitchVideos.cpp)
target_link_libraries(videoStitch ${OpenCV_LIBS})
#link_libraries("/usr/lib/x86_64-linux-gnu/libboost_system.so" "/usr/lib/x86_64-linux-gnu/libpthread.so")

 

lsd_slam_core:

cmake_minimum_required(VERSION 2.8.7)
set (OpenCV_DIR "/home/vision1/Downloads/opencv-2.4.8/build") #########

project(lsd_slam_core)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

############################################
find_package(OpenCV REQUIRED)  
message(STATUS "OpenCV library status:")  
message(STATUS "    version: ${OpenCV_VERSION}")  
message(STATUS "    libraries: ${OpenCV_LIBS}")  
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")  
if(CMAKE_VERSION VERSION_LESS "2.8.7")  
  # Add OpenCV headers location to your include paths  
  include_directories(${OpenCV_INCLUDE_DIRS})  
endif()

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
set(ROS_BUILD_TYPE Release)

rosbuild_init()

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_MODULE_PATH   ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

find_package(Eigen3 REQUIRED)
find_package(SuiteParse REQUIRED) # Apparently needed by g2o
find_package(X11 REQUIRED)

# FabMap
# uncomment this part to enable fabmap
#add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/openFabMap)
#include_directories(${PROJECT_SOURCE_DIR}/thirdparty/openFabMap/include)
#add_definitions("-DHAVE_FABMAP")
#set(FABMAP_LIB openFABMAP )

# Dynamic Reconfigure Services
rosbuild_find_ros_package(dynamic_reconfigure)
include(${dynamic_reconfigure_PACKAGE_PATH}/cmake/cfgbuild.cmake)
gencfg()

# SSE flags
rosbuild_check_for_sse()
add_definitions("-DUSE_ROS")
add_definitions("-DENABLE_SSE")

# Also add some useful compiler flag
set(CMAKE_CXX_FLAGS
   "${CMAKE_CXX_FLAGS} ${SSE_FLAGS} -march=native  -std=c++0x"
)

# Set source files
set(lsd_SOURCE_FILES
  ${PROJECT_SOURCE_DIR}/src/DataStructures/Frame.cpp
  ${PROJECT_SOURCE_DIR}/src/DataStructures/FramePoseStruct.cpp
  ${PROJECT_SOURCE_DIR}/src/DataStructures/FrameMemory.cpp
  ${PROJECT_SOURCE_DIR}/src/SlamSystem.cpp
  ${PROJECT_SOURCE_DIR}/src/LiveSLAMWrapper.cpp
  ${PROJECT_SOURCE_DIR}/src/DepthEstimation/DepthMap.cpp
  ${PROJECT_SOURCE_DIR}/src/DepthEstimation/DepthMapPixelHypothesis.cpp
  ${PROJECT_SOURCE_DIR}/src/util/globalFuncs.cpp
  ${PROJECT_SOURCE_DIR}/src/util/SophusUtil.cpp
  ${PROJECT_SOURCE_DIR}/src/util/settings.cpp
  ${PROJECT_SOURCE_DIR}/src/util/Undistorter.cpp
  ${PROJECT_SOURCE_DIR}/src/Tracking/Sim3Tracker.cpp
  ${PROJECT_SOURCE_DIR}/src/Tracking/Relocalizer.cpp
  ${PROJECT_SOURCE_DIR}/src/Tracking/SE3Tracker.cpp
  ${PROJECT_SOURCE_DIR}/src/Tracking/TrackingReference.cpp
  ${PROJECT_SOURCE_DIR}/src/IOWrapper/Timestamp.cpp
  ${PROJECT_SOURCE_DIR}/src/GlobalMapping/FabMap.cpp
  ${PROJECT_SOURCE_DIR}/src/GlobalMapping/KeyFrameGraph.cpp
  ${PROJECT_SOURCE_DIR}/src/GlobalMapping/g2oTypeSim3Sophus.cpp
  ${PROJECT_SOURCE_DIR}/src/GlobalMapping/TrackableKeyFrameSearch.cpp
)
set(SOURCE_FILES
  ${lsd_SOURCE_FILES}
  ${PROJECT_SOURCE_DIR}/src/IOWrapper/ROS/ROSImageStreamThread.cpp
  ${PROJECT_SOURCE_DIR}/src/IOWrapper/ROS/ROSOutput3DWrapper.cpp
  ${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
)

include_directories(
  ${EIGEN3_INCLUDE_DIR}
  ${PROJECT_SOURCE_DIR}/src
  ${PROJECT_SOURCE_DIR}/thirdparty/Sophus
  ${CSPARSE_INCLUDE_DIR} #Has been set by SuiteParse
  ${CHOLMOD_INCLUDE_DIR} #Has been set by SuiteParse
  ${Boost_INCLUDE_DIRS}/usr/lib/x86_64-linux-gnu/libboost_system.so
)


# build shared library.
rosbuild_add_library(lsdslam SHARED ${SOURCE_FILES})
target_link_libraries(lsdslam ${FABMAP_LIB} g2o_core g2o_stuff csparse cxsparse g2o_solver_csparse g2o_csparse_extension g2o_types_sim3 g2o_types_sba X11 boost_system)
rosbuild_link_boost(lsdslam thread)


# build live ros node
rosbuild_add_executable(live_slam src/main_live_odometry.cpp)
target_link_libraries(live_slam lsdslam boost_system ${OpenCV_LIBS})


# build image node
rosbuild_add_executable(dataset_slam src/main_on_images.cpp)
target_link_libraries(dataset_slam lsdslam boost_system ${OpenCV_LIBS})

7、

/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::getOptimalNewCameraMatrix(cv::_InputArray const&, cv::_InputArray const&, cv::Size_, double, cv::Size_, cv::Rect_*, bool)’未定义的引用
/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::waitKey(int)’未定义的引用
/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::namedWindow(cv::String const&, int)’未定义的引用
/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::destroyAllWindows()’未定义的引用
/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::resizeWindow(cv::String const&, int, int)’未定义的引用
/home/bdf/lsd-slam_ws/devel/lib/liblsdslam.so:对‘cv::imshow(cv::String const&, cv::_InputArray const&)’未定义的引用
collect2: error: ld returned 1 exit status

 

ubuntu16.04安装、编译LSD-SLAM遇到错误及解决_第7张图片

解决:lsd_slam_core/CMakeLists.txt更改

target_link_libraries(live_slam lsdslam boost_system ${OpenCV_LIBS})
# build image node

target_link_libraries(dataset lsdslam boost_system ${OpenCV_LIBS})

 

你可能感兴趣的:(ubuntu16.04安装、编译LSD-SLAM遇到错误及解决)