ORB-SLAM3论文地址:https://arxiv.org/abs/2007.11898
代码地址:https://github.com/UZ-SLAMLab/ORB_SLAM3
根据ORB-SLAM3源代码安装以下库:
1、Pangolin
附上github网址:https://github.com/stevenlovegrove/Pangolin
根据github里面安装即可:
#安装依赖
sudo apt install libglew-dev
sudo apt install cmake
sudo apt install libpython2.7-dev
#可选依赖见github,我没装所以就不贴出来啦
#下载并编译
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .
#最后不要忘了安装
sudo make install
2、opencv3.2.0
下载官网opencv3.2.0安装包
#安装依赖
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
#再加上以下依赖,后面出错了,所以先加上
sudo apt-get install libgtk-3-dev
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
#进入文件夹编译安装
mkdir build
cd build
cmake -D ENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make -j8
sudo make install
环境配置
sudo gedit /etc/ld.so.conf.d/opencv.conf #添加库路径
#里面应该是
/usr/local/lib #没有则加上
sudo gedit ~/.profile #添加环境变量
#末尾加上
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
2.1 出现错误及解决办法
(1)无法定位软件包 libjasper-dev
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
(2)出现错误
– Checking for module ‘gtk±3.0’
– No package ‘gtk±3.0’ found
#安装依赖
sudo apt-get install libgtk-3-dev
(3)出现错误
– No package ‘gstreamer-base-1.0’ found
#安装依赖
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
(4)出现错误
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录
#include_next
#在cmake语句里加上
-D ENABLE_PRECOMPILED_HEADERS=OFF
3、ROS
根据ROS官网安装对应版本的ROS,本机安装的是ROS Melodic
#加链接和钥匙
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
#安装完整版,其他的见官网
sudo apt install ros-melodic-desktop-full
#环境配置
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep
sudo rosdep init
rosdep update
安装成功后,创建并初始化工作目录
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws/ #直接$ cd .. 也一样
catkin_make
#catkin的构建系统的相关文件保存在build目录中,构建后的可执行文件保存在devel目录中
#加载与catkin构建系统相关的环境文件
$ source ~/catkin_ws/devel/setup.bash
4、Eigen3
5、python2.7
6、DBoW2 and g2o(ORB-SLAM3文件中自带)
1、运行demo
依旧是根据github来
下载并编译ORB-SLAM3,将文件放入ROS工作空间的src文件夹中
#注意在ROS工作空间的src文件夹中下载,或者是下载完成后移入工作空间
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3
#编译
cd ORB_SLAM3
chmod +x build.sh
./build.sh
下载数据集,官网下载慢可用迅雷下载
ps.不使用ROS运行的下载ASL格式的,使用ROS运行的下载ROS bag
修改ORB-SLAM3/euroc_examples.sh文件中的数据集地址
#!/bin/bash
#pathDatasetEuroc='/Datasets/EuRoC' #Example, it is necesary to change it by the dataset path
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
结果图
2、用Realsense D415相机运行
Ubuntu18.04安装RealsenseD415方法见另一篇博客。
编译ROS版
#添加环境变量
gedit ~/.bashrc
#加入以下内容,PATH改为自己的地址
#export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples/ROS
export ROS_PACKAGE_PATH=${
ROS_PACKAGE_PATH}:/home/yu/catkin_ws/src/ORB_SLAM3/Examples/ROS
#再加个这个吧
source ~/catkin_ws/devel/setup.bash
#编译
chmod +x build_ros.sh
./build_ros.sh
修改相应节点
> 打开 ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/ros_rgbd.cc 文件
> 修改节点(绿色字体)
message_filters::Subscriber rgb_sub(nh, "/camera/color/image_raw", 100);
message_filters::Subscriber depth_sub(nh, "camera/depth/image_rect_raw", 100);
相机标定后,修改ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml文件
#打开ROS
roscore
#打开相机
roslaunch realsense2_camera rs_rgbd.launch
#运行节点,注意修改命令中的地址
#使用还需要修改yaml文件,即修改相机的参数
rosrun ORB_SLAM3 RGBD /home/yu/catkin_ws/src/ORB_SLAM3/Vocabulary/ORBvoc.txt /home/yu/catkin_ws/src/ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml