从github上寻找了几个例子,前两个遇到问题,第三个成功了,
github:https://github.com/BoomFan/ORB_SLAM2
对应博客:https://blog.csdn.net/qq_34254510/article/details/79969046#commentsedit
1.编译
2.保存地图
3.载入地图
载入地图遇到错误:
andy@asus:~/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build$ rosrun ORB_SLAM2 Mono /home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/Monocular/TUM1.yaml
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...
loadFromTextFile......
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
Do you want to save images from the viewer?(y/n)
n
Do you want to run pure localization?(y/n)
n
The current dir is : /home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build
Your setting file path is : /home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build//home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/Monocular/TUM1.yaml
Your map file path would be : /home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/MapPointandKeyFrame.bin
Do you want to load the map?(y/n)
yLoading System Parameters form:/home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build//home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/Monocular/TUM1.yaml
- size:0x0
- fx:0
- fy: 0
- cx: 0
- cy: 0
- k1: 0
- k2: 0
- p1: 0
- p2: 0
- bf: 0ORB Extractor Parameters:
- Number of Features: 0
- Scale Levels: 0
- Scale Factor: 0
- Initial Fast Threshold: 0
- Minimum Fast Threshold: 0
Map.cc :: Map reading from:/home/andy/ORB_SLAM2_with_SM/e3/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/MapPointandKeyFrame.bin
Map.cc :: The number of MapPoints:6764
Map.cc :: The number of KeyFrames:152
Segmentation fault (core dumped)
解决方法:
错误原因是输入参数是已经给的是绝对路径不需要再加cwd,修改方法:
将System.cc152行:string strPathSystemSetting = cwd + "/" + strSettingsFile.c_str();
修改为:string strPathSystemSetting = strSettingsFile.c_str();
对ORB_SLAM2/Examples/ROS/ORB_SLAM2/ros_mono.cc进行修改,成功实现在ROS下使用摄像头运行ORB_SLAM2,并可以保存和加载地图。
先写这么多,有空再更!2019年09月19日
如果你不想自己修改,可以下载我已经修改好的。
下载链接:https://download.csdn.net/download/m0_38031722/11784429
如果有理解的不对的地方还请大家指出。