LSD-SLAM源代码是源代码在ROS fuerte + Ubuntu 12.04和ROS indigo + Ubuntu 14.04,本次使运行在Ubuntu16.04 kinectic。
Ref : http://wiki.ros.org/kinetic/Installation/Ubuntu
a.安装ubutnu系统(https://wiki.ubuntu.org.cn/%E9%A6%96%E9%A1%B5)
b.安装对应ubuntu版本的ROS系统
注意:比如ubuntu14.04 对应ROS indigo, ubuntu16.04 对应ROS kinetic,本ppt以ROS kinetic为例
1)添加ROS软件源
$sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" /etc/apt/sources.list.d/ros-latest.list’
2)添加秘钥
$sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3)安装
$sudo apt-get update
$sudo apt-get install ros-kinetic-desktop-full
4)初始化rosdep
$sudo rosdep init
$rosdep update
5)设置环境变量
$echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
$source ~/.bashrc
6)安装rosinstall
$sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
7)测试安装 $roscore
1. 创建rosbuild工作空间:
sudo apt-get install python-rosinstall
mkdir ~/rosbuild_ws
cd ~/rosbuild_ws
rosws init . /opt/ros/kinetic
mkdir package_dir
rosws set ~/rosbuild_ws/package_dir -t .
echo "source ~/rosbuild_ws/setup.bash" >> ~/.bashrc
bash
cd package_dir
2.安装依赖
sudo apt-get install ros-kinetic-libg2o ros-kinetic-cv-bridge liblapack-dev libblas-dev freeglut3-dev libsuitesparse-dev libx11-dev
sudo apt install libqglviewer-dev-qt4
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libQGLViewer-qt4.so libQGLViewer.so.2
3.获取LSD-SLAM和编译
git clone https://github.com/tum-vision/lsd_slam.git lsd_slam
rosmake lsd_slam
4.编译报错:
报错1.编译过程中出现错误: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
报错2.编译过程中出现错误:invalid initialization of non-const reference of type 'qreal& {aka double&}' from an rvalue of type 'qreal {aka double}'
分析: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
3).报错: 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*)
解决:在lsd_slam_viewer中的CMAKELISTS.txt的最后加上:
#OpenCV3.4.3 我系统多opencv版本
set(OpenCV_DIR /usr/local/opencv-3.4.3/share/OpenCV)
find_package(OpenCV 3.4.3 REQUIRED)
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS} /usr/local/opencv-3.4.3/include)
link_directories(${OpenCV_LIBRARY_DIRS} /usr/local/opencv-3.4.3/lib)
rosbuild_add_executable(videoStitch src/main_stitchVideos.cpp)
target_link_libraries(videoStitch ${OpenCV_LIBS})
3.报错
解决:将文件lsd_slam_viewer/src/KeyFrameDisplay.cpp的头文件:#include "opencv2/opencv.hpp"注释掉
报错4.报错
解决:在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})
报错5.报错
$ rosmake lsd_slam
[rosmake-0] Finished <<< lsd_slam_viewer [FAIL] [ 2.87 seconds ] [ rosmake ] Halting due to failure in package lsd_slam_viewer.
解决方案是:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:"pwd"
https://github.com/tum-vision/lsd_slam/issues/316
报错6.报错
$ rosmake lsd_slam
错误信息:
[rosmake-3] Starting >>> lsd_slam_viewer [ make ]
[rosmake-3] Finished <<< lsd_slam_viewer [SKIP] No rule to make target None
viewer始终无法得出的可执行的二进制文件
解决方法是:
采用的qt4
报错7.报错
rosrun lsd_slam_core live_slam image:=/image_raw camera_info:=/camera_info
报错:
*** Error in `/home/name/rosbuild_ws/package_dir/lsd_slam/lsd_slam_core/bin/live_slam': double free or corruption (out): 0x08f11900 ***
解决方案是采用eigen3.2.5,下载见 https://bitbucket.org/eigen/eigen/downloads/?tab=tags,详情见https://github.com/tum-vision/lsd_slam/issues/208
本系统有两个eigen3.2.9和3.2.5,实现版本切换可采用为:https://blog.csdn.net/qq_36594547/article/details/102955881
6.编译通过和运行结果
参考: