文章目录
一、cmake编译ORB-SLAM库报错
首先确保自己都按照ORB-SLAM里的readme的流程安装了相应的各种库,包括Boost、ROS、OpenCV等,然后把ORB-SLAM-master文件夹名字改成ORB-SLAM(别问我为啥知道,后边rosrun没跑起来的时候,检查代码才发现需要用相对路径,而代码里默认用的是ORB-SLAM文件夹下的那些文件),然后再继续后边的步骤。
1、问题:cmake 后出现rosdep错误
在ORB-SLAM库编译时,cmake … -DROS_BUILD_TYPE=Release后出现rosdep错误:
[rospack] error: the rosdep view is empty: call sudo rosdep init and rosdep update
解决方法:
1、终端输入rospack find rosdep
2、如果报错:
[rospack] Error: package 'rosdep' not found
则需要重新安装rosdep:
sudo apt install python-rosdep
然后进行一系列初始化,update的操作:
sudo rosdep init
rosdep update
3、如果成功就解决问题了,但是处于国内网络下,大概率会出问题
rosdep init / rosdep update问题
在这一步遇到没法连接raw.githubusercontent.com的问题
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.
大部分解决方法是修改etc/hosts
,把raw.githubusercontent.com和对应的IP地址输入进去,但是我这在服务器上还是不太好使,这个本质也是定位网站IP,使得update时能连上,属于碰运气型方案;于是查找原理,找到绝对解决方案:
原理:
(1) raw.githubusercontent.com实际上就是github的用户数据服务器
(2)rosdep程序下载的就是从github.com/ros/rosdistro这个repo里的yaml文件
(3)虽然raw.githubusercontent.com服务器无法访问,但是yaml文件可以直接从git clone的repo中获得
解决方案:
(1)首先,将rosdistro clone到本地
git clone https://github.com/ros/rosdistro.git
(2)打开文件
sudo vim rosdistro/rosdep/sources.list.d/20-default.list
将里面所有的 raw.githubusercontent.com替换成自己的地址
PS: YOUR_FOLDER_PATH 换成你自己的rosdistro文件夹的所在地址!!!
PPS:yaml file://表示固定格式/home…表示文件目录,所以是yaml file:///
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/base.yaml
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/python.yaml
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/YOUR_FOLDER_PATH/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
(3)打开文件
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
做同样的替换:
# location of an example gbpdistro file for reference and testing
FUERTE_GBPDISTRO_URL = 'file:///home/YOUR_FOLDER_PATH/rosdistro/' \
'releases/fuerte.yaml'
(4)打开文件
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
做同样的替换:
# location of targets file for processing gbpdistro files
REP3_TARGETS_URL = 'file:///home/YOUR_FOLDER_PATH/rosdistro/releases/targets.yaml'
(5)打开文件
sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
做同样的替换:
DEFAULT_INDEX_URL = 'file:///home/YOUR_FOLDER_PATH/rosdistro/index-v4.yaml'
(6)打开新终端,执行以下指令创建root并切换至root用户
sudo su
//输入你的密码切换至root
sudo mkdir -p /etc/ros/rosdep/sources.list.d
sudo vim /etc/ros/rosdep/sources.list.d/20-default.list
将以下内容复制进 20-default.list
# os-specific listings first
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/base.yaml
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/python.yaml
yaml file:///home/YOUR_FOLDER_PATH/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/YOUR_FOLDER_PATH/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
(7)呼!搞定啦!开新终端,rosdep update
一波,这回就通了!!
参考链接:https://blog.csdn.net/weixin_42584917/article/details/114448355
2、问题:cmake 后出现opencv2错误
搞定rosdep后,再编译ORB-SLAM库时,cmake … -DROS_BUILD_TYPE=Release后出现opencv2错误(好气还有错误):
[rospack] Error: package ‘ORB_SLAM-master’ depends on non-existent package ‘opencv2’ and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling ‘rosdep update’
解决方法:
(1)打开ORB-SLAM文件夹中的manifest.xml文件
vim manifest.xml
(2)注释掉depend package=“opencv2”
<!--depend package="opencv2"/-->
保存文件,就像这样:
(3) 删除原来ORB-SLAM文件夹路径下的build文件夹下的东西,然后再重新cmake,编译成功,舒服了!!!!
cmake … -DROS_BUILD_TYPE=Release
cmake编译ORB-SLAM成功后显示:
二、make编译ORB-SLAM库报错
1、问题:ORBextractor.cc出错,缺少头文件
cmake成功后刚爽了一会,结果make的时候就疯狂飘红色error,只得再对问题分析处理 /(ㄒoㄒ)/
这回是make的过程中,进行到编译ORBextractor.cc文件的时候出现缺失头文件的报错
解决方法:
(1)添加缺少的头文件,对ORB_SLAM/src/ORBextractor.cc
文件修改,在头文件处添加
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
2、问题:Eigen3库出现bug
解决了opencv2头文件问题,又来了个eigen库的报错,逐渐暴躁,我还有论文没看呢淦!
这回飘红是eigen3库的问题,static assertion failed的报错
解决方法:
(1)打开ORB-SLAM文件夹中的
Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h
(2)将文件中的typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix
替换为:
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;
(3)运行成功,舒服了,开测!
参考链接:https://blog.csdn.net/h2763246823/article/details/113856868
三、其他问题
上边是我遇到过的问题,but由于各类玄学因素,大家配置的环境总是可以出千奇百怪的错误,所以其他细节问题需要科学上网,百度csdn大法搜索了,或者看看ORB-SLAM的github issues里边有没有相同的问题
https://github.com/raulmur/ORB_SLAM/issues
四、ORB-SLAM 效果展示
1、新建1个终端,然后运行 roscore
2、解压ORB词汇文件Data/ORBvoc.txt.tar.gz
,同时相机标定和设置的参数放置/Data/Settings.yaml
中,然后(optional)新建第2个终端,运行 rosrun ORB_SLAM ORB_SLAM /Data/ORBvoc.txt /Data/Settings.yaml
3、ORB-SLAM节点是是订阅/camera/image_raw
这个topic,(optional)新建第3个终端,由于ORB-SLAM节点处理的图像帧会通过/ORB_SLAM/Frame
这个话题发布出来,所以可以用image_view功能包来可视化最新处理的帧画面
rosrun image_view image_view image:=/ORB_SLAM/Frame _autosize:=true
4、(optional)新建第4个终端,ORB-SLAM节点处理后的地图会通过/ORB_SLAM/Map
这个topic发布,相机当前位姿和地图全局坐标原点通过/tf
功能包分别发布到话题/ORB_SLAM/Camera
和/ORB_SLAM/Camera
中,可以运行rviz
可视化地图
rosrun rviz rviz -d Data/rviz.rviz
5、2-4的步骤可以直接在ORB_SLAM文件夹路径下通过roslaunch
来实现,从一条指令中启动ORB_SLAM、image_view和rviz:
roslaunch ExampleGroovyOrNewer.launch
6、运行给的bag文件包示例 Example ,rosbga play
后按空格键开始运行,运行结果如图所示:
rosbag play --pause Example.bag
(1)跟踪ORB特征点效果
(2)建图与定位效果:1次检测闭环+2次重定位
7、查看ORB-SLAM节点的topic
rostopic list -v
8、测试在KITTI数据集上的效果
(1)按照KITTI相机参数,修改/Data/Settings.yaml
(2)跟踪ORB特征点效果、建图与定位效果
还得把KITTI数据集用https://github.com/raulmur/BagFromImages转成bag包,没时间不测了,以后有空再测,不过大概率是用ORB-SLAM2、3来玩了😀
参考链接:https://github.com/raulmur/ORB_SLAM
https://www.cnblogs.com/li-yao7758258/p/5912663.html