Ubuntu14.04运行lsdslam与问题解决

本文是在Ubuntu14.04中运行LSDSLAM的步骤以及出现的一系列问题的解决,最终可以运行数据集和实时运行

基本环境:Ubuntu14.04  opencv3.1.0  但是有问题,因此后来又安装了opencv2.4.9。感谢大佬。

前序的工作和该博主完全一致:

https://blog.csdn.net/softimite_zifeng/article/details/78632506

出现的问题:

已解决:raise Exception(r"""quotes not allowed in description string '%s'""" % description)

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

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

之后,

出现新的问题:

 main_stitchVideos.cpp:(.text+0x8f30): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x8fc9): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x8fdb): undefined reference to `cv::String::deallocate()'

  CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o: In function `inlayVid(int, char**)':

  main_stitchVideos.cpp:(.text+0x9c62): undefined reference to `cv::imread(cv::String const&, int)'

  main_stitchVideos.cpp:(.text+0x9c6a): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x9cb3): undefined reference to `cv::imread(cv::String const&, int)'

  main_stitchVideos.cpp:(.text+0x9cbd): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x9d02): undefined reference to `cv::imread(cv::String const&, int)'

  main_stitchVideos.cpp:(.text+0x9d0c): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x9d5a): undefined reference to `cv::imread(cv::String const&, int)'

  main_stitchVideos.cpp:(.text+0x9d67): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0x9db1): undefined reference to `cv::imread(cv::String const&, int)'

  main_stitchVideos.cpp:(.text+0x9dbe): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xa629): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xa654): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'

  main_stitchVideos.cpp:(.text+0xa661): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xa6c6): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xa6e7): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'

  main_stitchVideos.cpp:(.text+0xa6f4): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xaec5): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xaee8): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xaf08): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xaf28): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xaf46): undefined reference to `cv::String::allocate(unsigned long)'

  main_stitchVideos.cpp:(.text+0xb146): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xb1e2): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xb20e): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xb23f): undefined reference to `cv::String::deallocate()'

  main_stitchVideos.cpp:(.text+0xb270): undefined reference to `cv::String::deallocate()'

  CMakeFiles/videoStitch.dir/src/main_stitchVideos.cpp.o:main_stitchVideos.cpp:(.text+0xb33e): more undefined references to `cv::String::deallocate()' follow

  collect2: error: ld returned 1 exit status

  make[3]: *** [../bin/videoStitch] Error 1

  make[3]: Leaving directory `/home/zc/rosbuild_ws/package_dir/lsd_slam/lsd_slam_viewer/build'

  make[2]: *** [CMakeFiles/videoStitch.dir/all] Error 2

  make[2]: Leaving directory `/home/zc/rosbuild_ws/package_dir/lsd_slam/lsd_slam_viewer/build'

  make[1]: *** [all] Error 2

  make[1]: INTERNAL: Exiting with 3 jobserver tokens available; should be 2!

  make[1]: Leaving directory `/home/zc/rosbuild_ws/package_dir/lsd_slam/lsd_slam_viewer/build'

-------------------------------------------------------------------------------}

好像是因为opencv版本的问题,

pkg-config --modversion opencv

查看后发现是3.1.0

想办法解决。

找到了:

https://www.cnblogs.com/cc111/p/9382694.html

解决:   在lsd_slam_viewer中的CMAKELISTS.txt的最后加上:
    find_package(OpenCV REQUIRED) 
    rosbuild_add_executable(videoStitch src/main_stitchVideos.cpp)
    target_link_libraries(videoStitch ${OpenCV_LIBS})    

 接着还有一个报错,是在lsd_slam_core路径中的错误:

解决:在lsd_slam_core中的CMAKELISTS.txt的最后增加boost_system库的链接: 
      find_package(OpenCV REQUIRED)
        # 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})

然后还有一个错误:

/usr/bin/ld: cannot find -lglut

解决方法:我的是so.3   使用命令   locate libglut  找到的

ln -sv libglut.so.3 libglut.so

https://zh-ka-163-com.iteye.com/blog/2214601

使用数据集来跑

参考:

https://blog.csdn.net/softimite_zifeng/article/details/78632506
(1)下载数据集

(2)roscore

(3)rosrun lsd_slam_viewer viewer

(4)rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info

(5)rosbag play dataset/LSD_room.bag

将上述命令中的dataset/LSD_room.bag替换为你之前下载的数据集的所在的路径

然后出现问题:

zc@ubuntu:~ $ rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info
WAITING for ROS camera calibration!
Received ROS Camera Calibration: fx: 254.326950, fy: 375.934387, cx: 267.381897, cy: 231.599091 @ 640x480
RECEIVED ROS camera calibration!
Started mapping thread!
Doing Random initialization!
Started constraint search thread!
Started optimization thread
Segmentation fault (core dumped)

需要做的是到目录

lsd_slam/lsd_slam_core/src/util/settings.cpp

把其中的

bool displayDepthMap = true;

改成

//bool displayDepthMap = true;
bool displayDepthMap = false;

 这一步就是把debugdepth的那个界面不显示。

点云图正常显示。

然后就会出现新的问题:

rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info
WAITING for ROS camera calibration!
Received ROS Camera Calibration: fx: 254.326950, fy: 375.934387, cx: 267.381897, cy: 231.599091 @ 640x480
RECEIVED ROS camera calibration!
Doing Random initialization!
Started mapping thread!
Started constraint search thread!
Started optimization thread
Done Random initialization!
TRACKING LOST for frame 50 (0.00% good Points, which is 18.18% of available points, DIVERGED)!
warning: reciprocal tracking on new frame failed badly, added odometry edge (Hacky).

图片有显示,

 如果这个时候运行实时的命令,那么将会在优化线程的一步卡死。

最后发现是opencv的版本问题,一开始用的是opencv3.1.0,最后修改成2.4.9解决问题,参考如下:

 然后这边对于opencv的解决方法:

https://www.cnblogs.com/hxzkh/p/8488132.html    LSDSLAM

https://www.cnblogs.com/hxzkh/p/8473190.html    ORBSLAM  中的opencv解决

参考解决方法:

https://answers.ros.org/question/219063/segmentation-fault-in-lsd_slam/

https://blog.csdn.net/osgoodwu/article/details/79900620

github上哟一个:

https://github.com/tum-vision/lsd_slam/issues/30

最后这个问题发现其实是opencv版本的问题,我的是3.1.0,之后又安装了一个2.4.9的opencv,然后就可以了:

https://www.cnblogs.com/1228073191Blog/p/10927384.html

安装一个opencv2.4.9

然后更改:

然后编辑 lsd_slam_core 下的 CMakeLists.txt 文件,11行左右添加:

set(OpenCV_DIR ~/opencv-2.4.9/share/OpenCV)

include_directories(~/opencv-2.4.9/include)

find_package(cmake_modules REQUIRED)
然后编辑 lsd_slam_viewer 下的 CMakeLists.txt 文件,11行左右添加:

set(OpenCV_DIR ~/opencv-2.4.9/share/OpenCV)
include_directories(~/opencv-2.4.9/include)
find_package(cmake_modules REQUIRED)

就可以运行数据集了。

实时跑起来:

https://blog.csdn.net/buptwbs/article/details/52460758

(1)启动摄像头相关参考,主要是安装usb_cam

https://blog.csdn.net/qq_25241325/article/details/82705003

http://www.wh-robot.com/whb/?p=1232

1. roscore
2. rosrun lsd_slam_viewer viewer
3. rosrun usb_cam usb_cam_node
4. rosrun image_view image_view image:=/usb_cam/image_raw
5. rosrun lsd_slam_core live_slam /image:=/usb_cam/image_raw _calib:=/home/zhangchi/Desktop/LSDSlamDataset/LSD_room/cameraCalibration.cfg 
其中的calib的路径偷懒直接使用了数据集中的
原文地址:https://www.cnblogs.com/1228073191Blog/p/10919650.html