Advertisement

如何用orbslam2运行数据集以及让自己电脑相机运行单目slam

阅读量:

1、下载orbslam2

https://github.com/raulmur/ORB_SLAM2

2、下载数据集(tum和kitti的)

链接: https://pan.baidu.com/s/1cmPaJF84NNNPMXosds70Zg 提取码: fpje

3、按照orbslam2的readme配置环境

Prerequisites
The library has been tested successfully on Ubuntu 12.04, 14.04, and 16.04, though it should prove straightforward to compile on other platforms as well. A high-performance machine (for example, an i7-based system) is essential for ensuring real-time performance and delivering more reliable and precise results.

C++11 or C++0x Compiler

We use the new thread and chrono functionalities of C++11.

现在都支持c++11了

Pangolin

We utilize Pangolin to achieve visualization and user interface design. Download the installation instructions for Pangolin from the following link: https://github.com/stevenlovegrove/Pangolin.

pangolin安装方法

先安装依赖

use sudo apt-get obtain GleW - dev
use sudo apt-get obtain Boost - thread - dev Boost - filesystem - dev
use sudo apt-get obtain Python 2.7 - dev

https://github.com/stevenlovegrove/Pangolin下载解压,

mkdir build

cmake -DCPP11_NO_BOOSR=1 ..

make -j16(这里16看自己电脑线程多少而定)

sudo make install

OpenCV

We use OpenCV to manipulate images and features. Dowload and install instructions can be found at: http://opencv.org. Required at leat 2.4.3. Tested with OpenCV 2.4.11 and OpenCV 3.2.

opencv安装方法

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install cmake

使用apt-get工具安装build-essential、libgtk2.0-dev、libavcodec-dev等软件包。

https://opencv.org/releases/下载source版本解压

mkdir build

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

make -j16(这里16看自己电脑线程多少而定)

sudo make install

sudo gedit /etc/ld.so.conf.d/opencv.conf

末尾添加/usr/local/lib

sudo ldconfig

sudo gedit /etc/bash.bashrc

末尾添加两行

$pkg_config_path = /usr/local/lib/pkgconfig; set -eo pipefail PCP

source /etc/bash.bashrc

sudo updatedb

Eigen3

Required by g2o (see below). Download and install instructions can be found at: http://eigen.tuxfamily.org. Required at least 3.1.0.

Eigen3安装方法

http://eigen.tuxfamily.org下载解压

mkdir build

cmake ..

make -j16(这里16看自己电脑线程多少而定)

sudo make install

By utilizing adapted versions of the DBoW2 library, we execute place recognition tasks, and by employing adapted versions of the g2o library, we execute non-linear optimization tasks. Each adapted library (which is BSD-licensed) is located within the Thirdparty folder.

DBoW2 and g2o

这两个作者被放置到第三方库中,并无需安装软件即可使用。但需对某个位置进行调整以避免后续出现问题,并将g2o项目的cmakelists文件中的-march=native选项移除后保存。

ROS (optional)

我们提供了一些示例来处理单目、双目或多色深度(RGB-D)相机的实时数据。创建这些示例的过程是可选的。如果您希望使用ROS,则需要确保您正在使用Hydro版本或更高版本。

ROS安装方法

第一步安装软件

预防后续出现无法定位软件包的问题

复制代码
    sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

设置密钥

复制代码
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

更新软件

复制代码
    sudo apt update

W: GPG错误:访问地址http://mirrors.ustc.edu.cn/ros/ubuntu bionic InRelease时发现缺少公钥信息
E: 该软件包未提供数字签名
N: 建议暂时禁用此源以确保系统安全
N: 有关如何创建软件包和配置系统,请参阅 apt-secure(8)手册

复制代码
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

再更新软件

复制代码
    sudo apt update

安装ros melodic

复制代码
    sudo apt-get install ros-melodic-desktop-full

安装rosdep

复制代码
    sudo apt install python-rosdep

rosdep初始化

复制代码
 cd /etc

    
 sudo gedit hosts

在打开的文件末尾加入

151.101.84.133 raw.githubusercontent.com

保存退出,再进行rosdep初始化

复制代码
    sudo rosdep init

rosdep 更新

复制代码
    rosdep update

添加ros环境变量

复制代码
 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

    
 source ~/.bashrc

安装rosinstall

复制代码
    sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

4、使用自己电脑相机运行单目slam

创建ros工作空间

mkdir -p ~/test/src

cd ~/test

catkin_make

从主目录开始使用快捷键Ctrl+H打开bashrc配置文件,在终端输入source ~/test/devel/setup.bash并保存到指定位置。

source ~/.bashrc

安装usb_cam包

https://github.com/ros-drivers/usb_cam下载解压,放在src下面

cd ~/test

catkin_make

roslaunch usb_cam usb_cam-test.launch,测试后退出

编译报错及解决方案

将下载解压后的orbslam2放到src下面

修改~/test/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc

原 /camera/image_raw 改为/usb_cam/image_raw

移除ORM_SLAM2和g2o项目的cmakeLists文件中的-march=native编译指令(其中关于g2o项目的设置之前已经说明)

然后编译

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/test/src/ORB_SLAM2/Examples/ROS

./build_ros.sh

遇到错误 ORB_SLAM2/src/System.cc: 提示信息:'usleap' 未声明在此范围内 usleep(5000)

解决方案:

找到对应的System.cc文件的首部加入 头文件

#include<unistd.h>

基于当前情况,请指示哪些文件存在usleep问题后立即添加该包含头文件。此外还需要包含以下路径和文件:Examples/Monocular/mono_euroc.cc、Examples/Monocular/mono_kitti.cc、Examples/Monocular/mono_tum.cc、Examples/RGB-D/rgbd_tum.cc、Examples/Stereo/stereo_euroc.cc、Examples/Stereo/stereo_kitti.cc、src/LocalMapping.cc、src/LoopClosing.cc、src/System.cc、src/Tracking.cc以及src/Viewer cc。

  1. 遇到这个问题CMakeFiles/RGBD.dir/build.make:197: 这个目标的构建计划出现了问题

解决方案:

对指定目录下OROBLAS/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeLists.txt文件进行编辑,在set命令的参数列表中添加 -lboost_system

3、出现这个错误No module named 'rospkg'

解决方案:

将Python版本更改为3;如果使用的是Python 2,则需将版本号更改为2;若采用Anaconda 3环境,则应默认选择Python 3;无需在前两行进行额外设置

alias python=python3

source ~/.bashrc

pip3 install rospkg

4、出现这个错误

When the requested attributes for the framebuffer are unavailable, the system will utilize the default framebuffer. This might result in visual artifacts. OpenGL support is confirmed to be functional. A new map containing 118 points has been successfully created, and a core dump has been captured during the process.

解决方案:

请移除ORM_SLAM2及其相关项目的cmakelists文件中的-march=native编译选项,并注意g2o项目的cmakelists文件中的同样设置(因为之前已经提及过)

编译成功后

roslaunch usb_cam usb_cam-test.launch

运行ROS节点ORB-SLAM2视觉SLAM系统并结合单目摄像头进行定位,并根据给定的词典路径配置特征描述词典,并在示例目录中选择相应的配置文件配置参数,并根据指定的ASUS摄像头配置参数进行初始化

结果如下:

5、使用数据集运行单目slam

有TUM、KITTI、EuRoC三种数据集

TUM提供的数据集可通过以下链接下载并解压:http://vision.in.tum.de/data/datasets/rgbd-dataset/download

TUM以及KITTI的数据集,请访问地址:https://pan.baidu.com/s/1cmPaJF84NNNPMXosds70Zg 获取密码:fpje

TUM1.yaml、TUM2.yaml 、TUM3.yaml 分别对应 freiburg1、freiburg2 、 freiburg3

readme里面很详细,这里运行一个tum数据集的单目slam

./Examples/Monocular/Single Camera/ORBOccupancyVocabulary/ Examples/Monocular/TUM-1 YAML Configuration File /home/zhw/下载ubuntu文件/RGBD/RGBD Dataset Freiburg XYZ Format

全部评论 (0)

还没有任何评论哟~