【ORB-SLAM2】(三):单目摄像头+ROS+ORB_SLAM2实时测试

介绍:首先启动一个单目摄像头,其次发布节点话题/usb_cam/image_raw,最后ORB_SLAM2订阅摄像头数据进行处理(这里需要修改相应的源文件里的话题类型,其默认值为 /camera/image_raw)。

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

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

将包含Examples/ROS/ORB_SLAM2的path添加到ROS_PACKAGE_PATH环境变量中,具体执行如下

sudo gedit ~/.bashrc

在最后一行添加

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/zqzy/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/

更新环境变量

source ~/.bashrc

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

chmod +x build_ros.sh
./build_ros.sh

如果报错,请参考:ORB_SLAM2编译出现问题 https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/107392436

2.运行单目节点

(1)打开新终端,启用

roscore

(2)打开单目usb_cam驱动

cd /home/zqzy/catkin_ws/src/usb_cam/launch

source ~/catkin-ws/devel/setup.bash

roslaunch usb_cam usb_cam-test.launch

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

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是我们需要订阅的节点

(4)修改 /home/zqzy/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc 中的节点名称,如下:

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

(5)重新编译

/home/zqzy/catkin_ws/src/ORB_SLAM2
./build_ros.sh

(6)运行

rosrun ORB_SLAM2 Mono /home/zqzy/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/zqzy/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml

结果如下:

 

参考:https://blog.csdn.net/qq_42041303/article/details/103049578

你可能感兴趣的:(SLAM)