Jetson AGX Xavier ROS 调用usb单目摄像头运行ORB_SLAM2

1. 修改源文件

修改ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc中的代码。

源代码

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

修改为

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

也就是修改为调用usb摄像头。

2. 编译ROS

在ORB_SLAM2中打开终端,运行

build_ros.sh

3. 编译ROS的example

cd ~/ORB_SLAM2/Example/ROS/ORB_SLAM2
mkdir build
cd build
cmake ..
make

4. 运行

打开三个终端,分别运行

roscore
roslaunch usb_cam usb_cam-test.launch
rosrun ORB_SLAM2 Mono ~/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml

这里的Asus.yaml是自带的,应该换成自己摄像头的参数,所以需要对摄像头进行标定。摄像头标定等做了再写。

原文地址:https://www.cnblogs.com/gloria-zhang/p/13891770.html