ROS + Kinect2 跑ORB_SLAM2 安装步骤记录

记录一下,总忘,出现问题解决问题,浪费时间。。。。。。。。。

用kinect2 跑ORB_SLAM2要安装 ROS、 安装Kinect2驱动 libfreenect2 以及ros接口 iai-kinect2

然后开始安装编译ORB_SLAM2:

1. github 下载源码解压

2. 添加环境变量在 ./bashrc 中  (添加路径和包)

$ export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/user/ORB_SLAM2/Examples/ROS

3. 编译ORB-SLAM2,第三方库中的DBoW2和g2o,并解压ORB词典,包括编译ORB_SLAM2

$ cd ORB_SLAM2
$ chmod +x build.sh
$ ./build.sh

然后修改订阅话题,运行 ORB_SLAM2:

1. 通过 ros 驱动 kinect2

$ roslaunch kinect2_bridge kinect2_bridge.launch  

2. 用 rostopic list 查阅发布话题(折叠排版好点 。。。)

/kinect2/bond 
/kinect2/hd/camera_info 
/kinect2/hd/image_color 
/kinect2/hd/image_color/compressed 
/kinect2/hd/image_color_rect 
/kinect2/hd/image_color_rect/compressed 
/kinect2/hd/image_depth_rect 
/kinect2/hd/image_depth_rect/compressed 
/kinect2/hd/image_mono 
/kinect2/hd/image_mono/compressed 
/kinect2/hd/image_mono_rect 
/kinect2/hd/image_mono_rect/compressed 
/kinect2/hd/points 
/kinect2/qhd/camera_info 
/kinect2/qhd/image_color 
/kinect2/qhd/image_color/compressed 
/kinect2/qhd/image_color_rect 
/kinect2/qhd/image_color_rect/compressed 
/kinect2/qhd/image_depth_rect 
/kinect2/qhd/image_depth_rect/compressed 
/kinect2/qhd/image_mono 
/kinect2/qhd/image_mono/compressed 
/kinect2/qhd/image_mono_rect 
/kinect2/qhd/image_mono_rect/compressed 
/kinect2/qhd/points 
/kinect2/sd/camera_info 
/kinect2/sd/image_color_rect 
/kinect2/sd/image_color_rect/compressed 
/kinect2/sd/image_depth 
/kinect2/sd/image_depth/compressed 
/kinect2/sd/image_depth_rect 
/kinect2/sd/image_depth_rect/compressed 
/kinect2/sd/image_ir 
/kinect2/sd/image_ir/compressed 
/kinect2/sd/image_ir_rect 
/kinect2/sd/image_ir_rect/compressed 
/kinect2/sd/points 
/rosout 
/rosout_agg
View Code

  选择 /kinect2/qhd/image_color 和 /kinect2/qhd/image_depth_rect 这两个话题

  打开 ORB-SLAM2/Example/ROS/ORBSLAM2/src/ros_rgbd.cc文件,修改订阅话题(68/69行)

message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh,"/kinect2/qhd/image_color",1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh,"/kinect2/qhd/image_depth_rect",1);   

3. 编译 ros 节点

$ chmod +x build_ros.sh
$ ./build_ros.sh 

4. 新建kinect2.yaml文件

  获取内参和畸变系数后,在 ORB_SLAM2/Examples/RGB-D 下新建 kinect2.yaml,参照 Examples/RGB-D/TUM1.yaml修改对应参数。   

5. 运行ORB_SLAM2

  在~/ORB_SLAM2/Examples/ROS$ 目录下,运行:

$ rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/kinect2.yaml

  运行ORB_SLAM2前,确保运行  roslaunch kinect2_bridge kinect2_bridge.launch  发布图片消息

 

原文地址:https://www.cnblogs.com/kidycharon/p/9966336.html