ORB-SLAM3论文地址:https://arxiv.org/abs/2007.11898
代码地址:https://github.com/UZ-SLAMLab/ORB_SLAM3
本机系统:Ubuntu 18.04 LTS
前期环境:GCC 7.5、G++ 7.5、Cmake 3.10.2
一、安装依赖
1.Pangolin 0.5 切记:版本 ≤ 0.5
附上github网址:https://github.com/stevenlovegrove/Pangolin
安装命令:
1 #安装依赖
2 sudo apt install libglew-dev
3 sudo apt install cmake
4 sudo apt install libpython2.7-dev
5 #可选依赖见github,我没装所以就不贴出来啦
6 #下载并编译
7 git clone https://github.com/stevenlovegrove/Pangolin.git
8 cd Pangolin
9 mkdir build
10 cd build
11 cmake ..
12 cmake --build .
13 #最后不要忘了安装
14 sudo make install
2.OpenCV 3.2.0
下载 官网(https://opencv.org/releases/)
opencv3.2.0安装包
安装命令:
1 #安装依赖
2 sudo apt-get install build-essential
3 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
4 sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
5 #再加上以下依赖,后面出错了,所以先加上
6 sudo apt-get install libgtk-3-dev
7 sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
8 #进入文件夹编译安装
9 mkdir build
10 cd build
11 cmake -D ENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
12 sudo make -j8
13 sudo make install
环境配置:
1. sudo gedit /etc/ld.so.conf.d/opencv.conf #添加库路径
2. #里面应该是
3. /usr/local/lib #没有则加上
4. sudo gedit ~/.profile #添加环境变量
5. #末尾加上
6. PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
7. export PKG_CONFIG_PATH
常见错误:
无法定位软件包libjasper-dev
1 sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
2 sudo apt update
3 sudo apt install libjasper1 libjasper-dev
3.ROS Melodic
根据ROS官网(http://wiki.ros.org/melodic/Installation/Ubuntu)
安装对应版本的ROS,本机安装的是ROS Melodic
安装命令:
1 #加链接和钥匙
2 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
3 sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
4 sudo apt update
5 #安装完整版,其他的见官网
6 sudo apt install ros-melodic-desktop-full
7 #环境配置
8 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
9 source ~/.bashrc
10 安装依赖
11 sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
12 sudo apt install python-rosdep
13 sudo rosdep init
14 rosdep update
常见错误:sudo rosdep inti、rosdep update
报错
主要原因是因为 www.rawgithubusercontent.com
这个网站被墙。
sudo rosdep inti
报错较好解决,以下提供rosdep update
报错解决方案:
1.打开包含资源下载函数的文件:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
2.添加代理:(download_rosdep_data
函数try内第一行添加下面代码)
url="https://ghproxy.com/"+url
3.修改/usr/lib/python2.7/dist-packages/rosdistro/__init__.py
文件中的DEFAULT_INDEX_URL
1. sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
2. DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
4.修改其余4个文件中的地址,在地址https://raw.githubusercontent.com/...
前添加https://ghproxy.com/
1. sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
2. //修改第36行的地址
3. sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 72行
4. //修改第72行
5. sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
6. //修改第39行
7. sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/manifest_provider/github.py
8. //修改第68行、119行
5.解决Hit第五个地址的报错
1. sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
2. //在第204行添加如下代码(即在该函数块下的第一行处)
3. gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
4. //注意,原网址中代理地址的双引号是中文,直接粘贴复制会报字符识别错误
rosdep update
,发现问题完美解决!安装成功后,创建并初始化工作目录
1. mkdir -p ~/catkin_ws/src
2. cd ~/catkin_ws/src
3. catkin_init_workspace
4. cd ~/catkin_ws/ #直接$ cd .. 也一样
5. catkin_make
6. #catkin的构建系统的相关文件保存在build目录中,构建后的可执行文件保存在devel目录中
7. #加载与catkin构建系统相关的环境文件
8. $ source ~/catkin_ws/devel/setup.bash
为了构建和管理开发者自己的ROS工作空间,还需安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
测试:
1. # 第一个终端运行如下命令
2. roscore
3. # 打开第二个终端,这时你会看见一只静止的小海龟
4. rosrun turtlesim turtlesim_node
5. # 如果希望小海龟能够移动,打开第三个终端
6. rosrun turtlesim turtle_teleop_key
4.Eigen 3
安装命令:
sudo apt-get install libeigen3-dev
常见错误:后续调用eigen报错fatal error: Eigen/Core: No such file or directory
因为eigen库默认安装在了/usr/include/eigen3/Eigen
路径下,需使用下面命令映射到/usr/include
路径下
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen
5.Boost 1.72
官网 http://www.boost.org/users/download/
下载源码
安装命令
1. #解压
2. tar -xvf boost_1_72_0.tar.bz2
3. #运行解压后生成的bootstrap.sh文件:
4. cd ./boost_1_72_0
5. ./bootstrap.sh
6. #然后使用b2工具进行安装:
7. sudo ./b2 install
安装完毕之后,头文件默认在/usr/local/include
目录中,.a与.so文件在/usr/local/lib
目录下。
6.ORB-SLAM3
将下载的ORB-SLAM3文件放入ROS工作空间的src文件夹中并编译
安装命令(非ROS版本):
1. #注意在ROS工作空间的src文件夹中下载,或者是下载完成后移入工作空间
2. git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
3. #编译
4. cd ORB_SLAM3
5. chmod +x build.sh
6. ./build.sh
常见错误:recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o‘ failed
解决方案:
添加以下代码到ORB_SLAM3-master/include/CameraModels/KannalaBrandt8.h
namespace cv
{
template<typename _Tp, int m, int n> static inline Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha)
{
return Matx<_Tp, m, n>(a, 1.f / alpha, Matx_ScaleOp());
}
}
安装命令(ROS版本):
1. #添加环境变量
2. gedit ~/.bashrc
3. #加入以下内容,PATH改为自己的地址
4. #export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples/ROS
5. export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/yu/catkin_ws/src/ORB_SLAM3/Examples/ROS
6. #再加个这个吧
7. source ~/catkin_ws/devel/setup.bash
8. #编译
9. chmod +x build_ros.sh
10. ./build_ros.sh
7.下载数据集运行demo
官网(https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets)
下载
不使用ROS运行的下载ASL格式的,使用ROS运行的下载ROS bag
非ROS版
修改ORB-SLAM3/euroc_examples.sh文件中的数据集地址
1. #!/bin/bash
2. #pathDatasetEuroc='/Datasets/EuRoC' #Example, it is necesary to change it by the dataset path
3. pathDatasetEuroc='/home/yu/Datasets' #Example, it is necesary to change it by the dataset path
另外,数据集文件名需要修改为euroc_examples.sh文件中对应的名称,例如MH_01_easy修改为MH01
接下来,运行demo
./euroc_examples.sh
ROS版
安装librealsense(使用Intel realsense D400系列相机)
1. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
2. sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
3. sudo apt-get install librealsense2-dkms
4. sudo apt-get install librealsense2-utils
5. sudo apt-get install librealsense2-dev
测试:
Realsense-viewer
相机驱动realsense-ros
sudo apt-get install ros-melodic-realsense2-camera
编译完成后,使用如下命令测试:
roslaunch realsense2_camera demo_pointcloud.launch
修改相应节点:
1. 打开 ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/ros_rgbd.cc 文件
2. 修改节点(绿色字体)
3. message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/color/image_raw", 1);
4. message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);
5. 回到ORB-SLAM3文件夹路径下运行以下命令
6. ./build_ros.sh
相机标定后,修改ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml
文件
1. cd ~/catkin_ws/src/ORB_SLAM
2. #分别开三个终端, 按顺序每个终端运行一句
3. roscore
4. roslaunch realsense2_camera rs_rgbd.launch
5. rosrun ORB_SLAM3 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/D455.yaml
参考:
https://blog.csdn.net/qq_36804414/article/details/109241264
https://blog.csdn.net/weixin_43311920/article/details/114796748?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.control
https://zhuanlan.zhihu.com/p/392082731
https://www.jianshu.com/p/4c621a34ba69
https://blog.csdn.net/qq_39247667/article/details/116707889?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control
https://blog.csdn.net/weixin_48464886/article/details/118970304
https://github.com/UZ-SLAMLab/ORB_SLAM3
https://www.cnblogs.com/dinghongkai/p/11308805.html
https://blog.csdn.net/ByYastal/article/details/111589721?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link