-
源码地址
https://github.com/raulmur/ORB_SLAM2.git
-
启动指令
第一个终端启动AstraPro Camera:
roslaunch astra_camera astrapro.launch
第二个终端启动ROS_SLAM:
rosrun ORB_SLAM2 RGBD xr_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt xr_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/AstraPro.yaml
1.第一个参数指定相机类型:RGBD。根据实际需求另有Mono,MonoAR,Stereo,RGBD可选。
2.PATH_TO_VOCABULARY,指定ORBvoc.txt路径。
3.PATH_TO_SETTINGS_FILE,相机参数与ORB参数文件路径。
下面给出文中使用的配置文件,仅供参考。
%YAML:1.0 #-------------------------------------------------------------------------------------------- # Camera Parameters. Adjust them! #-------------------------------------------------------------------------------------------- # Camera calibration and distortion parameters (OpenCV) Camera.fx: 564.2 Camera.fy: 563.7 Camera.cx: 328.6 Camera.cy: 236.4
Camera.k1: 0.138 Camera.k2: -0.185 Camera.p1: -0.0004 Camera.p2: 0.007 Camera.width: 640 Camera.height: 480 # Camera frames per second Camera.fps: 30.0 # IR projector baseline times fx (aprox.) Camera.bf: 40.0 # Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale) Camera.RGB: 1 # Close/Far threshold. Baseline times. ThDepth: 40.0 # Deptmap values factor DepthMapFactor: 1.0 #-------------------------------------------------------------------------------------------- # ORB Parameters #-------------------------------------------------------------------------------------------- # ORB Extractor: Number of features per image ORBextractor.nFeatures: 1000 # ORB Extractor: Scale factor between levels in the scale pyramid ORBextractor.scaleFactor: 1.2 # ORB Extractor: Number of levels in the scale pyramid ORBextractor.nLevels: 8 # ORB Extractor: Fast threshold # Image is divided in a grid. At each cell FAST are extracted imposing a minimum response. # Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST # You can lower these values if your images have low contrast ORBextractor.iniThFAST: 20 ORBextractor.minThFAST: 7 #-------------------------------------------------------------------------------------------- # Viewer Parameters #-------------------------------------------------------------------------------------------- Viewer.KeyFrameSize: 0.05 Viewer.KeyFrameLineWidth: 1 Viewer.GraphLineWidth: 0.9 Viewer.PointSize:2 Viewer.CameraSize: 0.08 Viewer.CameraLineWidth: 3 Viewer.ViewpointX: 0 Viewer.ViewpointY: -0.7 Viewer.ViewpointZ: -1.8 Viewer.ViewpointF: 500
-
运行结果
(1) 特征点提取结果。
(2)点云图、相机位姿、追踪结果显示。
-
问题记录
执行build_ros.sh 出现 'undefined reference to symbol '_ZN5boost6system15system_categoryEv' 错误,具体如下:
CMakeFiles/Makefile2:163: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [100%] Linking CXX executable ../RGBD /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:223: recipe for target '../RGBD' failed make[2]: *** [../RGBD] Error 1 CMakeFiles/Makefile2:754: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2
解决方法:切换目录至 Examples/ROS/ORB_SLAM2,编辑CMakeLists.txt,添加-lboost_system一项,如下所示。
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 -lboost_system )
再次编译,错误消失。
-
参考文献
Mur-Artal R , Tardos J D . ORB-SLAM2: an Open-Source SLAM System for Monocular, Stereo and RGB-D Cameras[J]. IEEE Transactions on Robotics, 2017, 33(5):1255-1262.