本文已参与「新人创作礼」活动,一起开启掘金创作之路。
以下内容是按照ORB-SLAM2写的,如果是ORB-SLAM3的话只需更换ORB-SLAM2为ORB-SLAM3即可
首先关于如何调用USB双目摄像头请先移步链接 另外关于ORB-SLAM2的安装,可以先移步我的踩坑记录 按照上面链接配置好后,执行
rostopic list
你应该可以找到两个比较关键的节点:/left_cam/image_raw 和 /right_cam/image_raw
然后是ORB-SLAM2的安装与配置 如果根据上面的链接ORB-slam2已经跑通Demo 接下来我们要修改orb_slam_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_stereo.cc 找到
message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/camera/left/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/camera/right/image_raw", 1);
修改为
message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/left_cam/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/right_cam/image_raw", 1);
然后
cd /orb_slam_ws/src/ORB_SLAM2
./build_ros.sh
接下来
rosrun ORB_SLAM2 Stereo /home/daybeha/Documents/github/orb_slam_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/daybeha/Documents/github/orb_slam_ws/src/ORB_SLAM2/Examples/Stereo/mystereo.yaml false
其中mystereo.yaml需要包含你的相机标定数据(注意该文件的版本,ORB-SLAM2和ORB-SLAM3v1.0以上的格式不太一样)
对于ORB-SLAM3v1.0,即便do_rectify的选项为“false",只要yaml内有相关内容,就会自动进行校正。
/home/daybeha/Documents/github/ORB_SLAM3/Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml /home/daybeha/Documents/Dataset/EuRoc/V1_01_easy ./Examples/Stereo/EuRoC_TimeStamps/V101.txt dataset-V101_stereo
num_seq = 1
file name: dataset-V101_stereo
Loading images for sequence 0...LOADED!
-------
ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
under certain conditions. See LICENSE.txt.
Input sensor was set to: Stereo
Loading settings from ./Examples/Stereo/EuRoC.yaml
-Loaded camera 1
-Loaded camera 2
-Loaded image info
-Loaded ORB settings
-Loaded viewer settings
-Loaded Atlas settings
-Loaded misc parameters
-Computed rectification maps
----------------------------------
SLAM settings:
-Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ]
-Camera 1 distortion parameters: [ -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ]
-Camera 2 parameters (Pinhole: [ 457.58700561523438 456.13400268554688 379.99899291992188 255.23800659179688 ]
-Camera 1 distortion parameters: [ -0.2836836576461792 0.074512839317321777 -0.00010473000293131918 -3.555907096597366e-05 ]
-Original image size: [ 752 , 480 ]
-Current image size: [ 752 , 480 ]
-Camera 1 parameters after rectification: [ 456.71499633789062 456.71499633789062 364.52615356445312 257.268798828125 ]
-Sequence FPS: 20
-Stereo baseline: 0.11007785052061081
-Stereo depth threshold : 60
-Features per image: 1200
-ORB scale factor: 1.2000000476837158
-ORB number of scales: 8
-Initial FAST threshold: 20
-Min FAST threshold: 7
Loading ORB Vocabulary. This could take a while...
Camera1.k3 optional parameter does not exist...
Camera2.k3 optional parameter does not exist...
Camera.newHeight optional parameter does not exist...
Camera.newWidth optional parameter does not exist...
System.LoadAtlasFromFile optional parameter does not exist...
System.SaveAtlasToFile optional parameter does not exist...
System.thFarPoints optional parameter does not exist...
Vocabulary loaded!
Initialization of Atlas from scratch
Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name:
There are 1 cameras in the atlas
Camera 0 is pinhole
First KF:0; Map init KF:0
New Map created with 545 points
Starting the Viewer