//編譯ORBSLAM2 build_ros.sh
參考:“http://www.cnblogs.com/bigzhao/p/6635770.html”
1.source ~/.bashrc
出現問題:
ctrl+h,打開.bashrc文件,最後一行加入
source ~/catkin_ws/devel/setup.bash
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/user/ORB_SLAM/ORB_SLAM2(因爲我的orb_slam2前面還有一個orb_slam文件夾)
2.export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/user/ORB_SLAM2/Examples/ROS
3. 編譯build_ros.sh
a) cd ../orb_slam/orbslam2
b) chmod +x build_ros.sh
c) ./build_ros.sh
4. 運行
确保原程序可以编译
a).打开一个终端,运行:roslaunch kinect2_bridge kinect2_bridge.launch
b).再打开另一个终端,输入:rostopic list查看此时Kinect2发布的topic,我用的是/kinect2/qhd/image_color_rect和/kinect2/qhd/image_depth_rect
c).找到源文件ros_rgbd.cc,按照上面3的topic修改里面的ros订阅的内容
d).重新编译工程
chmod +x build_ros.sh
./build_ros.sh
e).在~/ORB_SLAM2/Examples/ROS$ 目录下,运行rosrun ORB_SLAM2 RGBD /home/user/ORB_SLAM/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/user/ORB_SLAM/ORB_SLAM2/Examples/RGB-D/kinect2_qhd.yaml
即可得到实时在线轨迹。