小觅摄像头标准版运行 VIORB-SLAM

小觅相机标准版SDK:https://github.com/slightech/MYNT-EYE-S-SDK

小觅VIORB项目:https://github.com/slightech/MYNT-EYE-VIORB-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

1
2
3
4
5
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 Kinetic

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

1.2.1 配置 Ubuntu 软件仓库

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

1.2.2 添加 sources.list

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

1
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'

或清华源

1
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

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

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

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

1.2.4 安装

1
sudo apt-get update

安装桌面完整版

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

1.2.5 初始化rosdep

1
2
sudo rosdep init
rosdep update

1.2.6 环境配置

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

1.2.7 构建工厂依赖

1
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

1
2
3
4
5
6
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

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    
    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. 添加路径

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

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

2.安装依赖项

2.1 安装Pangolin

准备依赖

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

下载Pangolin并配置环境

1
2
3
4
5
6
7
git clone https://github.com/stevenlovegrove/Pangolin Pangolin
cd Pangolin
mkdir build
cd build
cmake ..
make -j2
sudo make install

2.2 安装Eigen3

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

可以从官网下载源码。

1
2
3
4
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

编译安装

1
2
3
4
5
6
cd eigen-3.2.10
mkdir build
cd build
cmake ..
make
sudo make install

2.3 安装OpenCV 3.2.0

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

  1. 安装依赖(前两个必装,optional可选)
1
2
3
[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. 下载(也可以从官网下载安装)
1
2
3
4
5
6
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. 配置并编译安装
1
2
3
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
  1. 在/etc/ld.so.conf.d/opencv.conf中添加路径
1
sudo vim /etc/ld.so.conf.d/opencv.conf

​ 在其中添加

1
/usr/local/lib

​ 使之生效

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

​ 在其中添加

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

​ 使之生效

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

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

2.4 安装libg2o

还需安装ros-kinetic-libg2o,不然编译可能会报错。

1
sudo apt-get install ros-kinetic-libg2o

3. 编译安装VIORB

这里依然使用前面配置好的工作空间 ~/catkin_ws/

  1. 下载源码

    1
    2
    3
    
    cd ~/catkin_ws/src
    git clone -b mynteye https://github.com/slightech/MYNT-EYE-VIORB-Sample.git
    cd MYNT-EYE-VIORB-Sample
  2. 配置环境变量

    1
    2
    3
    4
    
    sudo vim ~/.bashrc
    #在最后添加 export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/Examples/ROS/ORB_VIO
    #PATH替换为路径,这里添加为:
    export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}: ~/catkin_ws/src/MYNT-EYE-VIORB-Sample/Examples/ROS/ORB_VIO
  3. 安装

    1
    2
    
    cd MYNT-EYE-VIORB-Sample
    ./build.sh

4.调整参数并运行

4.1 调整相机参数

  1. 使用左目摄像头和 IMU ,通过 MYNT-EYE-S-SDK ,获得当前工作设备的图像校准参数:

    1
    2
    
    cd MYNT-EYE-S-SDK
    ./samples/_output/bin/tutorials/get_img_params
  2. 这时,可以获得针孔模型下的 distortion_parameters 和 projection_parameters 参数,然后在 <MYNT-EYE-VIORB-Sample>/config/mynteye_s.yaml 中更新。

4.2 运行VIORB

  1. 运行mynteye

    1
    
    roslaunch mynt_eye_ros_wrapper mynteye.launch
  2. 运行viorb

    1
    
    roslaunch ORB_VIO testmynteye_s.launch

5.后记

前面利用笔记本摄像头跑通了ORB SLAM2,也用小觅摄像头跑通了VINS MONO和VINS FUSION,但是在跑VIO SLAM的时候遇到了许多问题。

首先是安装了一个新的系统,配置了ROS和OoenCV,接下来安装SDK编译SDK的ROS节点的时候死活无法编译,报错:

1
2
3
4
Make ros
/bin/bash: catkin_make: 未找到命令
Makefile:200: recipe for target 'ros' failed
make: *** [ros] Error 127

给小觅工程师提交了ticket也没有找到原因,我便又重新装了一次系统,这次只安装了ROS之后就去安装SDK,另外安装SDK的时候,没有采用官方文档的 make install(我执行这条的时候会报权限错误),而是:

1
2
3
4
make
make install #权限有问题就sudo make install
make samples
make ros

顺利安装,接下来再继续安装其他的依赖,顺便跑了一次ORB SLAM2发现也没有问题,便开始安装VIORB。

在安装VIORB的时候遇到了一个问题

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Configuring and building ORB_SLAM2 ...

-- Could NOT find CHOLMOD (missing:  CHOLMOD_INCLUDE_DIR CHOLMOD_LIBRARIES) 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CHOLMOD_INCLUDE_DIR
   used as include directory in directory /home/neko/catkin_ws/src/MYNT-EYE-VIORB-Sample
   used as include directory in directory /home/neko/catkin_ws/src/MYNT-EYE-VIORB-Sample
   used as include directory in directory /home/neko/catkin_ws/src/MYNT-EYE-VIORB-Sample
CHOLMOD_LIBRARY
    linked by target "ORB_SLAM2" in directory /home/neko/catkin_ws/src/MYNT-EYE-VIORB-Sample
-- Configuring incomplete, errors occurred!
See also "/home/neko/catkin_ws/src/MYNT-EYE-VIORB-Sample/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。

以及

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
make[2]: *** No rule to make target '../../../../lib/libORB_SLAM2.so', needed by '../MYNT_VIO'。 停止。
make[2]: *** 正在等待未完成的任务....
make[2]: *** No rule to make target '../../../../lib/libORB_SLAM2.so', needed by '../VIO'。 停止。
make[2]: *** 正在等待未完成的任务....
[ 16%] Building CXX object CMakeFiles/VIO.dir/src/ros_vio.cc.o
[ 33%] Building CXX object CMakeFiles/MYNT_VIO.dir/src/MsgSync/MsgSynchronizer.cpp.o
[ 50%] Building CXX object CMakeFiles/MYNT_VIO.dir/src/mynt_vio.cc.o
[ 66%] Building CXX object CMakeFiles/VIO.dir/src/MsgSync/MsgSynchronizer.cpp.o
CMakeFiles/Makefile2:259: recipe for target 'CMakeFiles/VIO.dir/all' failed
make[1]: *** [CMakeFiles/VIO.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....
CMakeFiles/Makefile2:746: recipe for target 'CMakeFiles/MYNT_VIO.dir/all' failed
make[1]: *** [CMakeFiles/MYNT_VIO.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Launch file in Examples/ROS/ORB_VIO/launch.
Modify the configuration file config/euroc.yaml
Run as: roslaunch ORB_VIO testeuroc.launch

在Google以及百度搜索了许多解决方案,也没有解决问题,看错误提示是CHOLMODlibORB_SLAM2.so这个库文件的问题,根据找到的解决方案,首先安装了cholmod,但是没能解决问题。

1
sudo apt install libcholmod<tab> #输完libcholmod后按TAB自动补全版本

后面经过摸索,安装了g2o之后,上面两个问题竟然一起解决了,suprise!执行:

1
sudo apt-get install ros-kinetic-libg2o

如果还报错,试一下安装这个依赖:

1
sudo apt-get install libsuitesparse-dev

报错之后重新编译之前,删除以下文件夹:

1
2
3
4
5
6
PATH/build
PATH/Thirdparty/DBoW2/build
PATH/Thirdparty/g2o/build
PATH/Examples/ROS/ORB_VIO/build
PATH/Examples/ROS/ORB_VIO/launch
PATH/Examples/ROS/ORB_VIO/lib
0%