ORB-SLAM2使用TUM深度相机、KITTI单目双目、自己摄像头

安装依赖

sudo apt-get install libglew-dev   #安装Glew  
sudo apt-get install cmake         #安装CMake 3 
#安装Boost  
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev  

编译安装Pangolin

编译安装Pangolin:

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
make

安装OPENCV、Eigen、g2o、BLAS and LAPACK、DBoW2 and g2o (Included in Thirdparty folder)等

见https://www.cnblogs.com/ilym/p/9080141.html

编译ORB_SLAM2

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2 
cd ORB_SLAM2
chmod +x build.sh
./build.sh

注意:首先将build.sh中最后一行的make -j 改为make ,否则容易死机
等待一段时间,就编译成功了!

编译完成后生成libORB_SLAM2.so,其位于lib目录下,

生成的可执行程序mono_tum, mono_kitti, rgbd_tum, stereo_kitti, mono_euroc and stereo_euroc,位于Examples目录下。

RGB-D实例,TUM数据集

#首先把rgb和depth合成assocaite
python associate.py PATH_TO_SEQUENCE/rgb.txt PATH_TO_SEQUENCE/depth.txt > associations.txt 

#然后进入ORB-SLAM2执行
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUMX.yaml PATH_TO_SEQUENCE_FOLDER ASSOCIATIONS_FILE 
#如
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM2.yaml /home/ttwang/ORB_SLAM2/rgbd_dataset_freiburg2_pioneer_360 /home/ttwang/ORB_SLAM2/rgbd_dataset_freiburg2_pioneer_360/associations.txt

单目实例,KITTI左目图像


#使用该数据集,运行下面的命令:
./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTIX.yaml PATH_TO_DATASET_FOLDER/dataset/sequences/SEQUENCE_NUMBER

#针对上述命令,做如下修改:
#将KITTIX.yaml改为 KITTI00-02.yaml、KITTI03.yaml、KITTI04-12.yaml其中之一即可
#PATH_TO_DATASET_FOLDER修改为所下载数据集合放置的位置

#如
./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTI04-12.yaml ~/KITTI/04/

 双目实例,KITTI


#使用该数据集,运行下面的命令:
./Examples/Stereo/stereo_kitti Vocabulary/ORBvoc.txt Examples/Stereo/KITTIX.yaml PATH_TO_DATASET_FOLDER/dataset/sequences/SEQUENCE_NUMBER

#针对上述命令,做如下修改:
#将KITTIX.yaml改为 KITTI00-02.yaml、KITTI03.yaml、KITTI04-12.yaml其中之一即可
#PATH_TO_DATASET_FOLDER修改为所下载数据集合放置的位置

#如
./Examples/Stereo/stereo_kitti Vocabulary/ORBvoc.txt Examples/Stereo/KITTI04-12.yaml ~/KITTI/04/

 

ROS包,笔记本摄像头实例

#建立ROS工作空间,把ORB-SLAM2整个放进去src
catkin_make
cd ~/catkin_ws/src

#将包含Examples/ROS/ORB_SLAM2的路径添加到ROS_PACKAGE_PATH环境变量中。
#打开.bashrc文件并在最后添加以下行,其中PATH为ORB-SLAM2项目所在路径
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/PATH/TO/ORB_SLAM2/Examples/ROS

source ~/.bashrc
#修改ROS/ORB-SLAM2/src/ros_mono.cc中订阅的摄像头话题
#/camera改为自己的 如 /usb_cam
   ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);

#编译orb的ros包
chmod +x build_ros.sh
./build_ros.sh

#启动摄像头
roslaunch usb_cam usb_cam-test.launch

#启动实时slam
rosrun ORB_SLAM2 Mono ~/ORB_SLAM2_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/ORB_SLAM2_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml

编译ros包遇到的问题

`/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv’
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line

出错原因为:libboost_system.so 与libboost_filesystem.so找不到链接目录
解决方案为

locate boost_system //查找到目录 

locate boost_filesystem //查找到目录 

将libboost_system.so、libboost_filesystem.so、
libboost_system.so.1.58.0、libboost_filesystem.so.1.58.0复制到ORB_SLAM2/lib下
并且将ORBSLAM2/Examples/ROS/ORBSLAM2下的Cmakelists.txt中加入库目录,具体为

在set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/…/…/…/lib/libORB_SLAM2.so
之后加入
${PROJECT_SOURCE_DIR}/…/…/…/lib/libboost_filesystem.so
${PROJECT_SOURCE_DIR}/…/…/…/lib/libboost_system.so
 

重新运行.sh即可

你可能感兴趣的:(ROS,slam)