ORB_SLAM2 - yuhannah/skills_map GitHub Wiki
-
安装ubuntu16.04
OPEN_VINS、VINS_Mono、ORB_SLAM2都支持ubuntu16.04,但SVO2.0支持ubuntu18.04和ubuntu20.04,选择大部分算法支持的ubuntu16.04。
-
安装ROS Kinetic(自带OpenCV和Eigen3)
-
sources.list
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list' -
set up keys
sudo apt install curl # if you haven't already installed curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
网络不好时报错,多试几次会OK。
gpg: no valid OpenPGP data found.
-
up date package
sudo apt-get update
-
install,安装需要很长时间
sudo apt-get install ros-kinetic-desktop-full
-
environment setup
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc source ~/.bashrc
-
dependencies
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential ```` - initialize rosdep ```bash sudo apt install python-rosdep sudo rosdep init rosdep update网络不好时会报错,多试几次会OK。
ERROR: cannot download default sources list from: https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list Website may be down.
-
查看Eigen3版本,ros安装了Eigen3.2.92
pkg-config --modversion eigen3 3.2.92
-
查看OpenCV版本,ros安装了OpenCV3.3.1
sudo find / -iname "*opencv*" /opt/ros/kinetic/include/opencv-3.3.1-dev -
安装Eigen3(已有3.2.92>3.1.0,跳过)
-
安装OpenCV(已有3.3.1>2.4.3,跳过)
-
安装Pangolin v0.5
第一步查询依赖库。不知道哪个版本能用,先从master开始尝试:
# master ./scripts/install_prerequisites.sh --dry-run recommended报错找不到库:
NOTE: This is only a simulation! apt-get needs root privileges for real execution. Keep also in mind that locking is deactivated, so don't depend on the relevance to the real current situation! Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'libpng12-dev' instead of 'libpng-dev' E: Unable to locate package catch2
查询所有tag,从v0.9.3降级到v0.9.1,所有依赖库都能找到。找到了Eigen3,并且要安装OpenCV2.4。
# v0.9.1 libeigen3-dev is already the newest version (3.3~beta1-2). libeigen3-dev set to manually installed. The following additional packages will be installed: libass5 libavdevice-ffmpeg56 libavfilter-dev libavfilter-ffmpeg5 libavresample-dev libavresample-ffmpeg2 libbs2b0 libc++-helpers libc++1 libdc1394-22 libflite1 libopenal-data libopenal1 libopencv-core2.4v5 libopencv-imgproc2.4v5 libpostproc-dev libpostproc-ffmpeg53 libsdl1.2debian libsodium18 libzmq5 Suggested packages: clang The following NEW packages will be installed: libass5 libavdevice-dev libavdevice-ffmpeg56 libavfilter-dev libavfilter-ffmpeg5 libavresample-dev libavresample-ffmpeg2 libbs2b0 libc++-dev libc++-helpers libc++1 libdc1394-22 libflite1 libglew-dev libopenal-data libopenal1 libopencv-core2.4v5 libopencv-imgproc2.4v5 libpostproc-dev libpostproc-ffmpeg53 libsdl1.2debian libsodium18 libzmq5 ninja-build wayland-protocols 0 upgraded, 25 newly installed, 0 to remove and 98 not upgraded.
第二步安装库。报错找不到命令。
./scripts/install_prerequisites.sh -m brew all
因为`brew`是macOS上的包管理器的命令。
./scripts/install_prerequisites.sh: line 197: brew: command not found继续降级到v0.7,上述两步命令没有了,变成如下命令:
git clone https://github.com/stevenlovegrove/Pangolin.git cd Pangolin mkdir build cd build cmake .. cmake --build .
直接`cmake`,报错`cmake`版本太低:
cmake .. CMake Error at CMakeLists.txt:1 (cmake_minimum_required): CMake 3.8 or higher is required. You are running version 3.5.1 -- Configuring incomplete, errors occurred! See also "/home/yu/sources/Pangolin/build/CMakeFiles/CMakeOutput.log". See also "/home/yu/sources/Pangolin/build/CMakeFiles/CMakeError.log".
继续降级到v0.6,查看`cmake`版本要求大于2.8.12。执行`cmake`并安装依赖库。
CMake Error at CMakeModules/FindGLEW.cmake:51 (MESSAGE): Could not find GLEW
sudo apt-get install libglew-dev
执行`build`,报错找不到头文件:
/home/yu/sources/Pangolin/src/image/image_io_zstd.cpp:8:20: fatal error: zstd.h: No such file or directory
安装依赖库:
sudo apt-get install zstd libzstd-dev
还是报错,查询zstd版本为v1.3.1<v1.4.0。
zstd --version *** zstd command line interface 64-bits v1.3.1, by Yann Collet *** ```` 继续降级到v0.5,编译通过。安装到`/usr/local/`下。 ```bash sudo make installInstall the project... -- Install configuration: "Release" -- Installing: /usr/local/include/pangolin/config.h -- Up-to-date: /usr/local/include/pangolin -- Installing: /usr/local/include/pangolin/compat -- Installing: /usr/local/include/pangolin/compat/glutbitmap.h -- Installing: /usr/local/include/pangolin/compat/type_traits.h -- Installing: /usr/local/include/pangolin/compat/ovr.h -- Installing: /usr/local/include/pangolin/compat/glconsole.h -- Installing: /usr/local/include/pangolin/console -- Installing: /usr/local/include/pangolin/console/ConsoleInterpreter.h -- Installing: /usr/local/include/pangolin/console/ConsoleView.h -- Installing: /usr/local/include/pangolin/gl -- Installing: /usr/local/include/pangolin/gl/glplatform.h -- Installing: /usr/local/include/pangolin/gl/compat -- Installing: /usr/local/include/pangolin/gl/compat/gl2engine.h -- Installing: /usr/local/include/pangolin/gl/compat/gl_es_compat.h -- Installing: /usr/local/include/pangolin/gl/glfont.h -- Installing: /usr/local/include/pangolin/gl/glinclude.h -- Installing: /usr/local/include/pangolin/gl/gl.h -- Installing: /usr/local/include/pangolin/gl/glglut.h -- Installing: /usr/local/include/pangolin/gl/gldraw.h -- Installing: /usr/local/include/pangolin/gl/gl.hpp -- Installing: /usr/local/include/pangolin/gl/glformattraits.h -- Installing: /usr/local/include/pangolin/gl/glsl.h -- Installing: /usr/local/include/pangolin/gl/gltexturecache.h -- Installing: /usr/local/include/pangolin/gl/glpangoglu.h -- Installing: /usr/local/include/pangolin/gl/glvbo.h -- Installing: /usr/local/include/pangolin/gl/glchar.h -- Installing: /usr/local/include/pangolin/gl/gltext.h -- Installing: /usr/local/include/pangolin/gl/colour.h -- Installing: /usr/local/include/pangolin/gl/glpixformat.h -- Installing: /usr/local/include/pangolin/gl/glcuda.h -- Installing: /usr/local/include/pangolin/gl/cg.h -- Installing: /usr/local/include/pangolin/gl/glstate.h -- Installing: /usr/local/include/pangolin/handler -- Installing: /usr/local/include/pangolin/handler/handler_enums.h -- Installing: /usr/local/include/pangolin/handler/handler_image.h -- Installing: /usr/local/include/pangolin/handler/handler_glbuffer.h -- Installing: /usr/local/include/pangolin/handler/handler.h -- Installing: /usr/local/include/pangolin/video -- Installing: /usr/local/include/pangolin/video/iostream_operators.h -- Installing: /usr/local/include/pangolin/video/video.h -- Installing: /usr/local/include/pangolin/video/drivers -- Installing: /usr/local/include/pangolin/video/drivers/thread.h -- Installing: /usr/local/include/pangolin/video/drivers/depthsense.h -- Installing: /usr/local/include/pangolin/video/drivers/teli.h -- Installing: /usr/local/include/pangolin/video/drivers/pvn_video.h -- Installing: /usr/local/include/pangolin/video/drivers/uvc.h -- Installing: /usr/local/include/pangolin/video/drivers/join.h -- Installing: /usr/local/include/pangolin/video/drivers/v4l.h -- Installing: /usr/local/include/pangolin/video/drivers/debayer.h -- Installing: /usr/local/include/pangolin/video/drivers/openni.h -- Installing: /usr/local/include/pangolin/video/drivers/openni2.h -- Installing: /usr/local/include/pangolin/video/drivers/shared_memory.h -- Installing: /usr/local/include/pangolin/video/drivers/pango_video_output.h -- Installing: /usr/local/include/pangolin/video/drivers/firewire.h -- Installing: /usr/local/include/pangolin/video/drivers/firewire_deinterlace.h -- Installing: /usr/local/include/pangolin/video/drivers/ffmpeg.h -- Installing: /usr/local/include/pangolin/video/drivers/test.h -- Installing: /usr/local/include/pangolin/video/drivers/unpack.h -- Installing: /usr/local/include/pangolin/video/drivers/shift.h -- Installing: /usr/local/include/pangolin/video/drivers/pango_video.h -- Installing: /usr/local/include/pangolin/video/drivers/mirror.h -- Installing: /usr/local/include/pangolin/video/drivers/images.h -- Installing: /usr/local/include/pangolin/video/drivers/realsense.h -- Installing: /usr/local/include/pangolin/video/drivers/pleora.h -- Installing: /usr/local/include/pangolin/video/drivers/openni_common.h -- Installing: /usr/local/include/pangolin/video/drivers/video_splitter.h -- Installing: /usr/local/include/pangolin/video/video_output.h -- Installing: /usr/local/include/pangolin/video/video_record_repeat.h -- Installing: /usr/local/include/pangolin/pangolin.h -- Installing: /usr/local/include/pangolin/var -- Installing: /usr/local/include/pangolin/var/input_record_repeat.h -- Installing: /usr/local/include/pangolin/var/varvalue.h -- Installing: /usr/local/include/pangolin/var/var.h -- Installing: /usr/local/include/pangolin/var/varextra.h -- Installing: /usr/local/include/pangolin/var/varwrapper.h -- Installing: /usr/local/include/pangolin/var/varstate.h -- Installing: /usr/local/include/pangolin/var/varvaluegeneric.h -- Installing: /usr/local/include/pangolin/var/varvaluet.h -- Installing: /usr/local/include/pangolin/platform.h -- Installing: /usr/local/include/pangolin/image -- Installing: /usr/local/include/pangolin/image/image.h -- Installing: /usr/local/include/pangolin/image/image_utils.h -- Installing: /usr/local/include/pangolin/image/image_common.h -- Installing: /usr/local/include/pangolin/image/image_io.h -- Installing: /usr/local/include/pangolin/hud -- Installing: /usr/local/include/pangolin/hud/oculus_hud.h -- Installing: /usr/local/include/pangolin/display -- Installing: /usr/local/include/pangolin/display/device -- Installing: /usr/local/include/pangolin/display/device/display_android.h -- Installing: /usr/local/include/pangolin/display/device/display_glut.h -- Installing: /usr/local/include/pangolin/display/device/X11GlContext.h -- Installing: /usr/local/include/pangolin/display/device/OsxWindow.h -- Installing: /usr/local/include/pangolin/display/device/PangolinNSGLView.h -- Installing: /usr/local/include/pangolin/display/device/WinWindow.h -- Installing: /usr/local/include/pangolin/display/device/X11Window.h -- Installing: /usr/local/include/pangolin/display/device/PangolinNSApplication.h -- Installing: /usr/local/include/pangolin/display/attach.h -- Installing: /usr/local/include/pangolin/display/window.h -- Installing: /usr/local/include/pangolin/display/opengl_render_state.h -- Installing: /usr/local/include/pangolin/display/display_internal.h -- Installing: /usr/local/include/pangolin/display/viewport.h -- Installing: /usr/local/include/pangolin/display/display.h -- Installing: /usr/local/include/pangolin/display/user_app.h -- Installing: /usr/local/include/pangolin/display/widgets -- Installing: /usr/local/include/pangolin/display/widgets/widgets.h -- Installing: /usr/local/include/pangolin/display/view.h -- Installing: /usr/local/include/pangolin/ios -- Installing: /usr/local/include/pangolin/ios/PangolinAppDelegate.h -- Installing: /usr/local/include/pangolin/ios/PangolinUIView.h -- Installing: /usr/local/include/pangolin/log -- Installing: /usr/local/include/pangolin/log/packetstream.h -- Installing: /usr/local/include/pangolin/utils -- Installing: /usr/local/include/pangolin/utils/picojson.h -- Installing: /usr/local/include/pangolin/utils/sigstate.h -- Installing: /usr/local/include/pangolin/utils/fix_size_buffer_queue.h -- Installing: /usr/local/include/pangolin/utils/simple_math.h -- Installing: /usr/local/include/pangolin/utils/posix -- Installing: /usr/local/include/pangolin/utils/posix/condition_variable.h -- Installing: /usr/local/include/pangolin/utils/posix/semaphore.h -- Installing: /usr/local/include/pangolin/utils/posix/shared_memory_buffer.h -- Installing: /usr/local/include/pangolin/utils/type_convert.h -- Installing: /usr/local/include/pangolin/utils/file_extension.h -- Installing: /usr/local/include/pangolin/utils/xml -- Installing: /usr/local/include/pangolin/utils/xml/rapidxml.hpp -- Installing: /usr/local/include/pangolin/utils/xml/license.txt -- Installing: /usr/local/include/pangolin/utils/xml/rapidxml_print.hpp -- Installing: /usr/local/include/pangolin/utils/xml/rapidxml_utils.hpp -- Installing: /usr/local/include/pangolin/utils/xml/rapidxml_iterators.hpp -- Installing: /usr/local/include/pangolin/utils/threadedfilebuf.h -- Installing: /usr/local/include/pangolin/utils/timer.h -- Installing: /usr/local/include/pangolin/utils/file_utils.h -- Installing: /usr/local/include/pangolin/utils/params.h -- Installing: /usr/local/include/pangolin/utils/uri.h -- Installing: /usr/local/include/pangolin/python -- Installing: /usr/local/include/pangolin/python/PyUniqueObj.h -- Installing: /usr/local/include/pangolin/python/PyInterpreter.h -- Installing: /usr/local/include/pangolin/python/PyModulePangolin.h -- Installing: /usr/local/include/pangolin/python/PyVar.h -- Installing: /usr/local/include/pangolin/python/PyPangoIO.h -- Installing: /usr/local/include/pangolin/plot -- Installing: /usr/local/include/pangolin/plot/datalog.h -- Installing: /usr/local/include/pangolin/plot/plotter.h -- Installing: /usr/local/include/pangolin/plot/range.h -- Installing: /usr/local/lib/libpangolin.so -- Installing: /usr/local/lib/cmake/Pangolin/PangolinConfig.cmake -- Installing: /usr/local/lib/cmake/Pangolin/PangolinConfigVersion.cmake -- Installing: /usr/local/lib/cmake/Pangolin/PangolinTargets.cmake -- Installing: /usr/local/lib/cmake/Pangolin/PangolinTargets-release.cmake -
安装DBow2(跳过)
在ORB_SLAM2的`Thirdparty/DBoW2/`,编译ORB_SLAM2时一起编译。
-
安装g2o(跳过)
在ORB_SLAM2的`Thirdparty/g2o/`,编译ORB_SLAM2时一起编译。
-
编译ORB_SLAM2
cd ORB_SLAM2 chmod +x build.sh ./build.sh -
运行ORB_SLAM2
运行单目数据集TUM1:
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /home/yu/datas/rgbd_dataset_freiburg1_xyz
正常输出所有数据:
ORB_SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Monocular Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Camera Parameters: - fx: 517.306 - fy: 516.469 - cx: 318.643 - cy: 255.314 - k1: 0.262383 - k2: -0.953104 - k3: 1.16331 - p1: -0.005358 - p2: 0.002628 - fps: 30 - color order: RGB (ignored if grayscale) ORB Extractor Parameters: - Number of Features: 1000 - Scale Levels: 8 - Scale Factor: 1.2 - Initial Fast Threshold: 20 - Minimum Fast Threshold: 7 ------- Start processing sequence ... Images in the sequence: 798 Framebuffer with requested attributes not available. Using available framebuffer. You may see visual artifacts.New Map created with 90 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 80 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 75 points Wrong initialization, reseting... System Reseting Reseting Local Mapper... done Reseting Loop Closing... done Reseting Database... done New Map created with 102 points ------- median tracking time: 0.0214125 mean tracking time: 0.0241273 Saving keyframe trajectory to KeyFrameTrajectory.txt ... trajectory saved! QObject::~QObject: Timers cannot be stopped from another thread Segmentation fault (core dumped)
-
运行ORB_SLAM2(ROS)
添加路径:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/yu/sources/ORB_SLAM2/Examples/ROS
编译ROS节点:
chmod +x build_ros.sh ./build_ros.sh
报错未定义的boost:
/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/RGBD.dir/build.make:217: recipe for target '../RGBD' failed make[2]: *** [../RGBD] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/Stereo.dir/build.make:217: recipe for target '../Stereo' failed make[2]: *** [../Stereo] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2
安装boost库,重新编译,仍然报错:
sudo apt-get install libboost-dev libboost-filesystem-dev libboost-thread-dev libboost-system-dev
在`Examples/ROS/ORB_SLAM2/CMakeLists.txt`中添加查找boost和显示添加boost库,重新编译通过:
# 查找boost库 find_package(Boost REQUIRED COMPONENTS system filesystem thread) message(STATUS "Boost found: ${Boost_FOUND}") message(STATUS "Boost libraries: ${Boost_LIBRARIES}") message(STATUS "Boost system lib: ${Boost_SYSTEM_LIBRARY}") # 显示添加boost库 set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so ${Boost_LIBRARIES} )
运行双目数据集,每个终端都要配置环境变量:
# 终端1 roscore# 终端2 export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS rosrun ORB_SLAM2 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml true
# 终端3 export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS rosbag play --pause /home/yu/datas/V1_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw
正常输出所有数据:
ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions. See LICENSE.txt. Input sensor was set to: Stereo Loading ORB Vocabulary. This could take a while... Vocabulary loaded! Camera Parameters: - fx: 435.205 - fy: 435.205 - cx: 367.452 - cy: 252.201 - k1: 0 - k2: 0 - p1: 0 - p2: 0 - fps: 20 - color order: RGB (ignored if grayscale) ORB Extractor Parameters: - Number of Features: 1200 - Scale Levels: 8 - Scale Factor: 1.2 - Initial Fast Threshold: 20 - Minimum Fast Threshold: 7 Depth Threshold (Close/Far Points): 3.85272 Framebuffer with requested attributes not available. Using available framebuffer. You may see visual artifacts.New map created with 542 points
[RUNNING] Bag Time: 1403715418.863405 Duration: 147.146585 / 147.166583 [RUNNING] Bag Time: 1403715418.868392 Duration: 147.151572 / 147.166583 [RUNNING] Bag Time: 1403715418.873453 Duration: 147.156633 / 147.166583 Done.