MYNT-ORB-SLAM2 项目地址https://github.com/slightech/MYNT-EYE-ORB-SLAM2-Sample

1. 准备运行环境和依赖

1.1 系统环境

Ubuntu 16.04 LTS,最好是干净的系统。

可以到阿里巴巴开源镜像站或其他下载站下载系统镜像。
https://mirrors.aliyun.com/ubuntu-releases/16.04/ubuntu-16.04.6-desktop-amd64.iso

​ 安装git、cmake、vim、wget

sudo apt-get update
sudo apt-get install git
sudo apt-get install cmake
sudo apt-get install vim
sudo apt-get install wget

1.2 ROS

安装说明:http://wiki.ros.org/cn/kinetic/Installation/Ubuntu

1.2.1 配置 Ubuntu 软件仓库

配置你的 Ubuntu 软件仓库(repositories) 以允许 "restricted"、"universe" 和 "multiverse"这三种安装模式。 你可以按照ubuntu中的配置指南来完成配置。

1.2.2 添加 sources.list

官方源速度有些慢,添加中科大源

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 sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

1.2.3 添加key

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

添加公钥(官方文档没有这一步,但是不添加公钥会报不信任错误

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

1.2.4 安装

sudo apt-get update

安装桌面完整版

sudo apt-get install ros-kinetic-desktop-full

1.2.5 初始化rosdep

sudo rosdep init
rosdep update

1.2.6 环境配置

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

1.2.7 构建工厂依赖

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

1.2.8 配置ROS环境,创建工作空间

参考:http://wiki.ros.org/cn/ROS/Tutorials/InstallingandConfiguringROSEnvironment

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
source devel/setup.bash
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

1.3 小觅相机SDK

本部分参考官方文档SDK安装部分,安装到目录~/MYNT/SDK下(路径根据需要可自行修改)

https://mynt-eye-s-sdk.readthedocs.io/zh_CN/latest/src/sdk/install_ubuntu_src.html

  1. 下载并编译安装SDK

    mkdir ~/MYNT
    cd ~/MYNT
    git clone https://github.com/slightech/MYNT-EYE-S-SDK.git SDK
    cd SDK
    make init
    make
    make install
    
    make samples
    make tools
    make ros
    # make all
  2. 添加路径

    echo "source ~/MYNT/SDK/wrappers/ros/devel/setup.bash" >> ~/.bashrc
    source ~/.bashrc
  3. 测试相机

    1. 不使用ROS
     cd ~/MYNT/SDK                        #cd <sdk>
    ./samples/_output/bin/api/camera_a
    1. 使用ROS
    cd <sdk>
    source wrappers/ros/devel/setup.bash
    roslaunch mynt_eye_ros_wrapper mynteye.launch     #开摄像头,但默认不显示图像
    roslaunch mynt_eye_ros_wrapper display.launch    #也可以运行这个节点,会打开 RViz 显示图像
    1. 获取参数
    cd <sdk>
    ./samples/_output/bin/tutorials/get_img_params     #获取相机标定参数
    ./samples/_output/bin/tutorials/get_imu_params     #获取IMU标定参数

1.4 依赖项

1.4.1 安装Pangolin

准备依赖

sudo apt-get install libglew-dev libpython2.7-dev libboost-dev libboost-thread-dev libboost-filesystem-dev -y

下载Pangolin并配置环境

git clone https://github.com/stevenlovegrove/Pangolin Pangolin
cd Pangolin
mkdir build
cd build
cmake ..
make -j2
sudo make install

1.4.2 安装Eigen3

最低要求为3.1.0,这里安装Eigen 3.2.10。

可以从官网下载源码,也可以直接执行下面的命令下载。

cd ~/catkin_ws/src
wget https://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
tar -xjf 3.2.10.tar.bz2
mv eigen-eigen-b9cd8366d4e8/ eigen-3.2.10

编译安装

cd eigen-3.2.10
mkdir build
cd build
cmake ..
make
sudo make install

1.4.3 安装OpenCV 3.2.0

参考:https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html

  1. 安装依赖(前两个必装,optional可选)
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  1. 下载(也可以从官网下载安装)
cd ~
wget https://github.com/opencv/opencv/archive/3.2.0.zip
unzip 3.2.0.zip
cd opencv-3.2.0
mkdir build
cd build
  1. 配置并编译安装
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
  1. 在/etc/ld.so.conf.d/opencv.conf中添加路径
sudo vim /etc/ld.so.conf.d/opencv.conf

​ 在其中添加

/usr/local/lib

​ 使之生效

sudo ldconfig
  1. 在bash.bashrc中添加路径
sudo vim /etc/bash.bashrc

​ 在其中添加

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH

​ 使之生效

source /etc/bash.bashrc
  1. 测试opencv
cd ~/opencv-3.2.0/samples/cpp/example_cmake
mkdir muild
cd build
cmake ..
make
./opencv_example

​ 此时应当打开摄像头,并在左上角显示 Hello OpenCV

1.4.4 安装glog

git clone https://github.com/google/glog
sudo apt-get install autoconf automake libtool
cd glog
./autogen.sh
./configure
make -j 24
sudo make install

不安装glog编译MYNT-ORBSLAM会报错。

No preference for use of exported glog CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported glog CMake configuration if available.
-- Failed to find installed glog CMake configuration, searching for glog build directories exported with CMake.
-- Failed to find an installed/exported CMake configuration for glog, will perform search for installed glog components.
CMake Error at cmake_modules/FindGlog.cmake:103 (message):
  Failed to find glog - Could not find glog include directory, set
  GLOG_INCLUDE_DIR to directory containing glog/logging.h
Call Stack (most recent call first):
  cmake_modules/FindGlog.cmake:268 (glog_report_not_found)
  CMakeLists.txt:32 (find_package)

2. 编译安装

  1. 下载源码

    cd ~/catkin_ws/src
    git clone https://github.com/slightech/MYNT-EYE-ORB-SLAM2-Sample.git MYNT-ORB
    #下载到~/catkin_ws/src/MYNT-ORB文件夹
  2. 配置路径

    # 打开~/.bashrc
    sudo vim ~/.bashrc
    # 在最后添加:
    export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/catkin_ws/src/MYNT-ORB/Examples/ROS

如果添加之后编译ros的时候还是报错,如果有多个 ROS_PACKAGE_PATH 尝试更改一下位置,我将其从最后一个提到前面就不报错了(神奇=_=)。

  1. 编译安装

    cd ~/catkin_ws/src/MYNT-ORB
    chmod +x build.sh
    ./build.sh
    chmod +x build_ros.sh
    ./build_ros.sh

3.运行

  1. 启动小觅相机节点

    cd <path of mynteye-s-sdk>        #进入小觅SDK目录
    source ./wrappers/ros/devel/setup.bash
    # 如果安装SDK的时候配置过路径,直接运行下面一行命令即可。
    roslaunch mynt_eye_ros_wrapper mynteye.launch
  2. 打开新的终端,运行ORB-SLAM

    cd ~/catkin_ws/src/MYNT-ORB
    rosrun ORB_SLAM2 mynteye_s_stereo ./Vocabulary/ORBvoc.txt ./config/mynteye_s_stereo.yaml true /mynteye/left/image_raw /mynteye/right/image_raw

cd ~/catkin_ws/src/MYNT-ORB
rosrun ORB_SLAM2 mynteye_s_stereo ./Vocabulary/ORBvoc.txt ./config/mynteye_s_stereo.yaml false /mynteye/left_rect/image_rect /mynteye/right_rect/image_rect

参考资料:

https://blog.csdn.net/weixin_42681311/article/details/86751720

Last modification:March 11th, 2020 at 06:11 pm