实验环境ubuntu 14.04+ros indigo
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
在’src’目录中可能没有任何软件包,只有一个CMakeLists.txt,返回到catkin_ws中依然可以编译它:
$ cd ~/catkin_ws/
$ catkin_make
gedit ~/.bashrc,之后在.bashrc 最下面添加:
source /opt/ros/indigo/setup.bash`
source ~/catkin_ws/devel/setup.bash`
在~/catkin_ws/src下创建usb_cam,并编译
cd usb_cam
git clone https://github.com/bosch-ros-pkg/usb_cam.git
$ mkdir build
$ cd build
$ cmake ..
$ make
编译成功后可先测试一下usb摄像头
首先开个新的终端,运行roscore,
完成之后再开一个终端, 运行
roslaunch usb_cam usb_cam-test.launch
PS: 在运行该节点之前,需要先配置一下节点参数,打开src/usb_cam-develop/launch文件中的的launch文件,我这里只需要该设备号即可,笔记本电脑的video0一般是网络摄像头,插入usb摄像头一般是video1
参考之前在视觉SLAM 十四讲时写的那些库的安装
1. 方式一、
先转到自己打算存储ORBSLAM2工程的路径,然后执行下列命令
git clone https://github.com/raulmur/ORB_SLAM2.git
cd ORB_SLAM2
chmod +x build.sh
./build.sh
之后会在lib文件夹下生成libORB_SLAM2.so,并且在Examples文件夹下生成mono_tum,mono_kitti, rgbd_tum,stereo_kitti, mono_euroc 和 stereo_euroc。
编译完之后,记得在.bashrc后面加入:
source ~/catkin_ws/src/ORB_SLAM2-master/Examples/ROS/ORB_SLAM2/build/devel/setup.bash
方式二、
cd catkin_ws/src/ORB_SLAM2
mkdir build
cd build
cmake ..
make
2、编译ROS的example
cd ~/catkin_ws/src/ORB_SLAM2/Example/ROS/ORB_SLAM2
mkdir build
cd build
cmake ..
make
进入~/orbslam_ws/src/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)
1、首先我们要启动ros内核,新开一个终端,执行
roscore
2、启动usb_cam摄像头节点,新开一个终端,执行
roslaunch usb_cam usb_cam.launch
3、启动 ORB_SLAM2 的 Mono 节点(单目)
rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
PATH_TO_VOCABULARY是ORBvoc.txt文件路径,PATH_TO_SETTINGS_FILE是你的摄像机内参数文件路径
所以可以在第三个终端输入如下命令:
rosrun ORB_SLAM2 Mono ~/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml