双目小觅相机-S,在ROS上跑通ORB-SLAM2

        在没有动手操作小觅相机之前,看教程觉得很简单,但是实际操作相机时,发现出现各种错误,真是让人难受,好不容易调通了,记录一下整个过程。

  1.  安装小觅相机的SDK-S

       SDK的下载地址:MYNT-EYE-S-SDK,要注意自己的相机是S还是D的,我的是S的。

       接着是创建ROS的工作空间,我创建的空间思路是让所有的ROS工程都在一个ROS_WORKSPACE下,然后再在这个目录下进行不同ROS工程的创建,比如这次中有两个ROS工程,一个是ORB-SLAM2、一个是MYNT-EYE-S-SDK,目录树如下:

双目小觅相机-S,在ROS上跑通ORB-SLAM2_第1张图片

 

mynt_eye_sdk工作空间的创建及SDK的安装:

mkdir -p ~/ROS_WORKSPACE/mynt_eye_sdk/src
cd ROS_WORKSPACE/mynt_eye_sdk/src
#我的git clone很慢,也可以直接在网站下压缩包
git clone https://github.com/slightech/MYNT-EYE-S-SDK.git 
cd MYNT-EYE-S-SDK
make ros

我在make ros这一步出现了问题,问题报错如下:

CMake Warning at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:33 (find_package):
  Could not find a package configuration file provided by
  "image_transport" with any of the following names:
 
    image_transportConfig.cmake
    image_transport-config.cmake
 

意思是缺少那个image_transport这个包,安装即可:

sudo apt install ros-melodic-image-transport

接着提示缺少了nodelet、tf、rviz这几个包,也是类似的安装即可。于是make ros编译通过了。

然后使用catkin_make编译工程:

cd ../../  #回到~/ROS_WORKSPACE/mynt_eye_sdk下
catkin_make #一定要在工程mynt_eye_sdk这个工程目录下与src同一级处进行编译,不然报错

接着是回到MYNT-EYE-S-SDK目录下对SDK进行初始化和sample的编译

cd src/MYNT-EYE-S-SDK/
make init
make install
make sample

最终添加环境变量:

vim ~/.bashrc
#在最后一行添加如下信息
source /home/john/ROS_WORKSPACE/mynt_eye_sdk/devel/setup.bash 
source ~/.bashrc #让其生效

查看相机的参数./samples/_output/bin/get_img_params:

I/get_img_params.cc:44 Intrinsics left: {equidistant, width: 752, height: 480, k2: -0.03343625026121679, k3: 0.03328763961737054, k4: -0.04048481801793070, k5: 0.01375595617338635, mu: 368.00109936663506005, mv: 368.14125585024601151, u0: 382.46605022163305421, v0: 232.38885544094148372}
I/get_img_params.cc:45 Intrinsics right: {equidistant, width: 752, height: 480, k2: -0.03027553142278981, k3: 0.02497931491439021, k4: -0.03194112777437654, k5: 0.01197489501731172, mu: 368.18639597962368271, mv: 368.27519893909658322, u0: 375.06808327853707397, v0: 242.96186355063645124}
I/get_img_params.cc:46 Extrinsics right to left: {rotation: [0.99998231287269768, -0.00135018727967198, -0.00579231698717417, 0.00132975946115195, 0.99999288852827484, -0.00352911216211198, 0.00579704075762551, 0.00352134735394022, 0.99997699695106357], translation: [-120.35795667555478872, -0.01660120727134306, -0.93897253440181172]}
I/get_img_params.cc:52 ROSMsgInfoPair:
I/get_img_params.cc:53 left:
width: 752, height: 480
distortion_model: KANNALA_BRANDT
D: -0.03343625026121679,0.03328763961737054,-0.04048481801793070,0.01375595617338635,0.00000000000000000,
K: 368.00109936663506005,0.00000000000000000,382.46605022163305421,0.00000000000000000,368.14125585024601151,232.38885544094148372,0.00000000000000000,0.00000000000000000,1.00000000000000000,
R: 0.99999728123590015,-0.00118474845969421,0.00200845510164209,0.00118829414163281,0.99999773617885857,-0.00176510458352707,-0.00200635934992244,0.00176748642005512,0.99999642525056764,
P: 368.20822739467132578,0.00000000000000000,388.46754455566406250,0.00000000000000000,0.00000000000000000,368.20822739467132578,226.83135223388671875,0.00000000000000000,0.00000000000000000,0.00000000000000000,1.00000000000000000,0.00000000000000000,

right:
width: 752, height: 480
distortion_model: KANNALA_BRANDT
D: -0.03027553142278981,0.02497931491439021,-0.03194112777437654,0.01197489501731172,0.00000000000000000,
K: 368.18639597962368271,0.00000000000000000,375.06808327853707397,0.00000000000000000,368.27519893909658322,242.96186355063645124,0.00000000000000000,0.00000000000000000,1.00000000000000000,
R: 0.99996956018038186,0.00013792774812838,0.00780126198701029,-0.00015168705369697,0.99999843412066314,0.00176316399105472,-0.00780100658193649,-0.00176429367110679,0.99996801527056400,
P: 368.20822739467132578,0.00000000000000000,388.46754455566406250,-44318.13891650510777254,0.00000000000000000,368.20822739467132578,226.83135223388671875,0.00000000000000000,0.00000000000000000,0.00000000000000000,1.00000000000000000,0.00000000000000000,

于是SDK的ROS工程也建立了,SDK工具也安装了。

      2. 安装ORB-SLAM2

        ORB-SLAM2的地址为:小觅提供的下载 ,最好用这个,因为官方的存在usleep(300)这行报错,需要自己手动添加unitsd.h这个头文件。当然能到跑ORB-SLAM2的demo这一步了,肯定要有的依赖都安装了,若是没有,则在编译的时候根据提示来进行安装依赖。

mkdir -p MYNT-ORB2/src/ #创建ORB-SLAM的工作空间
cd MYNT-ORB2/src/ #当前路径为:/home/john/ROS_WORKSPACE/MYNT-ORB2/src
#git clone 也比较慢,也是下载的压缩包,然后放到了这个位置上了
git clone https://github.com/slightech/MYNT-EYE-ORB-SLAM2-Sample.git

因为ORB-SLAM2中自身存在ROS的工程,所以不需要ros make,只需要catkin_make即可:

cd ..   #回到上一级与src同级目录,路径为/home/john/ROS_WORKSPACE/MYNT-ORB2
catkin_make

接着就是添加环境变量,有ROS的包路径和ORB-SLAM这个工程下的环境:

vim ~/.bashrc
#在末尾添加这两行,第一行的路径为git clone ORB-SLAM2下来的路径
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/john/ROS_WORKSPACE/MYNT-ORB2/src/MYNT-EYE-ORB-SLAM2-Sample
source /home/john/ROS_WORKSPACE/MYNT-ORB2/devel/setup.bash
source ~/.bashrc

最后就是对ORB-SLAM2进行安装:

cd src/MYNT-EYE-ORB-SLAM2-Sample/ #调到ORB-SLAM2的目录下
chmod +x build.sh
./build.sh
chmod +x build_ros.sh
./build_ros.sh

./build.sh过程没有报错;而./build_ros.sh过程出现了一些错误,缺少依赖包,安装即可。于是完成ORB-SLAM2的ROS编译。

看一下工程目录树,当前路径为/home/john/ROS_WORKSPACE/MYNT-ORB2下的目录树:

双目小觅相机-S,在ROS上跑通ORB-SLAM2_第2张图片

我们上面所说的与src同级目录,是这个目录树下的src,这也是一个catkin的工作空间。

接着在src目录下添加你所需要的工程,如添加了MYNT-EYE-ORB-SLAM2-Sample,在src路径下的目录树:

双目小觅相机-S,在ROS上跑通ORB-SLAM2_第3张图片

可以看出MYNT-EYE-ORB-SLAM2-Sample这个工程的结构,当然里面也有一个src,不过这个src是MYNT-EYE-ORB-SLAM2-Sample的;而之前说的src是/home/john/ROS_WORKSPACE/MYNT-ORB2工作空间下的src。

3.运行小觅和ORB-SLAM2

在两者都安装和配置完事之后,就可以开始测试了。只是进行简答的测试,就不进行标定了,直接用小觅例子里面标定好的数据,如果标定了相机的话,内外参数放置到:~/ROS_WORKSPACE/MYNT-ORB2/src/MYNT-EYE-ORB-SLAM2-Sample/config的mynteye_s_stereo.yaml中即可。

首先进入到小觅的SDK工程下:

cd ~/ROS_WORKSPACE/mynt_eye_sdk/src/MYNT-EYE-S-SDK
source ./wrappers/ros/devel/setup.bash #在当前的bash中添加环境变量
roslaunch mynt_eye_ros_wrapper mynteye.launch #运行camera的mynt_eye_ros_wrapper

打开另外一个终端来运行ORB-SLAM2:

cd ROS_WORKSPACE/MYNT-ORB2/src/MYNT-EYE-ORB-SLAM2-Sample/
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

双目小觅相机-S,在ROS上跑通ORB-SLAM2_第4张图片

双目小觅相机-S,在ROS上跑通ORB-SLAM2_第5张图片

 

    4.总结

    之前一直不想仔细的看报错的内容,所以花了很多时间搜答案,但是答案很多都是对自己的错误没有作用,所有呀,还是要好好的仔细的研究一下报错的内容,对症下药。

    接下来就是看如何标定相机,使用一个更好的模型来标定相机的投影模型;以及结合IMU的使用了。

 

 

 

 

你可能感兴趣的:(SLAM)