欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ORB_SLAM测试3-单目摄像头+ROS+ORB_SLAM2实时测试

程序员文章站 2022-06-12 10:30:39
...

介绍:这篇博客首先启动一个单目摄像头(参看上一篇博客),发布节点话题/usb_cam/image_rawORB_SLAM2订阅摄像头数据进行处理(修改相应的源文件里话题类型,默认是/camera/image_raw)。

git上有ros节点使用介绍,https://github.com/Vincentqyw/ORB-SLAM2-CHINESE

a. 为mono、monoAR、stereore和RGB-D构建节点

将包含Examples/ROS/ORB_SLAM2的path添加到ROS_PACKAGE_PATH环境变量中。

打开.bashrc文件并在最后添加以下行。用克隆ORB SLAM2的文件夹所在位置替换PATH:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS

我的电脑添加如下:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/chen/catkin_ws2/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/

执行build_ros.sh脚本,在/ORB_SLAM2目录下:

chmod +x build_ros.sh
./build_ros.sh

 b. 运行单目节点

对于来自topic/camera/image_raw的单目输入运行节点 ORB_SLAM2/Mono。您需要提供词汇表文件(位于/Vocabulary目录里的.txt文件)和设置文件(PATH_TO_SETTINGS_FILE位于相应的包里的.yaml文件)。

rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE

 我的电脑配置如下:

aaa@qq.com:~$ rosrun ORB_SLAM2 Mono /home/chen/catkin_ws2/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/chen/catkin_ws2/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml

c. 具体运行时分为三步:

(1)打开新终端,启用roscore

(2)打开单目usb_cam驱动

roslaunch usb_cam usb_cam-test.launch

(3)查看目前发布的节点列表

aaa@qq.com:~$ rostopic list
/image_view/output
/image_view/parameter_descriptions
/image_view/parameter_updates
/rosout
/rosout_agg
/usb_cam/camera_info
/usb_cam/image_raw
/usb_cam/image_raw/compressed
/usb_cam/image_raw/compressed/parameter_descriptions
/usb_cam/image_raw/compressed/parameter_updates
/usb_cam/image_raw/compressedDepth
/usb_cam/image_raw/compressedDepth/parameter_descriptions
/usb_cam/image_raw/compressedDepth/parameter_updates
/usb_cam/image_raw/theora
/usb_cam/image_raw/theora/parameter_descriptions
/usb_cam/image_raw/theora/parameter_updates

其中,/usb_cam/image_raw是我们需要订阅的节点,记得在/ros_mono.cc里修改节点名称,如下:

ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);

(4)运行

rosrun ORB_SLAM2 Mono /home/chen/catkin_ws2/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/chen/catkin_ws2/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml

(5)结果如下:

ORB_SLAM测试3-单目摄像头+ROS+ORB_SLAM2实时测试