除了正常的编译ORB-SLAM之外,在ROS平台下使用USB_CAM来跑通单目ORB-SLAM,需要执行以下命令
cd ORB_SLAM2/Examples/ROS/ORB_SLAM2
mkdir build
cd build
cmake ..
make
(1) 在上面的cmake ..命令中会出编译错误
CMake Error at /opt/ros/indigo/share/ros/core/rosbuild/private.cmake::102
[rosbuild] rospack found package "ORB_SLAM2" at " ",but the current directory is "/home/bigh/ORB_SLAM2/Examples/ROS/ORB_SLAM2",you should double-check your ROS_PACKAGE_PATH to ensure the packages are found in the correct precedence order.
解决方案:
在.bashrc末尾添加;export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/bigh/ORB_SLAM2/Examples/ROS/ORB_SLAM2
关闭终端重新进行CMake ..
(2)由于安装了cuda8.0,在make的过程中出现了错误:cannot find -lopencv_dep_cudart
解决方案:
打开要编译的CMakeLists.txt
在find_package(OpenCV 3.0 QUIET)之前添加
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
解决了上面的两个问题:打开两个终端分别执行:
(1)切换到usb_cam文件夹下的launch文件夹,执行usb_cam-test.launch
cd catkin_ws/usb_cam/usb_cam/launch
roslaunch usb_cam-test.launch
(2)开启新的终端 执行:
rosrun ORB_SLAM2 Mono /home/bigh/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/bigh/ORB_SLAM2/Examples/Monocular/TUM2.yaml